linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: use a macro instead of platform_driver_register
@ 2013-05-25  4:40 Libo Chen
  2013-05-25 12:22 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Libo Chen @ 2013-05-25  4:40 UTC (permalink / raw)
  To: linux-arm-kernel


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>
---
 drivers/base/platform.c         |    8 +++++---
 include/linux/platform_device.h |    8 +++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9eda842..ed75cf6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -523,11 +523,13 @@ static void platform_drv_shutdown(struct device *_dev)
 }

 /**
- * platform_driver_register - register a driver for platform-level devices
+ * __platform_driver_register - register a driver for platform-level devices
  * @drv: platform driver structure
  */
-int platform_driver_register(struct platform_driver *drv)
+int __platform_driver_register(struct platform_driver *drv,
+				struct module *owner)
 {
+	drv->driver.owner = owner;
 	drv->driver.bus = &platform_bus_type;
 	if (drv->probe)
 		drv->driver.probe = platform_drv_probe;
@@ -538,7 +540,7 @@ int platform_driver_register(struct platform_driver *drv)

 	return driver_register(&drv->driver);
 }
-EXPORT_SYMBOL_GPL(platform_driver_register);
+EXPORT_SYMBOL_GPL(__platform_driver_register);

 /**
  * 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 9abf1db..cd46ee5 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -180,7 +180,13 @@ struct platform_driver {
 	const struct platform_device_id *id_table;
 };

-extern int platform_driver_register(struct platform_driver *);
+/*
+ * use a macro to avoid include chaining to get THIS_MODULE
+ */
+#define platform_driver_register(drv) \
+	__platform_driver_register(drv, THIS_MODULE)
+extern int __platform_driver_register(struct platform_driver *,
+					struct module *);
 extern void platform_driver_unregister(struct platform_driver *);

 /* non-hotpluggable platform devices may use this so that probe() and
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] module: use a macro instead of platform_driver_register
  2013-05-25  4:40 [PATCH] module: use a macro instead of platform_driver_register Libo Chen
@ 2013-05-25 12:22 ` Greg KH
  2013-05-28  7:42   ` Libo Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2013-05-25 12:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, May 25, 2013 at 12:40:50PM +0800, Libo Chen wrote:
> 
> 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>

Nice job, that's the better way to fix this, I'll queue it up for 3.11.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] module: use a macro instead of platform_driver_register
  2013-05-25 12:22 ` Greg KH
@ 2013-05-28  7:42   ` Libo Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Libo Chen @ 2013-05-28  7:42 UTC (permalink / raw)
  To: linux-arm-kernel

On 2013/5/25 20:22, Greg KH wrote:
> On Sat, May 25, 2013 at 12:40:50PM +0800, Libo Chen wrote:
>>
>> 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>
> 
> Nice job, that's the better way to fix this, I'll queue it up for 3.11.
> 

Thank Gu, Thomas, David and yours suggestions!

Regards

Libo

> thanks,
> 
> greg k-h
> 
> .
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-28  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-25  4:40 [PATCH] module: use a macro instead of platform_driver_register Libo Chen
2013-05-25 12:22 ` Greg KH
2013-05-28  7:42   ` Libo Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).