linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface
@ 2016-11-03 10:55 Ooi, Joyce
  2016-11-04 14:03 ` Benjamin Tissoires
  2016-11-05 15:58 ` Jiri Kosina
  0 siblings, 2 replies; 4+ messages in thread
From: Ooi, Joyce @ 2016-11-03 10:55 UTC (permalink / raw)
  To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada
  Cc: Benjamin Tissoires, linux-input, linux-iio, linux-kernel,
	Ooi Joyce, Kweh Hock Leong, Ong Boon Leong, Lay Kuan Loon

User is unable to access to input-X-yyy and feature-X-yyy where
X is a hex value and more than 9 (e.g. input-a-yyy, feature-b-yyy) in HID
sensor custom sysfs interface.
This is because when creating the attribute, the attribute index is
written to using %x (hex). However, when reading and writing values into
the attribute, the attribute index is scanned using %d (decimal). Hence,
user is unable to access to attributes with index in hex values
(e.g. 'a', 'b', 'c') but able to access to attributes with index in
decimal values (e.g. 1, 2, 3,..).
This fix will change input-%d-%x-%s and feature-%d-%x-%s to input-%x-%x-%s
and feature-%x-%x-%s in show_values() and store_values() accordingly.

Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com>
---
 drivers/hid/hid-sensor-custom.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 5614fee..3a84aaf 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -292,11 +292,11 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
 	bool input = false;
 	int value = 0;
 
-	if (sscanf(attr->attr.name, "feature-%d-%x-%s", &index, &usage,
+	if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage,
 		   name) == 3) {
 		feature = true;
 		field_index = index + sensor_inst->input_field_count;
-	} else if (sscanf(attr->attr.name, "input-%d-%x-%s", &index, &usage,
+	} else if (sscanf(attr->attr.name, "input-%x-%x-%s", &index, &usage,
 		   name) == 3) {
 		input = true;
 		field_index = index;
@@ -398,7 +398,7 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr,
 	char name[HID_CUSTOM_NAME_LENGTH];
 	int value;
 
-	if (sscanf(attr->attr.name, "feature-%d-%x-%s", &index, &usage,
+	if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage,
 		   name) == 3) {
 		field_index = index + sensor_inst->input_field_count;
 	} else
-- 
1.9.1

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

* Re: [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface
  2016-11-03 10:55 [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface Ooi, Joyce
@ 2016-11-04 14:03 ` Benjamin Tissoires
  2016-11-04 17:49   ` Srinivas Pandruvada
  2016-11-05 15:58 ` Jiri Kosina
  1 sibling, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2016-11-04 14:03 UTC (permalink / raw)
  To: Ooi, Joyce
  Cc: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, linux-input,
	linux-iio, linux-kernel, Kweh Hock Leong, Ong Boon Leong,
	Lay Kuan Loon

On Nov 03 2016 or thereabouts, Ooi, Joyce wrote:
> User is unable to access to input-X-yyy and feature-X-yyy where
> X is a hex value and more than 9 (e.g. input-a-yyy, feature-b-yyy) in HID
> sensor custom sysfs interface.
> This is because when creating the attribute, the attribute index is
> written to using %x (hex). However, when reading and writing values into
> the attribute, the attribute index is scanned using %d (decimal). Hence,
> user is unable to access to attributes with index in hex values
> (e.g. 'a', 'b', 'c') but able to access to attributes with index in
> decimal values (e.g. 1, 2, 3,..).
> This fix will change input-%d-%x-%s and feature-%d-%x-%s to input-%x-%x-%s
> and feature-%x-%x-%s in show_values() and store_values() accordingly.
> 
> Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com>

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

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

* Re: [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface
  2016-11-04 14:03 ` Benjamin Tissoires
@ 2016-11-04 17:49   ` Srinivas Pandruvada
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2016-11-04 17:49 UTC (permalink / raw)
  To: Benjamin Tissoires, Ooi, Joyce
  Cc: Jiri Kosina, Jonathan Cameron, linux-input, linux-iio,
	linux-kernel, Kweh Hock Leong, Ong Boon Leong, Lay Kuan Loon

On Fri, 2016-11-04 at 15:03 +0100, Benjamin Tissoires wrote:
> On Nov 03 2016 or thereabouts, Ooi, Joyce wrote:
> > 
> > User is unable to access to input-X-yyy and feature-X-yyy where
> > X is a hex value and more than 9 (e.g. input-a-yyy, feature-b-yyy)
> > in HID
> > sensor custom sysfs interface.
> > This is because when creating the attribute, the attribute index is
> > written to using %x (hex). However, when reading and writing values
> > into
> > the attribute, the attribute index is scanned using %d (decimal).
> > Hence,
> > user is unable to access to attributes with index in hex values
> > (e.g. 'a', 'b', 'c') but able to access to attributes with index in
> > decimal values (e.g. 1, 2, 3,..).
> > This fix will change input-%d-%x-%s and feature-%d-%x-%s to input-
> > %x-%x-%s
> > and feature-%x-%x-%s in show_values() and store_values()
> > accordingly.
> > 
> > Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com>
> 
> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> 

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

* Re: [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface
  2016-11-03 10:55 [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface Ooi, Joyce
  2016-11-04 14:03 ` Benjamin Tissoires
@ 2016-11-05 15:58 ` Jiri Kosina
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2016-11-05 15:58 UTC (permalink / raw)
  To: Ooi, Joyce
  Cc: Jonathan Cameron, Srinivas Pandruvada, Benjamin Tissoires,
	linux-input, linux-iio, linux-kernel, Kweh Hock Leong,
	Ong Boon Leong, Lay Kuan Loon

On Thu, 3 Nov 2016, Ooi, Joyce wrote:

> User is unable to access to input-X-yyy and feature-X-yyy where
> X is a hex value and more than 9 (e.g. input-a-yyy, feature-b-yyy) in HID
> sensor custom sysfs interface.
> This is because when creating the attribute, the attribute index is
> written to using %x (hex). However, when reading and writing values into
> the attribute, the attribute index is scanned using %d (decimal). Hence,
> user is unable to access to attributes with index in hex values
> (e.g. 'a', 'b', 'c') but able to access to attributes with index in
> decimal values (e.g. 1, 2, 3,..).
> This fix will change input-%d-%x-%s and feature-%d-%x-%s to input-%x-%x-%s
> and feature-%x-%x-%s in show_values() and store_values() accordingly.
> 
> Signed-off-by: Ooi, Joyce <joyce.ooi@intel.com>

Applied to hid.git#for-4.9/upstream-fixes. Thanks,

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2016-11-05 15:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 10:55 [PATCH] hid: sensor: fix input and feature attributes in HID sensor custom sysfs interface Ooi, Joyce
2016-11-04 14:03 ` Benjamin Tissoires
2016-11-04 17:49   ` Srinivas Pandruvada
2016-11-05 15:58 ` Jiri Kosina

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).