Linux Input/HID development
 help / color / mirror / Atom feed
From: Matteo Bruni <mbruni@codeweavers.com>
To: sashiko-bot@kernel.org
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 1/2] HID: core: include product version in the uevent
Date: Fri, 27 Nov 2026 13:46:03 +0100	[thread overview]
Message-ID: <388d3d6e5a4f988f4a4be2c436cdd2ee652336f8.camel@codeweavers.com> (raw)
In-Reply-To: <sashiko-outbox-235847@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 2758 bytes --]

On Thu, 2026-11-26 at 15:50 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] HID: core: redundant unprefixed PRODUCT uevent in
>   hid_uevent()
> --
> 
> commit f1a7bbe068e7bfcbcd219202f30241d7b9e0e8bc
> Author: Matteo Bruni <mbruni@codeweavers.com>
> 
> HID: core: include product version in the uevent
> 
> This commit adds a PRODUCT variable containing the bus, vendor, product,
> and version fields to the HID device uevent environment.
> 
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > index 64ac7606927ca..6b71104aa3319 100644
> > --- a/drivers/hid/hid-core.c
> > +++ b/drivers/hid/hid-core.c
> > @@ -3003,6 +3003,10 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)
> >  			return -ENOMEM;
> >  	}
> >  
> > +	if (add_uevent_var(env, "PRODUCT=%x/%x/%x/%x",
> > +			   hdev->bus, hdev->vendor, hdev->product, hdev->version))
> > +		return -ENOMEM;
> 
> [Severity: Medium]
> Does adding an unprefixed four-field PRODUCT variable to hid_uevent()
> conflict with the parent USB device's PRODUCT uevent while duplicating
> existing HID sysfs and uevent attributes?
> 
> For USB HID devices, usb_uevent() on the parent USB node emits a
> three-field PRODUCT=%x/%x/%x (idVendor/idProduct/bcdDevice), whereas
> usbhid_parse() sets hid->version to hdesc->bcdHID (the HID specification
> version) before the HID device uevent is emitted.  Consumers or udev rules
> walking up parent devices from hidraw looking for USB's three-field
> PRODUCT variable will hit this four-field bus/vendor/product/bcdHID value
> on the child HID device first and misparse the fields.

I suspect this might be a fair concern. FWIW, I picked the four-field
PRODUCT= line "schema" from input devices, which is what is used by
Wine for non-hidraw devices. Using the same format for hidraw
(including UHID) devices seemed pretty natural and makes the required
Wine change very small.

> In addition, other variables in hid_uevent() use the HID_ prefix (with
> HID_ID already exporting bus, vendor, and product), and commit
> cdf826a94e0f ("HID: core: Expose id attributes in sysfs") already exposes
> hdev->version for all HID and UHID devices via the id/version sysfs
> attribute.

That's a relatively recent addition to the kernel and one I wasn't
aware of. I have a WIP Wine patch to directly read
<sys_path>/id/version to get to the version info. It's quite a bit
unfortunate that this is effectively the only case in that component
where we can't use the udev API to retrieve the information we want.
I'm not entirely sure if it's going to be considered acceptable
upstream.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 557 bytes --]

      reply	other threads:[~2026-11-27 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 15:39 [PATCH 1/2] HID: core: include product version in the uevent Matteo Bruni
2026-11-26 15:39 ` [PATCH 2/2] samples: uhid: use a non-zero version Matteo Bruni
2026-11-26 15:43   ` sashiko-bot
2026-11-26 15:50 ` [PATCH 1/2] HID: core: include product version in the uevent sashiko-bot
2026-11-27 12:46   ` Matteo Bruni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=388d3d6e5a4f988f4a4be2c436cdd2ee652336f8.camel@codeweavers.com \
    --to=mbruni@codeweavers.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox