Search code examples
linuxkernelhid

How to explain path under /sys/bus/hid/devices


I am studying about HID driver, and there is one thing I cannot find out any document about it. Hope someone can help me.

When a HID device mount, I can found it on /sys/bus/hid/devices, it may looks like

0003:045E:0773.0002

Now, I known its format should be BUS:VID:PID.N. My question is, what is the N (in above example, 0002)? A HID mounting order? Or a index? And where can I find the document about this? Thanks.


Solution

  • N is just a unique number - in other words, mounting order, though relying on that would be risky.

    You can see where it is assigned in the source of hid_add_device here:

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

    You didn't ask about the other fields, but for completeness: