Skip to content

Commit 291f653

Browse files
Wolfram Sanggregkh
authored andcommitted
core: platform: let platform_create_bundle 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_create_bundle() which uses it via platform_driver_probe() 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 c3b50dc commit 291f653

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
@@ -637,24 +637,25 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv,
637637
EXPORT_SYMBOL_GPL(__platform_driver_probe);
638638

639639
/**
640-
* platform_create_bundle - register driver and create corresponding device
640+
* __platform_create_bundle - register driver and create corresponding device
641641
* @driver: platform driver structure
642642
* @probe: the driver probe routine, probably from an __init section
643643
* @res: set of resources that needs to be allocated for the device
644644
* @n_res: number of resources
645645
* @data: platform specific data for this platform device
646646
* @size: size of platform specific data
647+
* @module: module which will be the owner of the driver
647648
*
648649
* Use this in legacy-style modules that probe hardware directly and
649650
* register a single platform device and corresponding platform driver.
650651
*
651652
* Returns &struct platform_device pointer on success, or ERR_PTR() on error.
652653
*/
653-
struct platform_device * __init_or_module platform_create_bundle(
654+
struct platform_device * __init_or_module __platform_create_bundle(
654655
struct platform_driver *driver,
655656
int (*probe)(struct platform_device *),
656657
struct resource *res, unsigned int n_res,
657-
const void *data, size_t size)
658+
const void *data, size_t size, struct module *module)
658659
{
659660
struct platform_device *pdev;
660661
int error;
@@ -677,7 +678,7 @@ struct platform_device * __init_or_module platform_create_bundle(
677678
if (error)
678679
goto err_pdev_put;
679680

680-
error = platform_driver_probe(driver, probe);
681+
error = __platform_driver_probe(driver, probe, module);
681682
if (error)
682683
goto err_pdev_del;
683684

@@ -690,7 +691,7 @@ struct platform_device * __init_or_module platform_create_bundle(
690691
err_out:
691692
return ERR_PTR(error);
692693
}
693-
EXPORT_SYMBOL_GPL(platform_create_bundle);
694+
EXPORT_SYMBOL_GPL(__platform_create_bundle);
694695

695696
/* modalias support enables more hands-off userspace setup:
696697
* (a) environment variable lets new-style hotplug events work once system is

include/linux/platform_device.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ static void __exit __platform_driver##_exit(void) \
240240
} \
241241
module_exit(__platform_driver##_exit);
242242

243-
extern struct platform_device *platform_create_bundle(
243+
#define platform_create_bundle(driver, probe, res, n_res, data, size) \
244+
__platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)
245+
extern struct platform_device *__platform_create_bundle(
244246
struct platform_driver *driver, int (*probe)(struct platform_device *),
245247
struct resource *res, unsigned int n_res,
246-
const void *data, size_t size);
248+
const void *data, size_t size, struct module *module);
247249

248250
/* early platform driver interface */
249251
struct early_platform_driver {

0 commit comments

Comments
 (0)