Thread (6 messages) 6 messages, 2 authors, 1d ago
WARM1d

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

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

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/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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help