]> git.karo-electronics.de Git - linux-beck.git/commitdiff
usb: ulpi: Automatically set driver::owner with ulpi_driver_register()
authorStephen Boyd <stephen.boyd@linaro.org>
Sun, 26 Jun 2016 05:38:21 +0000 (22:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Aug 2016 14:06:49 +0000 (16:06 +0200)
Let's follow other driver registration functions and
automatically set the driver's owner member to THIS_MODULE when
ulpi_driver_register() is called. This allows ulpi driver writers
to forget about this boiler plate detail and avoids common bugs
in the process.

Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/common/ulpi.c
include/linux/ulpi/driver.h

index 01c0c0477a9e93d1c8e1150b80763f5ee6c90a02..e04a34e7a341d64af2262cf0dd436875794ac09a 100644 (file)
@@ -127,16 +127,17 @@ static struct device_type ulpi_dev_type = {
  *
  * Registers a driver with the ULPI bus.
  */
-int ulpi_register_driver(struct ulpi_driver *drv)
+int __ulpi_register_driver(struct ulpi_driver *drv, struct module *module)
 {
        if (!drv->probe)
                return -EINVAL;
 
+       drv->driver.owner = module;
        drv->driver.bus = &ulpi_bus;
 
        return driver_register(&drv->driver);
 }
-EXPORT_SYMBOL_GPL(ulpi_register_driver);
+EXPORT_SYMBOL_GPL(__ulpi_register_driver);
 
 /**
  * ulpi_unregister_driver - unregister a driver with the ULPI bus
index 388f6e08b9d451dfbb360b544e766834d57d3398..80b36ca12e80ec9aec1cff524475e7195526c1a1 100644 (file)
@@ -47,7 +47,11 @@ struct ulpi_driver {
 
 #define to_ulpi_driver(d) container_of(d, struct ulpi_driver, driver)
 
-int ulpi_register_driver(struct ulpi_driver *drv);
+/*
+ * 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);
 void ulpi_unregister_driver(struct ulpi_driver *drv);
 
 #define module_ulpi_driver(__ulpi_driver) \