Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1431338 > unrolled thread

[PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register()

Started byStephen Boyd <stephen.boyd@linaro.org>
First post2016-06-26 07:40 +0200
Last post2016-06-27 15:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register() Stephen Boyd <stephen.boyd@linaro.org> - 2016-06-26 07:40 +0200
    Re: [PATCH] usb: ulpi: Automatically set driver::owner with  ulpi_driver_register() Heikki Krogerus <heikki.krogerus@linux.intel.com> - 2016-06-27 15:10 +0200

#1431338 — [PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register()

FromStephen Boyd <stephen.boyd@linaro.org>
Date2016-06-26 07:40 +0200
Subject[PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register()
Message-ID<rOaXv-79i-1@gated-at.bofh.it>
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.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
 drivers/usb/common/ulpi.c   | 5 +++--
 include/linux/ulpi/driver.h | 6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index a6b2a150b176..4e15e2b9f4b4 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -148,16 +148,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
diff --git a/include/linux/ulpi/driver.h b/include/linux/ulpi/driver.h
index 388f6e08b9d4..80b36ca12e80 100644
--- a/include/linux/ulpi/driver.h
+++ b/include/linux/ulpi/driver.h
@@ -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) \
-- 
2.9.0.rc2.8.ga28705d

[toc] | [next] | [standalone]


#1432030 — Re: [PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register()

FromHeikki Krogerus <heikki.krogerus@linux.intel.com>
Date2016-06-27 15:10 +0200
SubjectRe: [PATCH] usb: ulpi: Automatically set driver::owner with ulpi_driver_register()
Message-ID<rOEsz-DU-79@gated-at.bofh.it>
In reply to#1431338
On Sat, Jun 25, 2016 at 10:38:21PM -0700, Stephen Boyd wrote:
> 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.
> 
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>

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


Thanks,

-- 
heikki

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web