linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dev->uniq is not unique for individual USB interfaces
@ 2025-07-21 22:31 Andrey Smirnov
  2025-08-04  7:20 ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Smirnov @ 2025-07-21 22:31 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires; +Cc: linux-usb, open list:HID CORE LAYER

Hey folks:

I'm working on a custom USB device that presents N battery powered HID
interfaces with each interface reporting its own battery life via
standard HID Power Device report. The problem I'm running into is that

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/hid-input.c?h=v6.16-rc7#n524

assumes that "uniq" field of a "struct hid_device" is always unique, but

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/usbhid/hid-core.c?h=v6.16-rc7#n1415

populates "uniq" with iSerialNumber which is only unique per USB
device, not per USB interface. At the first glance the right way to
fix this would be to change how uniq is generated by usbhid_probe()
but that probably would break some userspace assumptions? Should this
be wrapped in a quirk? Is there a good way to add a fix to support my
use-case?

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

* Re: dev->uniq is not unique for individual USB interfaces
  2025-07-21 22:31 dev->uniq is not unique for individual USB interfaces Andrey Smirnov
@ 2025-08-04  7:20 ` Jiri Kosina
  2025-08-05  3:11   ` Andrey Smirnov
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2025-08-04  7:20 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Benjamin Tissoires, linux-usb, open list:HID CORE LAYER

On Mon, 21 Jul 2025, Andrey Smirnov wrote:

> Hey folks:
> 
> I'm working on a custom USB device that presents N battery powered HID
> interfaces with each interface reporting its own battery life via
> standard HID Power Device report. The problem I'm running into is that
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/hid-input.c?h=v6.16-rc7#n524
> 
> assumes that "uniq" field of a "struct hid_device" is always unique, but
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/usbhid/hid-core.c?h=v6.16-rc7#n1415
> 
> populates "uniq" with iSerialNumber which is only unique per USB
> device, not per USB interface. At the first glance the right way to
> fix this would be to change how uniq is generated by usbhid_probe()
> but that probably would break some userspace assumptions? 

Hmm, actually, from top of my head I am not able to come up with any 
userspace breakage this might cause. Do you have anything particular on 
mind?

Thanks,

-- 
Jiri Kosina
SUSE Labs


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

* Re: dev->uniq is not unique for individual USB interfaces
  2025-08-04  7:20 ` Jiri Kosina
@ 2025-08-05  3:11   ` Andrey Smirnov
  0 siblings, 0 replies; 3+ messages in thread
From: Andrey Smirnov @ 2025-08-05  3:11 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-usb, open list:HID CORE LAYER

On Mon, Aug 4, 2025 at 12:20 AM Jiri Kosina <jikos@kernel.org> wrote:
>
> On Mon, 21 Jul 2025, Andrey Smirnov wrote:
>
> > Hey folks:
> >
> > I'm working on a custom USB device that presents N battery powered HID
> > interfaces with each interface reporting its own battery life via
> > standard HID Power Device report. The problem I'm running into is that
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/hid-input.c?h=v6.16-rc7#n524
> >
> > assumes that "uniq" field of a "struct hid_device" is always unique, but
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/usbhid/hid-core.c?h=v6.16-rc7#n1415
> >
> > populates "uniq" with iSerialNumber which is only unique per USB
> > device, not per USB interface. At the first glance the right way to
> > fix this would be to change how uniq is generated by usbhid_probe()
> > but that probably would break some userspace assumptions?
>
> Hmm, actually, from top of my head I am not able to come up with any
> userspace breakage this might cause. Do you have anything particular on
> mind?


No, not really. It sounds like we can try to fix this without gating
the change by a quirk. I'll try to put together a path in the next
couple of days, then.

Thanks!

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

end of thread, other threads:[~2025-08-05  3:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 22:31 dev->uniq is not unique for individual USB interfaces Andrey Smirnov
2025-08-04  7:20 ` Jiri Kosina
2025-08-05  3:11   ` Andrey Smirnov

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