aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibo Chen <clbchenlibo.chen@huawei.com>2013-05-25 00:40:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-03 16:59:03 -0400
commit9447057eaff871dd7c63c808de761b8732407169 (patch)
tree6284b1e6653b14ceb6a9193002eec6303a509a66
parentf494513ff1b3f6bee2df329d8bbe864febf05a27 (diff)
platform_device: use a macro instead of platform_driver_register
I found a lot of mistakes using struct platform_driver without owner so I make a macro instead of the function platform_driver_register. It can set owner in it, then guys don`t care about module owner again. Signed-off-by: Libo Chen <libo.chen@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/platform.c8
-rw-r--r--include/linux/platform_device.h8
2 files changed, 12 insertions, 4 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9eda84246ffd..ed75cf6ef9c9 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -523,11 +523,13 @@ static void platform_drv_shutdown(struct device *_dev)
523} 523}
524 524
525/** 525/**
526 * platform_driver_register - register a driver for platform-level devices 526 * __platform_driver_register - register a driver for platform-level devices
527 * @drv: platform driver structure 527 * @drv: platform driver structure
528 */ 528 */
529int platform_driver_register(struct platform_driver *drv) 529int __platform_driver_register(struct platform_driver *drv,
530 struct module *owner)
530{ 531{
532 drv->driver.owner = owner;
531 drv->driver.bus = &platform_bus_type; 533 drv->driver.bus = &platform_bus_type;
532 if (drv->probe) 534 if (drv->probe)
533 drv->driver.probe = platform_drv_probe; 535 drv->driver.probe = platform_drv_probe;
@@ -538,7 +540,7 @@ int platform_driver_register(struct platform_driver *drv)
538 540
539 return driver_register(&drv->driver); 541 return driver_register(&drv->driver);
540} 542}
541EXPORT_SYMBOL_GPL(platform_driver_register); 543EXPORT_SYMBOL_GPL(__platform_driver_register);
542 544
543/** 545/**
544 * platform_driver_unregister - unregister a driver for platform-level devices 546 * platform_driver_unregister - unregister a driver for platform-level devices
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 9abf1db6aea6..cd46ee58b9dc 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -180,7 +180,13 @@ struct platform_driver {
180 const struct platform_device_id *id_table; 180 const struct platform_device_id *id_table;
181}; 181};
182 182
183extern int platform_driver_register(struct platform_driver *); 183/*
184 * use a macro to avoid include chaining to get THIS_MODULE
185 */
186#define platform_driver_register(drv) \
187 __platform_driver_register(drv, THIS_MODULE)
188extern int __platform_driver_register(struct platform_driver *,
189 struct module *);
184extern void platform_driver_unregister(struct platform_driver *); 190extern void platform_driver_unregister(struct platform_driver *);
185 191
186/* non-hotpluggable platform devices may use this so that probe() and 192/* non-hotpluggable platform devices may use this so that probe() and