All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] input/serio: Add a firmware_id sysfs attribute
@ 2014-03-20 10:12 Hans de Goede
  2014-03-20 10:12 ` [PATCH 1/2] " Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Hans de Goede @ 2014-03-20 10:12 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Matthew Garrett, Benjamin Tissoires, Peter Hutterer,
	platform-driver-x86, linux-input

Hi All,

For firmware instantiated serio devices, such as devices instantiated
through ACPI, it may be useful for userspace to know the firmware-id
(pnp-id in case of ACPI) through which the device was instantiated.

One concrete example of this is the new ps/2 touchpads found in Lenovo
Thinkpad X240 T440 and T540 laptops, which not only have a special
bottom right click area to emulate right clicks, but also top middle
and top right areas to emulate middle and right clicks for the trackpoint.

Lenove has given these touchpads a unique LENxxxx pnp-id and we would like
to use this to automatically enable emulation of middle and right buttons
in the top area of the clickpad.

Matthew Garret wrote a patch to set the parent of the serio port to the
/sys/devices/pnp0/00:xx device so that we could get the necessary info that
way, but Dmitry rightfully pointed out that that would break suspend/resume
ordering, see:
https://lkml.org/lkml/2014/2/23/63
https://lkml.org/lkml/2014/3/7/428

So while discussing this with Peter Hutterer I made the plan to add a
/dev/devices/platform/i8042/serioX/firmware_parent symlink pointing to the
relevant /sys/devices/pnp0/00:xx device, and add a little udev-helper + rules
file to read this symlink and add an attribute to the udevdb with the
pnp-id this way.

This however is harder then it sounds, I spend a couple of hours on how
to do this in a race free manner and I could not come up with one. The
problem is that the sysfs_create_symlink call needs to be done after the
device_add call, at which point an add uevent has already been fired.
Causing a theoretical race where the udev-helper would not find the symlink,
this can be fixed with an extra change event after adding the symlink, but
then any higher userspace levels need to re-check on a change event as well.
So after spending too much time on this I decided to go for an alternative
solution.

Which in the end turns out to be much nicer too, since it gets rid of needing
a udev-helper too. After this much too long introduction I'll let the patches
speak for themselves.

With this patch-set one can now do:

[hans@shalem linux]$ udevadm info -p /devices/platform/i8042/serio1
P: /devices/platform/i8042/serio1
E: DEVPATH=/devices/platform/i8042/serio1
E: MODALIAS=serio:ty01pr00id00ex00
E: SERIO_EXTRA=00
E: SERIO_FIRMWARE_ID=PNP0f03 PNP0f13
E: SERIO_ID=00
E: SERIO_PROTO=00
E: SERIO_TYPE=01
E: SUBSYSTEM=serio

And the info we need is just there in the new SERIO_FIRMWARE_ID attribute,
for completeness the patch-set also adds:

[hans@shalem linux]$ cat /sys/devices/platform/i8042/serio1/firmware_id 
PNP0f03 PNP0f13

Regards,

Hans

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

end of thread, other threads:[~2014-03-28 16:04 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20 10:12 [PATCH 0/2] input/serio: Add a firmware_id sysfs attribute Hans de Goede
2014-03-20 10:12 ` [PATCH 1/2] " Hans de Goede
2014-03-20 10:12 ` [PATCH 2/2] input/serio/8042: Add firmware_id support Hans de Goede
2014-03-20 17:21 ` [PATCH 0/2] input/serio: Add a firmware_id sysfs attribute Matthew Garrett
2014-03-24  1:07   ` Peter Hutterer
2014-03-28  7:56   ` Dmitry Torokhov
2014-03-28  8:12     ` Hans de Goede
2014-03-28  8:17       ` Dmitry Torokhov
2014-03-28  8:29         ` Hans de Goede
2014-03-28  8:52           ` Dmitry Torokhov
2014-03-28  9:00             ` Matthew Garrett
2014-03-28 16:04               ` Dmitry Torokhov
2014-03-28  9:05             ` Hans de Goede
2014-03-28  8:20     ` Matthew Garrett
2014-03-28  8:24       ` Dmitry Torokhov
2014-03-28  8:27         ` Matthew Garrett
2014-03-28  8:50           ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.