Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: sensor: fix attributes in HID sensor interface

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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Ooi, Joyce and committed by
Jiri Kosina
4c4480aa 021afd55

+3 -3
+3 -3
drivers/hid/hid-sensor-custom.c
··· 292 292 bool input = false; 293 293 int value = 0; 294 294 295 - if (sscanf(attr->attr.name, "feature-%d-%x-%s", &index, &usage, 295 + if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage, 296 296 name) == 3) { 297 297 feature = true; 298 298 field_index = index + sensor_inst->input_field_count; 299 - } else if (sscanf(attr->attr.name, "input-%d-%x-%s", &index, &usage, 299 + } else if (sscanf(attr->attr.name, "input-%x-%x-%s", &index, &usage, 300 300 name) == 3) { 301 301 input = true; 302 302 field_index = index; ··· 398 398 char name[HID_CUSTOM_NAME_LENGTH]; 399 399 int value; 400 400 401 - if (sscanf(attr->attr.name, "feature-%d-%x-%s", &index, &usage, 401 + if (sscanf(attr->attr.name, "feature-%x-%x-%s", &index, &usage, 402 402 name) == 3) { 403 403 field_index = index + sensor_inst->input_field_count; 404 404 } else