Re: [RFC PATCH] USB: core: emit a device-level modalias

From: Alan Stern

Date: Wed Oct 07 2026 - 13:55:36 EST


On Wed, Oct 07, 2026 at 06:17:21PM +0200, Giuseppe Piscitelli wrote:
> USB device drivers can load from interface modaliases after a userspace
> client has already configured the device. Loading apple-mfi-fastcharge
> then reprobes the generic binding and interrupts usbmuxd transfers.

This description is very confusing for anyone who doesn't already know
what you're talking about. Are you referring to some particular type of
device? If not, why mention apple-mfi-fastcharge and usbmuxd? If yes,
you should say what type of device and why apple-mfi-fastcharge and
usbmuxd would get loaded in the first place.

> Emit a modalias on the device event, with unknown interface fields left
> as wildcards.

Why? What does this accomplish? How does it prevent
apple-mfi-fastcharge from interrupting usbmuxd transfers?

> The existing udev module loader can load matching modules
> before consumers receive the processed device event.

Why do you say "_existing_ udev module loader"? Are you trying to
reassure people who might think there was a _nonexistent_ udev module
loader?

What processed device event? Is this the uevent added by the patch or
is it something else? In what way does it get "processed"?

Sure, the udev module loader _can_ load matching modules before
consumers receive the processed device event. But udev might run slowly
and not get around to loading matching modules until later. What will
happen then?

Alan Stern

> Keep interface
> modaliases and the driver teardown paths unchanged.
>
> Signed-off-by: Giuseppe Piscitelli <ooonea@xxxxxxxxx>
> Assisted-by: OpenAI Codex
> ---
> Tested on x86_64 with Linux 7.2.9 and an iPhone (05ac:12a8). With no
> Apple module preload, the first insertion after boot loads the module,
> keeps configuration 4 and works with iLoader without restarting usbmuxd.
> The current usb_uevent function also passes 18 source-extracted cases.
>
> drivers/usb/core/driver.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index 3c3bbaf89..29d1acba9 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -954,6 +954,17 @@ static int usb_uevent(const struct device *dev, struct kobj_uevent_env *env)
> usb_dev->descriptor.bDeviceProtocol))
> return -ENOMEM;
>
> + if (is_usb_device(dev) &&
> + add_uevent_var(env,
> + "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*in*",
> + le16_to_cpu(usb_dev->descriptor.idVendor),
> + le16_to_cpu(usb_dev->descriptor.idProduct),
> + le16_to_cpu(usb_dev->descriptor.bcdDevice),
> + usb_dev->descriptor.bDeviceClass,
> + usb_dev->descriptor.bDeviceSubClass,
> + usb_dev->descriptor.bDeviceProtocol))
> + return -ENOMEM;
> +
> return 0;
> }
>
>
> base-commit: 42bcac323cc3b16566fed8c5b250318ad02a0de0
>