Skip to content

Commit c3b50dc

Browse files
Wolfram Sanggregkh
authored andcommitted
core: platform: let platform_driver_probe initialize module owner
Since commit 9447057 ("platform_device: use a macro instead of platform_driver_register"), platform_driver_register() always overwrites the .owner field of a platform_driver with THIS_MODULE. This breaks platform_driver_probe() which uses it from within the platform core instead of the module init. Fix it by using a similar #define construct to obtain THIS_MODULE and pass it on later. Reported-by: Russell King <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 161d698 commit c3b50dc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/base/platform.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,10 @@ void platform_driver_unregister(struct platform_driver *drv)
580580
EXPORT_SYMBOL_GPL(platform_driver_unregister);
581581

582582
/**
583-
* platform_driver_probe - register driver for non-hotpluggable device
583+
* __platform_driver_probe - register driver for non-hotpluggable device
584584
* @drv: platform driver structure
585585
* @probe: the driver probe routine, probably from an __init section
586+
* @module: module which will be the owner of the driver
586587
*
587588
* Use this instead of platform_driver_register() when you know the device
588589
* is not hotpluggable and has already been registered, and you want to
@@ -598,8 +599,8 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister);
598599
* Returns zero if the driver registered and bound to a device, else returns
599600
* a negative error code and with the driver not registered.
600601
*/
601-
int __init_or_module platform_driver_probe(struct platform_driver *drv,
602-
int (*probe)(struct platform_device *))
602+
int __init_or_module __platform_driver_probe(struct platform_driver *drv,
603+
int (*probe)(struct platform_device *), struct module *module)
603604
{
604605
int retval, code;
605606

@@ -614,7 +615,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
614615

615616
/* temporary section violation during probe() */
616617
drv->probe = probe;
617-
retval = code = platform_driver_register(drv);
618+
retval = code = __platform_driver_register(drv, module);
618619

619620
/*
620621
* Fixup that section violation, being paranoid about code scanning
@@ -633,7 +634,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
633634
platform_driver_unregister(drv);
634635
return retval;
635636
}
636-
EXPORT_SYMBOL_GPL(platform_driver_probe);
637+
EXPORT_SYMBOL_GPL(__platform_driver_probe);
637638

638639
/**
639640
* platform_create_bundle - register driver and create corresponding device

include/linux/platform_device.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ extern void platform_driver_unregister(struct platform_driver *);
197197
/* non-hotpluggable platform devices may use this so that probe() and
198198
* its support may live in __init sections, conserving runtime memory.
199199
*/
200-
extern int platform_driver_probe(struct platform_driver *driver,
201-
int (*probe)(struct platform_device *));
200+
#define platform_driver_probe(drv, probe) \
201+
__platform_driver_probe(drv, probe, THIS_MODULE)
202+
extern int __platform_driver_probe(struct platform_driver *driver,
203+
int (*probe)(struct platform_device *), struct module *module);
202204

203205
static inline void *platform_get_drvdata(const struct platform_device *pdev)
204206
{

0 commit comments

Comments
 (0)