LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation
@ 2015-02-26 17:58 Azael Avalos
  2015-02-26 17:58 ` [PATCH 1/3] toshiba_haps: Replace sscanf with kstrtoint Azael Avalos
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Azael Avalos @ 2015-02-26 17:58 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos

These patches make some misc chanes to the driver, replacing sscanf with
kstrtoint, DEVICE_ATTR_{RW, WO} macros and adding documentation about
the sysfs entries.

Azael Avalos (3):
  toshiba_haps: Replace sscanf with kstrtoint
  toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros
  Documentation/ABI: Add file describing the sysfs entries for
    toshiba_haps

 .../ABI/testing/sysfs-driver-toshiba_haps          | 20 ++++++++++++++
 drivers/platform/x86/toshiba_haps.c                | 32 ++++++++++++++--------
 2 files changed, 40 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-toshiba_haps

-- 
2.2.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] toshiba_haps: Replace sscanf with kstrtoint
  2015-02-26 17:58 [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Azael Avalos
@ 2015-02-26 17:58 ` Azael Avalos
  2015-02-26 17:58 ` [PATCH 2/3] toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros Azael Avalos
  2015-03-06 18:32 ` [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Darren Hart
  2 siblings, 0 replies; 6+ messages in thread
From: Azael Avalos @ 2015-02-26 17:58 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos

This patch simply replaces the use of sscanf with kstrtoint returning
the error code in case that something went bad.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
 drivers/platform/x86/toshiba_haps.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c
index 65300b6..db6cc53 100644
--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -78,15 +78,20 @@ static ssize_t protection_level_store(struct device *dev,
 				      const char *buf, size_t count)
 {
 	struct toshiba_haps_dev *haps = dev_get_drvdata(dev);
-	int level, ret;
-
-	if (sscanf(buf, "%d", &level) != 1 || level < 0 || level > 3)
-		return -EINVAL;
+	int level;
+	int ret;
 
-	/* Set the sensor level.
-	 * Acceptable levels are:
+	ret = kstrtoint(buf, 0, &level);
+	if (ret)
+		return ret;
+	/*
+	 * Check for supported levels, which can be:
 	 * 0 - Disabled | 1 - Low | 2 - Medium | 3 - High
 	 */
+	if (level < 0 || level > 3)
+		return -EINVAL;
+
+	/* Set the sensor level */
 	ret = toshiba_haps_protection_level(haps->acpi_dev->handle, level);
 	if (ret != 0)
 		return ret;
@@ -101,9 +106,14 @@ static ssize_t reset_protection_store(struct device *dev,
 				      const char *buf, size_t count)
 {
 	struct toshiba_haps_dev *haps = dev_get_drvdata(dev);
-	int reset, ret;
+	int reset;
+	int ret;
 
-	if (sscanf(buf, "%d", &reset) != 1 || reset != 1)
+	ret = kstrtoint(buf, 0, &reset);
+	if (ret)
+		return ret;
+	/* The only accepted value is 1 */
+	if (reset != 1)
 		return -EINVAL;
 
 	/* Reset the protection interface */
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros
  2015-02-26 17:58 [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Azael Avalos
  2015-02-26 17:58 ` [PATCH 1/3] toshiba_haps: Replace sscanf with kstrtoint Azael Avalos
@ 2015-02-26 17:58 ` Azael Avalos
  2015-03-06 18:32 ` [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Darren Hart
  2 siblings, 0 replies; 6+ messages in thread
From: Azael Avalos @ 2015-02-26 17:58 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, linux-kernel; +Cc: Azael Avalos

This patch makes use of DEVICE_ATTR_{RW, WO} macros, simplifying
device attributes creation.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
 drivers/platform/x86/toshiba_haps.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c
index db6cc53..7f2afc6 100644
--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -100,6 +100,7 @@ static ssize_t protection_level_store(struct device *dev,
 
 	return count;
 }
+static DEVICE_ATTR_RW(protection_level);
 
 static ssize_t reset_protection_store(struct device *dev,
 				      struct device_attribute *attr,
@@ -123,10 +124,7 @@ static ssize_t reset_protection_store(struct device *dev,
 
 	return count;
 }
-
-static DEVICE_ATTR(protection_level, S_IRUGO | S_IWUSR,
-		   protection_level_show, protection_level_store);
-static DEVICE_ATTR(reset_protection, S_IWUSR, NULL, reset_protection_store);
+static DEVICE_ATTR_WO(reset_protection);
 
 static struct attribute *haps_attributes[] = {
 	&dev_attr_protection_level.attr,
-- 
2.2.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation
  2015-02-26 17:58 [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Azael Avalos
  2015-02-26 17:58 ` [PATCH 1/3] toshiba_haps: Replace sscanf with kstrtoint Azael Avalos
  2015-02-26 17:58 ` [PATCH 2/3] toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros Azael Avalos
@ 2015-03-06 18:32 ` Darren Hart
  2015-05-04 18:10   ` Azael Avalos
  2 siblings, 1 reply; 6+ messages in thread
From: Darren Hart @ 2015-03-06 18:32 UTC (permalink / raw)
  To: Azael Avalos; +Cc: platform-driver-x86, linux-kernel

On Thu, Feb 26, 2015 at 10:58:29AM -0700, Azael Avalos wrote:
> These patches make some misc chanes to the driver, replacing sscanf with
> kstrtoint, DEVICE_ATTR_{RW, WO} macros and adding documentation about
> the sysfs entries.
> 
> Azael Avalos (3):
>   toshiba_haps: Replace sscanf with kstrtoint
>   toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros
>   Documentation/ABI: Add file describing the sysfs entries for
>     toshiba_haps
> 
>  .../ABI/testing/sysfs-driver-toshiba_haps          | 20 ++++++++++++++
>  drivers/platform/x86/toshiba_haps.c                | 32 ++++++++++++++--------
>  2 files changed, 40 insertions(+), 12 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-driver-toshiba_haps

Queued for 4.1, thanks Azael.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation
  2015-03-06 18:32 ` [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Darren Hart
@ 2015-05-04 18:10   ` Azael Avalos
  2015-05-06 22:08     ` Darren Hart
  0 siblings, 1 reply; 6+ messages in thread
From: Azael Avalos @ 2015-05-04 18:10 UTC (permalink / raw)
  To: Darren Hart; +Cc: platform-driver-x86, linux-kernel

Hi Darren,


2015-03-06 11:32 GMT-07:00 Darren Hart <dvhart@infradead.org>:
> On Thu, Feb 26, 2015 at 10:58:29AM -0700, Azael Avalos wrote:
>> These patches make some misc chanes to the driver, replacing sscanf with
>> kstrtoint, DEVICE_ATTR_{RW, WO} macros and adding documentation about
>> the sysfs entries.
>>
>> Azael Avalos (3):
>>   toshiba_haps: Replace sscanf with kstrtoint
>>   toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros
>>   Documentation/ABI: Add file describing the sysfs entries for
>>     toshiba_haps
>>
>>  .../ABI/testing/sysfs-driver-toshiba_haps          | 20 ++++++++++++++
>>  drivers/platform/x86/toshiba_haps.c                | 32 ++++++++++++++--------
>>  2 files changed, 40 insertions(+), 12 deletions(-)
>>  create mode 100644 Documentation/ABI/testing/sysfs-driver-toshiba_haps
>
> Queued for 4.1, thanks Azael.

These patches were supposed to be included in 4.1,
but somehow they didn't, can you re-queue for 4.2?

>
> --
> Darren Hart
> Intel Open Source Technology Center


Cheers
Azael


-- 
-- El mundo apesta y vosotros apestais tambien --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation
  2015-05-04 18:10   ` Azael Avalos
@ 2015-05-06 22:08     ` Darren Hart
  0 siblings, 0 replies; 6+ messages in thread
From: Darren Hart @ 2015-05-06 22:08 UTC (permalink / raw)
  To: Azael Avalos; +Cc: platform-driver-x86, linux-kernel

On Mon, May 04, 2015 at 12:10:41PM -0600, Azael Avalos wrote:
> Hi Darren,
> 
> 
> 2015-03-06 11:32 GMT-07:00 Darren Hart <dvhart@infradead.org>:
> > On Thu, Feb 26, 2015 at 10:58:29AM -0700, Azael Avalos wrote:
> >> These patches make some misc chanes to the driver, replacing sscanf with
> >> kstrtoint, DEVICE_ATTR_{RW, WO} macros and adding documentation about
> >> the sysfs entries.
> >>
> >> Azael Avalos (3):
> >>   toshiba_haps: Replace sscanf with kstrtoint
> >>   toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros
> >>   Documentation/ABI: Add file describing the sysfs entries for
> >>     toshiba_haps
> >>
> >>  .../ABI/testing/sysfs-driver-toshiba_haps          | 20 ++++++++++++++
> >>  drivers/platform/x86/toshiba_haps.c                | 32 ++++++++++++++--------
> >>  2 files changed, 40 insertions(+), 12 deletions(-)
> >>  create mode 100644 Documentation/ABI/testing/sysfs-driver-toshiba_haps
> >
> > Queued for 4.1, thanks Azael.
> 
> These patches were supposed to be included in 4.1,
> but somehow they didn't, can you re-queue for 4.2?

So sorry, I honestly have no idea what happened :/ I don't reply with queued
until I have them in a branch... apologies. You should see them in for-next by
tomorrow.

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-06 22:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 17:58 [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Azael Avalos
2015-02-26 17:58 ` [PATCH 1/3] toshiba_haps: Replace sscanf with kstrtoint Azael Avalos
2015-02-26 17:58 ` [PATCH 2/3] toshiba_haps: Make use of DEVICE_ATTR_{RW, WO} macros Azael Avalos
2015-03-06 18:32 ` [PATCH 0/3] toshiba_haps: Some misc changes plus sysfs entries documentation Darren Hart
2015-05-04 18:10   ` Azael Avalos
2015-05-06 22:08     ` Darren Hart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).