Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers
@ 2026-07-22  3:31 Shashank Balaji
  2026-07-22  3:31 ` [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro Shashank Balaji
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Shashank Balaji @ 2026-07-22  3:31 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded, Shashank Balaji

This is in continuation to [1].

struct device_driver's mod_name is not set by a number of bus' driver registration
functions. Without that, built-in drivers don't have the module symlink in sysfs.
We want this to go from unbound driver name -> module name -> kernel config name.
This is useful on embedded platforms to minimize kernel config, reduce kernel size,
and reduce boot time.

This patchset adds mod_name to usb-related drivers.

[1] https://lore.kernel.org/all/20260518-acpi_mod_name-v5-0-705ccc430885@sony.com/

Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
---
Shashank Balaji (4):
      usb: core: pass THIS_MODULE implicitly through a macro
      usb: core: set mod_name in driver registration
      usb: typec: set mod_name in driver registration
      usb: ulpi: set mod_name in driver registration

 include/linux/ulpi/driver.h             |  4 ++--
 include/linux/usb.h                     |  6 ++++--
 include/linux/usb/typec_altmode.h       |  4 ++--
 drivers/net/usb/r8152.c                 |  2 +-
 drivers/usb/common/ulpi.c               |  4 +++-
 drivers/usb/core/driver.c               | 10 ++++++----
 drivers/usb/core/usb.c                  |  2 +-
 drivers/usb/misc/apple-mfi-fastcharge.c |  2 +-
 drivers/usb/misc/onboard_usb_dev.c      |  2 +-
 drivers/usb/typec/bus.c                 |  4 +++-
 drivers/usb/usbip/stub_main.c           |  2 +-
 11 files changed, 25 insertions(+), 17 deletions(-)
---
base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
change-id: 20260722-mod_name_usb-e3baf58e1e1e

Best regards,
--  
Shashank Balaji <shashank.mahadasyam@sony.com>


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

* [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
@ 2026-07-22  3:31 ` Shashank Balaji
  2026-07-27 12:19   ` Bastien Nocera
  2026-07-22  3:31 ` [PATCH 2/4] usb: core: set mod_name in driver registration Shashank Balaji
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Shashank Balaji @ 2026-07-22  3:31 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded, Shashank Balaji

Rename usb_register_device_driver() to __usb_register_device_driver() and replace
it with a macro wrapper that passes THIS_MODULE implicitly. This is in line with
what other buses do.

Co-developed-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
---
 include/linux/usb.h                     | 4 +++-
 drivers/net/usb/r8152.c                 | 2 +-
 drivers/usb/core/driver.c               | 6 +++---
 drivers/usb/core/usb.c                  | 2 +-
 drivers/usb/misc/apple-mfi-fastcharge.c | 2 +-
 drivers/usb/misc/onboard_usb_dev.c      | 2 +-
 drivers/usb/usbip/stub_main.c           | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 1da4ad1610bc..2466183a45f0 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1368,7 +1368,9 @@ extern void usb_deregister(struct usb_driver *);
 	module_driver(__usb_driver, usb_register, \
 		       usb_deregister)
 
-extern int usb_register_device_driver(struct usb_device_driver *,
+#define usb_register_device_driver(new_udriver) \
+	__usb_register_device_driver(new_udriver, THIS_MODULE)
+extern int __usb_register_device_driver(struct usb_device_driver *,
 			struct module *);
 extern void usb_deregister_device_driver(struct usb_device_driver *);
 
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f61686433031..73b9b2af1ed2 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -10495,7 +10495,7 @@ static int __init rtl8152_driver_init(void)
 {
 	int ret;
 
-	ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
+	ret = usb_register_device_driver(&rtl8152_cfgselector_driver);
 	if (ret)
 		return ret;
 
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index f63004417058..eac1ff468c08 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -980,7 +980,7 @@ bool is_usb_device_driver(const struct device_driver *drv)
 }
 
 /**
- * usb_register_device_driver - register a USB device (not interface) driver
+ * __usb_register_device_driver - register a USB device (not interface) driver
  * @new_udriver: USB operations for the device driver
  * @owner: module owner of this driver.
  *
@@ -990,7 +990,7 @@ bool is_usb_device_driver(const struct device_driver *drv)
  *
  * Return: A negative error code on failure and 0 on success.
  */
-int usb_register_device_driver(struct usb_device_driver *new_udriver,
+int __usb_register_device_driver(struct usb_device_driver *new_udriver,
 		struct module *owner)
 {
 	int retval = 0;
@@ -1023,7 +1023,7 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
 
 	return retval;
 }
-EXPORT_SYMBOL_GPL(usb_register_device_driver);
+EXPORT_SYMBOL_GPL(__usb_register_device_driver);
 
 /**
  * usb_deregister_device_driver - unregister a USB device (not interface) driver
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index df166cafe106..2559a180fdee 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1241,7 +1241,7 @@ static int __init usb_init(void)
 	retval = usb_hub_init();
 	if (retval)
 		goto hub_init_failed;
-	retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);
+	retval = usb_register_device_driver(&usb_generic_driver);
 	if (!retval)
 		goto out;
 
diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index af266e19f2fd..02adec28d9e6 100644
--- a/drivers/usb/misc/apple-mfi-fastcharge.c
+++ b/drivers/usb/misc/apple-mfi-fastcharge.c
@@ -245,7 +245,7 @@ static struct usb_device_driver mfi_fc_driver = {
 
 static int __init mfi_fc_driver_init(void)
 {
-	return usb_register_device_driver(&mfi_fc_driver, THIS_MODULE);
+	return usb_register_device_driver(&mfi_fc_driver);
 }
 
 static void __exit mfi_fc_driver_exit(void)
diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c
index 11508ed4df25..c60406240416 100644
--- a/drivers/usb/misc/onboard_usb_dev.c
+++ b/drivers/usb/misc/onboard_usb_dev.c
@@ -706,7 +706,7 @@ static int __init onboard_dev_init(void)
 {
 	int ret;
 
-	ret = usb_register_device_driver(&onboard_dev_usbdev_driver, THIS_MODULE);
+	ret = usb_register_device_driver(&onboard_dev_usbdev_driver);
 	if (ret)
 		return ret;
 
diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index 79110a69d697..01452f7bdabb 100644
--- a/drivers/usb/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
@@ -371,7 +371,7 @@ static int __init usbip_host_init(void)
 		return -ENOMEM;
 	}
 
-	ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
+	ret = usb_register_device_driver(&stub_driver);
 	if (ret) {
 		pr_err("usb_register failed %d\n", ret);
 		goto err_usb_register;

-- 
2.43.0


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

* [PATCH 2/4] usb: core: set mod_name in driver registration
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
  2026-07-22  3:31 ` [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro Shashank Balaji
@ 2026-07-22  3:31 ` Shashank Balaji
  2026-07-22  3:31 ` [PATCH 3/4] usb: typec: " Shashank Balaji
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Shashank Balaji @ 2026-07-22  3:31 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded, Shashank Balaji

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@sony.com>
Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
---
 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)
 extern int __usb_register_device_driver(struct usb_device_driver *,
-			struct module *);
+			struct module *, const char *);
 extern void usb_deregister_device_driver(struct usb_device_driver *);
 
 extern int usb_register_dev(struct usb_interface *intf,
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index eac1ff468c08..ab809cb6da26 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -983,6 +983,7 @@ bool is_usb_device_driver(const struct device_driver *drv)
  * __usb_register_device_driver - register a USB device (not interface) driver
  * @new_udriver: USB operations for the device driver
  * @owner: module owner of this driver.
+ * @mod_name: module name string
  *
  * Registers a USB device driver with the USB core.  The list of
  * unattached devices will be rescanned whenever a new driver is
@@ -991,7 +992,7 @@ bool is_usb_device_driver(const struct device_driver *drv)
  * Return: A negative error code on failure and 0 on success.
  */
 int __usb_register_device_driver(struct usb_device_driver *new_udriver,
-		struct module *owner)
+		struct module *owner, const char *mod_name)
 {
 	int retval = 0;
 
@@ -1003,6 +1004,7 @@ int __usb_register_device_driver(struct usb_device_driver *new_udriver,
 	new_udriver->driver.probe = usb_probe_device;
 	new_udriver->driver.remove = usb_unbind_device;
 	new_udriver->driver.owner = owner;
+	new_udriver->driver.mod_name = mod_name;
 	new_udriver->driver.dev_groups = new_udriver->dev_groups;
 
 	retval = driver_register(&new_udriver->driver);

-- 
2.43.0


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

* [PATCH 3/4] usb: typec: set mod_name in driver registration
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
  2026-07-22  3:31 ` [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro Shashank Balaji
  2026-07-22  3:31 ` [PATCH 2/4] usb: core: set mod_name in driver registration Shashank Balaji
@ 2026-07-22  3:31 ` Shashank Balaji
  2026-07-27 11:39   ` Heikki Krogerus
  2026-07-22  3:31 ` [PATCH 4/4] usb: ulpi: " Shashank Balaji
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Shashank Balaji @ 2026-07-22  3:31 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded, Shashank Balaji

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 driver left mod_name unset, so its built-in
form 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@sony.com>
Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
---
 include/linux/usb/typec_altmode.h | 4 ++--
 drivers/usb/typec/bus.c           | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
index ef21ead551be..92309b569c3a 100644
--- a/include/linux/usb/typec_altmode.h
+++ b/include/linux/usb/typec_altmode.h
@@ -227,9 +227,9 @@ struct typec_altmode_driver {
  * handle all SVID specific communication.
  */
 #define typec_altmode_register_driver(drv) \
-		__typec_altmode_register_driver(drv, THIS_MODULE)
+		__typec_altmode_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
 int __typec_altmode_register_driver(struct typec_altmode_driver *drv,
-				    struct module *module);
+				    struct module *module, const char *mod_name);
 /**
  * typec_altmode_unregister_driver - unregisters a USB Type-C alternate mode
  * 				     device driver
diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index e84b134a3381..587d3b06ee8d 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -383,12 +383,14 @@ void typec_altmode_put_plug(struct typec_altmode *plug)
 EXPORT_SYMBOL_GPL(typec_altmode_put_plug);
 
 int __typec_altmode_register_driver(struct typec_altmode_driver *drv,
-				    struct module *module)
+				    struct module *module,
+				    const char *mod_name)
 {
 	if (!drv->probe)
 		return -EINVAL;
 
 	drv->driver.owner = module;
+	drv->driver.mod_name = mod_name;
 	drv->driver.bus = &typec_bus;
 
 	return driver_register(&drv->driver);

-- 
2.43.0


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

* [PATCH 4/4] usb: ulpi: set mod_name in driver registration
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
                   ` (2 preceding siblings ...)
  2026-07-22  3:31 ` [PATCH 3/4] usb: typec: " Shashank Balaji
@ 2026-07-22  3:31 ` Shashank Balaji
  2026-07-23 23:07 ` [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Bird, Tim
  2026-07-27 12:21 ` Bastien Nocera
  5 siblings, 0 replies; 9+ messages in thread
From: Shashank Balaji @ 2026-07-22  3:31 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded, Shashank Balaji

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 driver left mod_name unset, so its built-in
form 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@sony.com>
Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
---
 include/linux/ulpi/driver.h | 4 ++--
 drivers/usb/common/ulpi.c   | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/linux/ulpi/driver.h b/include/linux/ulpi/driver.h
index c668d9c8d876..c899197e0aa8 100644
--- a/include/linux/ulpi/driver.h
+++ b/include/linux/ulpi/driver.h
@@ -51,8 +51,8 @@ struct ulpi_driver {
 /*
  * use a macro to avoid include chaining to get THIS_MODULE
  */
-#define ulpi_register_driver(drv) __ulpi_register_driver(drv, THIS_MODULE)
-int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module);
+#define ulpi_register_driver(drv) __ulpi_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
+int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module, const char *mod_name);
 void ulpi_unregister_driver(struct ulpi_driver *drv);
 
 #define module_ulpi_driver(__ulpi_driver) \
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 7e43429e996e..dec4baca1c53 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -147,15 +147,17 @@ static const struct device_type ulpi_dev_type = {
  * __ulpi_register_driver - register a driver with the ULPI bus
  * @drv: driver being registered
  * @module: ends up being THIS_MODULE
+ * @mod_name: ends up being KBUILD_MODNAME
  *
  * Registers a driver with the ULPI bus.
  */
-int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module)
+int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module, const char *mod_name)
 {
 	if (!drv->probe)
 		return -EINVAL;
 
 	drv->driver.owner = module;
+	drv->driver.mod_name = mod_name;
 	drv->driver.bus = &ulpi_bus;
 
 	return driver_register(&drv->driver);

-- 
2.43.0


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

* RE: [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
                   ` (3 preceding siblings ...)
  2026-07-22  3:31 ` [PATCH 4/4] usb: ulpi: " Shashank Balaji
@ 2026-07-23 23:07 ` Bird, Tim
  2026-07-27 12:21 ` Bastien Nocera
  5 siblings, 0 replies; 9+ messages in thread
From: Bird, Tim @ 2026-07-23 23:07 UTC (permalink / raw)
  To: Shashank.Mahadasyam@sony.com, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Greg Kroah-Hartman,
	Bastien Nocera, Matthias Kaehlcke, Valentina Manea, Shuah Khan,
	Hongren Zheng, Heikki Krogerus
  Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Daniel.Palmer@sony.com,
	Rahul.Bukte@sony.com, linux-embedded@vger.kernel.org

> -----Original Message-----
> From: Mahadasyam, Shashank (SGC) <Shashank.Mahadasyam@sony.com>
> Subject: [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers
> 
> This is in continuation to [1].
> 
> struct device_driver's mod_name is not set by a number of bus' driver registration
> functions. Without that, built-in drivers don't have the module symlink in sysfs.
> We want this to go from unbound driver name -> module name -> kernel config name.
> This is useful on embedded platforms to minimize kernel config, reduce kernel size,
> and reduce boot time.
> 
> This patchset adds mod_name to usb-related drivers.
> 
> [1] https://lore.kernel.org/all/20260518-acpi_mod_name-v5-0-705ccc430885@sony.com/
> 
> Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
> ---
> Shashank Balaji (4):
>       usb: core: pass THIS_MODULE implicitly through a macro
>       usb: core: set mod_name in driver registration
>       usb: typec: set mod_name in driver registration
>       usb: ulpi: set mod_name in driver registration
> 
>  include/linux/ulpi/driver.h             |  4 ++--
>  include/linux/usb.h                     |  6 ++++--
>  include/linux/usb/typec_altmode.h       |  4 ++--
>  drivers/net/usb/r8152.c                 |  2 +-
>  drivers/usb/common/ulpi.c               |  4 +++-
>  drivers/usb/core/driver.c               | 10 ++++++----
>  drivers/usb/core/usb.c                  |  2 +-
>  drivers/usb/misc/apple-mfi-fastcharge.c |  2 +-
>  drivers/usb/misc/onboard_usb_dev.c      |  2 +-
>  drivers/usb/typec/bus.c                 |  4 +++-
>  drivers/usb/usbip/stub_main.c           |  2 +-
>  11 files changed, 25 insertions(+), 17 deletions(-)
> ---
> base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
> change-id: 20260722-mod_name_usb-e3baf58e1e1e

FWIW, I looked through these and they look OK to me.  I didn't see
any obvious errors (but I'm not a USB or driver or sysfs developer).
Given that, a "Reviewed-by" might be too strong, but you can add
an "Acked-by" for me if you'd like.

We should talk some time about my (half-baked) tool to find the
config options associated with files and source code line numbers.
It sounds like it has similar goals to what these patches are trying to
enable.
 -- Tim


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

* Re: [PATCH 3/4] usb: typec: set mod_name in driver registration
  2026-07-22  3:31 ` [PATCH 3/4] usb: typec: " Shashank Balaji
@ 2026-07-27 11:39   ` Heikki Krogerus
  0 siblings, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2026-07-27 11:39 UTC (permalink / raw)
  To: Shashank Balaji
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Greg Kroah-Hartman, Bastien Nocera,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded

On Wed, Jul 22, 2026 at 12:31:23PM +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 driver left mod_name unset, so its built-in
> form 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@sony.com>
> Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
> Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  include/linux/usb/typec_altmode.h | 4 ++--
>  drivers/usb/typec/bus.c           | 4 +++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h
> index ef21ead551be..92309b569c3a 100644
> --- a/include/linux/usb/typec_altmode.h
> +++ b/include/linux/usb/typec_altmode.h
> @@ -227,9 +227,9 @@ struct typec_altmode_driver {
>   * handle all SVID specific communication.
>   */
>  #define typec_altmode_register_driver(drv) \
> -		__typec_altmode_register_driver(drv, THIS_MODULE)
> +		__typec_altmode_register_driver(drv, THIS_MODULE, KBUILD_MODNAME)
>  int __typec_altmode_register_driver(struct typec_altmode_driver *drv,
> -				    struct module *module);
> +				    struct module *module, const char *mod_name);
>  /**
>   * typec_altmode_unregister_driver - unregisters a USB Type-C alternate mode
>   * 				     device driver
> diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
> index e84b134a3381..587d3b06ee8d 100644
> --- a/drivers/usb/typec/bus.c
> +++ b/drivers/usb/typec/bus.c
> @@ -383,12 +383,14 @@ void typec_altmode_put_plug(struct typec_altmode *plug)
>  EXPORT_SYMBOL_GPL(typec_altmode_put_plug);
>  
>  int __typec_altmode_register_driver(struct typec_altmode_driver *drv,
> -				    struct module *module)
> +				    struct module *module,
> +				    const char *mod_name)
>  {
>  	if (!drv->probe)
>  		return -EINVAL;
>  
>  	drv->driver.owner = module;
> +	drv->driver.mod_name = mod_name;
>  	drv->driver.bus = &typec_bus;
>  
>  	return driver_register(&drv->driver);
> 
> -- 
> 2.43.0

-- 
heikki

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

* Re: [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro
  2026-07-22  3:31 ` [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro Shashank Balaji
@ 2026-07-27 12:19   ` Bastien Nocera
  0 siblings, 0 replies; 9+ messages in thread
From: Bastien Nocera @ 2026-07-27 12:19 UTC (permalink / raw)
  To: Shashank Balaji, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Greg Kroah-Hartman,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded

On Wed, 2026-07-22 at 12:31 +0900, Shashank Balaji wrote:
> Rename usb_register_device_driver() to __usb_register_device_driver()
> and replace
> it with a macro wrapper that passes THIS_MODULE implicitly. This is
> in line with
> what other buses do.

I found some examples by grepping for:
git grep 'THIS_MODULE)' include/ | grep driver

It could have been useful to mention some examples by name in the
commit message.

Cheers

> Co-developed-by: Rahul Bukte <rahul.bukte@sony.com>
> Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
> Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
> ---
>  include/linux/usb.h                     | 4 +++-
>  drivers/net/usb/r8152.c                 | 2 +-
>  drivers/usb/core/driver.c               | 6 +++---
>  drivers/usb/core/usb.c                  | 2 +-
>  drivers/usb/misc/apple-mfi-fastcharge.c | 2 +-
>  drivers/usb/misc/onboard_usb_dev.c      | 2 +-
>  drivers/usb/usbip/stub_main.c           | 2 +-
>  7 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 1da4ad1610bc..2466183a45f0 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -1368,7 +1368,9 @@ extern void usb_deregister(struct usb_driver
> *);
>  	module_driver(__usb_driver, usb_register, \
>  		       usb_deregister)
>  
> -extern int usb_register_device_driver(struct usb_device_driver *,
> +#define usb_register_device_driver(new_udriver) \
> +	__usb_register_device_driver(new_udriver, THIS_MODULE)
> +extern int __usb_register_device_driver(struct usb_device_driver *,
>  			struct module *);
>  extern void usb_deregister_device_driver(struct usb_device_driver
> *);
>  
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index f61686433031..73b9b2af1ed2 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -10495,7 +10495,7 @@ static int __init rtl8152_driver_init(void)
>  {
>  	int ret;
>  
> -	ret =
> usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
> +	ret =
> usb_register_device_driver(&rtl8152_cfgselector_driver);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index f63004417058..eac1ff468c08 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -980,7 +980,7 @@ bool is_usb_device_driver(const struct
> device_driver *drv)
>  }
>  
>  /**
> - * usb_register_device_driver - register a USB device (not
> interface) driver
> + * __usb_register_device_driver - register a USB device (not
> interface) driver
>   * @new_udriver: USB operations for the device driver
>   * @owner: module owner of this driver.
>   *
> @@ -990,7 +990,7 @@ bool is_usb_device_driver(const struct
> device_driver *drv)
>   *
>   * Return: A negative error code on failure and 0 on success.
>   */
> -int usb_register_device_driver(struct usb_device_driver
> *new_udriver,
> +int __usb_register_device_driver(struct usb_device_driver
> *new_udriver,
>  		struct module *owner)
>  {
>  	int retval = 0;
> @@ -1023,7 +1023,7 @@ int usb_register_device_driver(struct
> usb_device_driver *new_udriver,
>  
>  	return retval;
>  }
> -EXPORT_SYMBOL_GPL(usb_register_device_driver);
> +EXPORT_SYMBOL_GPL(__usb_register_device_driver);
>  
>  /**
>   * usb_deregister_device_driver - unregister a USB device (not
> interface) driver
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index df166cafe106..2559a180fdee 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -1241,7 +1241,7 @@ static int __init usb_init(void)
>  	retval = usb_hub_init();
>  	if (retval)
>  		goto hub_init_failed;
> -	retval = usb_register_device_driver(&usb_generic_driver,
> THIS_MODULE);
> +	retval = usb_register_device_driver(&usb_generic_driver);
>  	if (!retval)
>  		goto out;
>  
> diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c
> b/drivers/usb/misc/apple-mfi-fastcharge.c
> index af266e19f2fd..02adec28d9e6 100644
> --- a/drivers/usb/misc/apple-mfi-fastcharge.c
> +++ b/drivers/usb/misc/apple-mfi-fastcharge.c
> @@ -245,7 +245,7 @@ static struct usb_device_driver mfi_fc_driver = {
>  
>  static int __init mfi_fc_driver_init(void)
>  {
> -	return usb_register_device_driver(&mfi_fc_driver,
> THIS_MODULE);
> +	return usb_register_device_driver(&mfi_fc_driver);
>  }
>  
>  static void __exit mfi_fc_driver_exit(void)
> diff --git a/drivers/usb/misc/onboard_usb_dev.c
> b/drivers/usb/misc/onboard_usb_dev.c
> index 11508ed4df25..c60406240416 100644
> --- a/drivers/usb/misc/onboard_usb_dev.c
> +++ b/drivers/usb/misc/onboard_usb_dev.c
> @@ -706,7 +706,7 @@ static int __init onboard_dev_init(void)
>  {
>  	int ret;
>  
> -	ret = usb_register_device_driver(&onboard_dev_usbdev_driver,
> THIS_MODULE);
> +	ret =
> usb_register_device_driver(&onboard_dev_usbdev_driver);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/usb/usbip/stub_main.c
> b/drivers/usb/usbip/stub_main.c
> index 79110a69d697..01452f7bdabb 100644
> --- a/drivers/usb/usbip/stub_main.c
> +++ b/drivers/usb/usbip/stub_main.c
> @@ -371,7 +371,7 @@ static int __init usbip_host_init(void)
>  		return -ENOMEM;
>  	}
>  
> -	ret = usb_register_device_driver(&stub_driver, THIS_MODULE);
> +	ret = usb_register_device_driver(&stub_driver);
>  	if (ret) {
>  		pr_err("usb_register failed %d\n", ret);
>  		goto err_usb_register;

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

* Re: [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers
  2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
                   ` (4 preceding siblings ...)
  2026-07-23 23:07 ` [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Bird, Tim
@ 2026-07-27 12:21 ` Bastien Nocera
  5 siblings, 0 replies; 9+ messages in thread
From: Bastien Nocera @ 2026-07-27 12:21 UTC (permalink / raw)
  To: Shashank Balaji, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Greg Kroah-Hartman,
	Matthias Kaehlcke, Valentina Manea, Shuah Khan, Hongren Zheng,
	Heikki Krogerus
  Cc: linux-usb, netdev, linux-kernel, Daniel Palmer, Rahul Bukte,
	Tim Bird, linux-embedded

On Wed, 2026-07-22 at 12:31 +0900, Shashank Balaji wrote:
> This is in continuation to [1].
> 
> struct device_driver's mod_name is not set by a number of bus' driver
> registration
> functions. Without that, built-in drivers don't have the module
> symlink in sysfs.
> We want this to go from unbound driver name -> module name -> kernel
> config name.
> This is useful on embedded platforms to minimize kernel config,
> reduce kernel size,
> and reduce boot time.
> 
> This patchset adds mod_name to usb-related drivers.
> 
> [1]
> https://lore.kernel.org/all/20260518-acpi_mod_name-v5-0-705ccc430885@sony.com/
> 
> Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>

Reviewed-by: Bastien Nocera <hadess@hadess.net>

> ---
> Shashank Balaji (4):
>       usb: core: pass THIS_MODULE implicitly through a macro
>       usb: core: set mod_name in driver registration
>       usb: typec: set mod_name in driver registration
>       usb: ulpi: set mod_name in driver registration
> 
>  include/linux/ulpi/driver.h             |  4 ++--
>  include/linux/usb.h                     |  6 ++++--
>  include/linux/usb/typec_altmode.h       |  4 ++--
>  drivers/net/usb/r8152.c                 |  2 +-
>  drivers/usb/common/ulpi.c               |  4 +++-
>  drivers/usb/core/driver.c               | 10 ++++++----
>  drivers/usb/core/usb.c                  |  2 +-
>  drivers/usb/misc/apple-mfi-fastcharge.c |  2 +-
>  drivers/usb/misc/onboard_usb_dev.c      |  2 +-
>  drivers/usb/typec/bus.c                 |  4 +++-
>  drivers/usb/usbip/stub_main.c           |  2 +-
>  11 files changed, 25 insertions(+), 17 deletions(-)
> ---
> base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df
> change-id: 20260722-mod_name_usb-e3baf58e1e1e
> 
> Best regards,
> --  
> Shashank Balaji <shashank.mahadasyam@sony.com>

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

end of thread, other threads:[~2026-07-27 12:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  3:31 [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-07-22  3:31 ` [PATCH 1/4] usb: core: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-07-27 12:19   ` Bastien Nocera
2026-07-22  3:31 ` [PATCH 2/4] usb: core: set mod_name in driver registration Shashank Balaji
2026-07-22  3:31 ` [PATCH 3/4] usb: typec: " Shashank Balaji
2026-07-27 11:39   ` Heikki Krogerus
2026-07-22  3:31 ` [PATCH 4/4] usb: ulpi: " Shashank Balaji
2026-07-23 23:07 ` [PATCH 0/4] usb: enable sysfs module symlink for more built-in drivers Bird, Tim
2026-07-27 12:21 ` Bastien Nocera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox