linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute
@ 2014-04-14 10:30 Hans de Goede
  2014-04-14 10:30 ` [PATCH v3 1/2] " Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hans de Goede @ 2014-04-14 10:30 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Benjamin Tissoires, Peter Hutterer, linux-input

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

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

* [PATCH v3 1/2] input/serio: Add a firmware_id sysfs attribute
  2014-04-14 10:30 [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Hans de Goede
@ 2014-04-14 10:30 ` Hans de Goede
  2014-04-14 10:34 ` [PATCH v3 2/2] input/serio/8042: Add firmware_id support Hans de Goede
  2014-04-20  5:31 ` [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Dmitry Torokhov
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2014-04-14 10:30 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Benjamin Tissoires, Peter Hutterer, linux-input, Hans de Goede

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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 drivers/input/serio/serio.c | 12 ++++++++++++
 include/linux/serio.h       |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 8f4c4ab..1788a4d 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -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;
 }
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 36aac73..9f779c7 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -23,6 +23,7 @@ struct serio {
 
 	char name[32];
 	char phys[32];
+	char firmware_id[128];
 
 	bool manual_bind;
 
-- 
1.9.0


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

* [PATCH v3 2/2] input/serio/8042: Add firmware_id support
  2014-04-14 10:30 [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Hans de Goede
  2014-04-14 10:30 ` [PATCH v3 1/2] " Hans de Goede
@ 2014-04-14 10:34 ` Hans de Goede
  2014-04-20  5:31 ` [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Dmitry Torokhov
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2014-04-14 10:34 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Benjamin Tissoires, Peter Hutterer, linux-input, Hans de Goede

Fill in the new serio firmware_id sysfs attribute for pnp instantiated
8042 serio ports.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 drivers/input/serio/i8042-x86ia64io.h | 15 +++++++++++++++
 drivers/input/serio/i8042.c           |  6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 0ec9abb..381b20d 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -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;
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 020053f..3807c3e 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -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);
-- 
1.9.0


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

* Re: [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute
  2014-04-14 10:30 [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Hans de Goede
  2014-04-14 10:30 ` [PATCH v3 1/2] " Hans de Goede
  2014-04-14 10:34 ` [PATCH v3 2/2] input/serio/8042: Add firmware_id support Hans de Goede
@ 2014-04-20  5:31 ` Dmitry Torokhov
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2014-04-20  5:31 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Benjamin Tissoires, Peter Hutterer, linux-input

On Mon, Apr 14, 2014 at 12:30:17PM +0200, Hans de Goede wrote:
> 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

Applied, thank you.

-- 
Dmitry

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

end of thread, other threads:[~2014-04-20  5:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 10:30 [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Hans de Goede
2014-04-14 10:30 ` [PATCH v3 1/2] " Hans de Goede
2014-04-14 10:34 ` [PATCH v3 2/2] input/serio/8042: Add firmware_id support Hans de Goede
2014-04-20  5:31 ` [PATCH v3 0/2] input/serio: Add a firmware_id sysfs attribute Dmitry Torokhov

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