Commit 3f9120b0 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

driver core: prevent deferred probe with platform_driver_probe

Prevent drivers relying on platform_driver_probe from requesting
deferred probing in order to avoid further futile probe attempts (either
the driver has been unregistered or its probe function has been set to
platform_drv_probe_fail when probing is retried).

Note that several platform drivers currently return subsystem errors
from probe and that these can include -EPROBE_DEFER (e.g. if a gpio
request fails).

Add a warning to platform_drv_probe that can be used to catch drivers
that inadvertently request probe deferral while using
platform_driver_probe.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eee03164
...@@ -488,6 +488,11 @@ static int platform_drv_probe(struct device *_dev) ...@@ -488,6 +488,11 @@ static int platform_drv_probe(struct device *_dev)
if (ret && ACPI_HANDLE(_dev)) if (ret && ACPI_HANDLE(_dev))
acpi_dev_pm_detach(_dev, true); acpi_dev_pm_detach(_dev, true);
if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
dev_warn(_dev, "probe deferral not supported\n");
ret = -ENXIO;
}
return ret; return ret;
} }
...@@ -553,8 +558,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); ...@@ -553,8 +558,7 @@ 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
* must not return -EPROBE_DEFER.
* *
* 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
...@@ -565,8 +569,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); ...@@ -565,8 +569,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister);
* into system-on-chip processors, where the controller devices have been * into system-on-chip processors, where the controller devices have been
* configured as part of board setup. * configured as part of board setup.
* *
* This is incompatible with deferred probing so probe() must not * Note that this is incompatible with deferred probing.
* return -EPROBE_DEFER.
* *
* 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.
...@@ -576,6 +579,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv, ...@@ -576,6 +579,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
{ {
int retval, code; int retval, code;
/*
* Prevent driver from requesting probe deferral to avoid further
* futile probe attempts.
*/
drv->prevent_deferred_probe = true;
/* make sure driver won't have bind/unbind attributes */ /* make sure driver won't have bind/unbind attributes */
drv->driver.suppress_bind_attrs = true; drv->driver.suppress_bind_attrs = true;
......
...@@ -178,6 +178,7 @@ struct platform_driver { ...@@ -178,6 +178,7 @@ struct platform_driver {
int (*resume)(struct platform_device *); int (*resume)(struct platform_device *);
struct device_driver driver; struct device_driver driver;
const struct platform_device_id *id_table; const struct platform_device_id *id_table;
bool prevent_deferred_probe;
}; };
#define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment