HID device names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux