input/serio: Add a firmware_id sysfs attribute
Subsystems (2)
v3 cover input/serio: Add a firmware_id sysfs attribute
Hi All,
Here is v3 of my serio firmware_id sysfs attribute patch-set
Changes in v2:
-Add a helper function to avoid copy/pasting the code for building
the firmware_id string from pnp_ids
Changes in v3:
-Prefix the firmware_id string for 8042-pnp devices which "PNP: " so that
it will be easy to differentiate pnp-ids from ie devicetree ids in the future
Regards,
Hans
PATCH v3 1/2 input/serio: Add a firmware_id sysfs attribute
serio devices exposed via platform firmware interfaces such as ACPI may provide additional identifying information of use to userspace.
We don't associate the serio devices with the firmware device (we don't set it as parent), so there's no way for userspace to make use of this information.
We cannot change the parent for serio devices instantiated though a firmware interface as that would break suspend / resume ordering.
Therefor this patch adds a new firmware_id sysfs attribute so that userspace can get a string from there with any additional identifying information the firmware interface may provide.
--- drivers/input/serio/serio.c | 12 ++++++++++++ include/linux/serio.h | 1 + 2 files changed, 13 insertions(+)
drivers/input/serio/serio.c +12 -0
@@ -451,6 +451,13 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *return retval; } +static ssize_t firmware_id_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct serio *serio =to_serio_port (dev); + +return sprintf (buf,"%s\n" , serio->firmware_id); +} +static DEVICE_ATTR_RO (type);static DEVICE_ATTR_RO (proto);static DEVICE_ATTR_RO (id);
@@ -473,12 +480,14 @@ static DEVICE_ATTR_RO(modalias);static DEVICE_ATTR_WO (drvctl); static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); +static DEVICE_ATTR_RO (firmware_id);static struct attribute *serio_device_attrs[] = { &dev_attr_modalias.attr, &dev_attr_description.attr, &dev_attr_drvctl.attr, &dev_attr_bind_mode.attr, + &dev_attr_firmware_id.attr,NULL };
@@ -923,6 +932,9 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)SERIO_ADD_UEVENT_VAR ("SERIO_EXTRA=%02x" , serio->id.extra);SERIO_ADD_UEVENT_VAR ("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X" , serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); +if (serio->firmware_id[0 ]) +SERIO_ADD_UEVENT_VAR ("SERIO_FIRMWARE_ID=%s" , + serio->firmware_id);return 0 ; }
include/linux/serio.h +1 -0
@@ -23,6 +23,7 @@ struct serio {char name[32 ];char phys[32 ]; +char firmware_id[128 ];bool manual_bind;
Signature · 1 line
1.9.0
PATCH v3 2/2 input/serio/8042: Add firmware_id support
In reply to Hans de GoedeFill in the new serio firmware_id sysfs attribute for pnp instantiated 8042 serio ports.
--- drivers/input/serio/i8042-x86ia64io.h | 15 +++++++++++++++ drivers/input/serio/i8042.c | 6 ++++++ 2 files changed, 21 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +15 -0
@@ -702,6 +702,17 @@ static int i8042_pnp_aux_irq;static char i8042_pnp_kbd_name[32 ];static char i8042_pnp_aux_name[32 ]; +static void i8042_pnp_id_to_string (struct pnp_id *id,char *dst,int dst_size) +{ +strlcpy (dst,"PNP:" , dst_size); + +while (id) { +strlcat (dst," " , dst_size); +strlcat (dst, id->id, dst_size); + id = id->next; + } +} +static int i8042_pnp_kbd_probe (struct pnp_dev *dev,const struct pnp_device_id *did) {if (pnp_port_valid (dev,0 ) &&pnp_port_len (dev,0 ) ==1 )
@@ -718,6 +729,8 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *strlcat (i8042_pnp_kbd_name,":" ,sizeof (i8042_pnp_kbd_name));strlcat (i8042_pnp_kbd_name,pnp_dev_name (dev),sizeof (i8042_pnp_kbd_name)); } +i8042_pnp_id_to_string (dev->id, i8042_kbd_firmware_id, +sizeof (i8042_kbd_firmware_id));/* Keyboard ports are always supposed to be wakeup-enabled */ device_set_wakeup_enable (&dev->dev, true);
@@ -742,6 +755,8 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *strlcat (i8042_pnp_aux_name,":" ,sizeof (i8042_pnp_aux_name));strlcat (i8042_pnp_aux_name,pnp_dev_name (dev),sizeof (i8042_pnp_aux_name)); } +i8042_pnp_id_to_string (dev->id, i8042_aux_firmware_id, +sizeof (i8042_aux_firmware_id)); i8042_pnp_aux_devices++;return 0 ;
drivers/input/serio/i8042.c +6 -0
@@ -87,6 +87,8 @@ MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off");#endif static bool i8042_bypass_aux_irq_test; +static char i8042_kbd_firmware_id[128 ]; +static char i8042_aux_firmware_id[128 ];#include "i8042.h"
@@ -1218,6 +1220,8 @@ static int __init i8042_create_kbd_port(void) serio->dev.parent = &i8042_platform_device->dev;strlcpy (serio->name,"i8042 KBD port" ,sizeof (serio->name));strlcpy (serio->phys,I8042_KBD_PHYS_DESC ,sizeof (serio->phys)); +strlcpy (serio->firmware_id, i8042_kbd_firmware_id, +sizeof (serio->firmware_id)); port->serio = serio; port->irq =I8042_KBD_IRQ ;
@@ -1244,6 +1248,8 @@ static int __init i8042_create_aux_port(int idx)if (idx <0 ) {strlcpy (serio->name,"i8042 AUX port" ,sizeof (serio->name));strlcpy (serio->phys,I8042_AUX_PHYS_DESC ,sizeof (serio->phys)); +strlcpy (serio->firmware_id, i8042_aux_firmware_id, +sizeof (serio->firmware_id)); serio->close = i8042_port_close; }else {snprintf (serio->name,sizeof (serio->name),"i8042 AUX%d port" , idx);
Signature · 1 line
1.9.0
Quoted 11 lines · Hans de Goede
Hi All,
Here is v3 of my serio
firmware_idsysfs attribute patch-setChanges in v2:
-Add a helper function to avoid copy/pasting the code for building
thefirmware_idstring frompnp_idsChanges in v3:
-Prefix thefirmware_idstring for 8042-pnp devices which "PNP: " so that
it will be easy to differentiate pnp-ids from ie devicetree ids in the future
Applied, thank you.
Signature · 1 line
Dmitry