Re: [PATCH 2/4] usb: core: set mod_name in driver registration
From: Greg Kroah-Hartman
Date: Thu Sep 10 2026 - 08:52:48 EST
On Wed, Jul 22, 2026 at 12:31:22PM +0900, Shashank Balaji wrote:
> The driver core only creates the sysfs "module" symlink for a built-in
> driver when its struct device_driver has mod_name set (see
> module_add_driver()). This registration path left mod_name unset, so built-in
> drivers using it had no such symlink.
>
> Set mod_name to KBUILD_MODNAME during driver registration. Built-in
> drivers now gain the symlink, while loadable modules are unaffected.
>
> Co-developed-by: Rahul Bukte <rahul.bukte@xxxxxxxx>
> Signed-off-by: Rahul Bukte <rahul.bukte@xxxxxxxx>
> Signed-off-by: Shashank Balaji <shashank.mahadasyam@xxxxxxxx>
> ---
> include/linux/usb.h | 4 ++--
> drivers/usb/core/driver.c | 4 +++-
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 2466183a45f0..6507c217bca7 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -1369,9 +1369,9 @@ extern void usb_deregister(struct usb_driver *);
> usb_deregister)
>
> #define usb_register_device_driver(new_udriver) \
> - __usb_register_device_driver(new_udriver, THIS_MODULE)
> + __usb_register_device_driver(new_udriver, THIS_MODULE, KBUILD_MODNAME)
It seems odd to me that struct module doesn't contain the name of the
module, and you have to pass this around all the time...
Anyway, all now queued up, thanks!
greg k-h