linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* HID device names
@ 2009-10-12 13:02 Jean Delvare
  2009-10-12 14:01 ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Delvare @ 2009-10-12 13:02 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input

Hi Jiri,

Looking at hid-core.c, I see the following:

	dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
	             hdev->vendor, hdev->product, atomic_inc_return(&id));

This looks plain wrong to me. The vendor and product IDs can be
attributes of the devices, but they should not be part of the device
name aka bus_id. The bus_id is about the address of the device, not
what the device is. Just look at how the PCI or USB subsystems do, or
virtually any other kernel subsystem, as I don't think any other
subsystem does what HID is doing right now.

On top of this, using an auto-incrementing device ID in the bus_id
looks wrong too. For one thing, it will cycle after 65536 requests, so
the above does not guarantee uniqueness over time. If anything, you
should used an idr instead. But even that would probably be wrong,
because this scheme itself doesn't guarantee stability of the bus_id
over disconnect/reconnect, reboot, etc. While I agree it's not always
possible to guarantee stability especially for externally pluggable
devices, we should try to keep names as stable as we can.

The above makes me wonder if handling hid as a bus is really the right
thing to do, as apparently your devices do not have an address you can
use to generate a good-looking bus_id. Shouldn't hid devices be class
devices instead?

-- 
Jean Delvare

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

end of thread, other threads:[~2009-10-12 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-12 13:02 HID device names Jean Delvare
2009-10-12 14:01 ` Jiri Kosina
2009-10-12 14:49   ` Jean Delvare

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