提交 291f653a 编写于 作者: W Wolfram Sang 提交者: Greg Kroah-Hartman

core: platform: let platform_create_bundle initialize module owner

Since commit 9447057e ("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: NRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c3b50dc2
...@@ -637,24 +637,25 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv, ...@@ -637,24 +637,25 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv,
EXPORT_SYMBOL_GPL(__platform_driver_probe); EXPORT_SYMBOL_GPL(__platform_driver_probe);
/** /**
* platform_create_bundle - register driver and create corresponding device * __platform_create_bundle - register driver and create corresponding device
* @driver: platform driver structure * @driver: platform driver structure
* @probe: the driver probe routine, probably from an __init section * @probe: the driver probe routine, probably from an __init section
* @res: set of resources that needs to be allocated for the device * @res: set of resources that needs to be allocated for the device
* @n_res: number of resources * @n_res: number of resources
* @data: platform specific data for this platform device * @data: platform specific data for this platform device
* @size: size of platform specific data * @size: size of platform specific data
* @module: module which will be the owner of the driver
* *
* Use this in legacy-style modules that probe hardware directly and * Use this in legacy-style modules that probe hardware directly and
* register a single platform device and corresponding platform driver. * register a single platform device and corresponding platform driver.
* *
* Returns &struct platform_device pointer on success, or ERR_PTR() on error. * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
*/ */
struct platform_device * __init_or_module platform_create_bundle( struct platform_device * __init_or_module __platform_create_bundle(
struct platform_driver *driver, struct platform_driver *driver,
int (*probe)(struct platform_device *), int (*probe)(struct platform_device *),
struct resource *res, unsigned int n_res, struct resource *res, unsigned int n_res,
const void *data, size_t size) const void *data, size_t size, struct module *module)
{ {
struct platform_device *pdev; struct platform_device *pdev;
int error; int error;
...@@ -677,7 +678,7 @@ struct platform_device * __init_or_module platform_create_bundle( ...@@ -677,7 +678,7 @@ struct platform_device * __init_or_module platform_create_bundle(
if (error) if (error)
goto err_pdev_put; goto err_pdev_put;
error = platform_driver_probe(driver, probe); error = __platform_driver_probe(driver, probe, module);
if (error) if (error)
goto err_pdev_del; goto err_pdev_del;
...@@ -690,7 +691,7 @@ struct platform_device * __init_or_module platform_create_bundle( ...@@ -690,7 +691,7 @@ struct platform_device * __init_or_module platform_create_bundle(
err_out: err_out:
return ERR_PTR(error); return ERR_PTR(error);
} }
EXPORT_SYMBOL_GPL(platform_create_bundle); EXPORT_SYMBOL_GPL(__platform_create_bundle);
/* modalias support enables more hands-off userspace setup: /* modalias support enables more hands-off userspace setup:
* (a) environment variable lets new-style hotplug events work once system is * (a) environment variable lets new-style hotplug events work once system is
......
...@@ -240,10 +240,12 @@ static void __exit __platform_driver##_exit(void) \ ...@@ -240,10 +240,12 @@ static void __exit __platform_driver##_exit(void) \
} \ } \
module_exit(__platform_driver##_exit); module_exit(__platform_driver##_exit);
extern struct platform_device *platform_create_bundle( #define platform_create_bundle(driver, probe, res, n_res, data, size) \
__platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)
extern struct platform_device *__platform_create_bundle(
struct platform_driver *driver, int (*probe)(struct platform_device *), struct platform_driver *driver, int (*probe)(struct platform_device *),
struct resource *res, unsigned int n_res, struct resource *res, unsigned int n_res,
const void *data, size_t size); const void *data, size_t size, struct module *module);
/* early platform driver interface */ /* early platform driver interface */
struct early_platform_driver { struct early_platform_driver {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册