Thread (6 messages) 6 messages, 2 authors, 2d ago
WARM2d

[PATCH 4/4] usb: ulpi: set mod_name in driver registration

From: Shashank Balaji <hidden>
Date: 2026-07-22 03:31:51
Also in: linux-usb, lkml
Subsystem: the rest, ulpi bus, usb subsystem · Maintainers: Linus Torvalds, Heikki Krogerus, Greg Kroah-Hartman

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 <redacted>
Signed-off-by: Rahul Bukte <redacted>
Signed-off-by: Shashank Balaji <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help