Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3b50dc2 authored by Wolfram Sang's avatar Wolfram Sang Committed by Greg Kroah-Hartman
Browse files

core: platform: let platform_driver_probe 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_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: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 161d6981
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -580,9 +580,10 @@ void platform_driver_unregister(struct platform_driver *drv)
EXPORT_SYMBOL_GPL(platform_driver_unregister);
EXPORT_SYMBOL_GPL(platform_driver_unregister);


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


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


	/* temporary section violation during probe() */
	/* temporary section violation during probe() */
	drv->probe = probe;
	drv->probe = probe;
	retval = code = platform_driver_register(drv);
	retval = code = __platform_driver_register(drv, module);


	/*
	/*
	 * Fixup that section violation, being paranoid about code scanning
	 * Fixup that section violation, being paranoid about code scanning
@@ -633,7 +634,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
		platform_driver_unregister(drv);
		platform_driver_unregister(drv);
	return retval;
	return retval;
}
}
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
+4 −2
Original line number Original line Diff line number Diff line
@@ -197,8 +197,10 @@ extern void platform_driver_unregister(struct platform_driver *);
/* non-hotpluggable platform devices may use this so that probe() and
/* non-hotpluggable platform devices may use this so that probe() and
 * its support may live in __init sections, conserving runtime memory.
 * its support may live in __init sections, conserving runtime memory.
 */
 */
extern int platform_driver_probe(struct platform_driver *driver,
#define platform_driver_probe(drv, probe) \
		int (*probe)(struct platform_device *));
	__platform_driver_probe(drv, probe, THIS_MODULE)
extern int __platform_driver_probe(struct platform_driver *driver,
		int (*probe)(struct platform_device *), struct module *module);


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