diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-09-23 10:27:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 19:18:32 -0400 |
commit | 3f9120b0424f3e03c75518cb751f9e2bfa73c32a (patch) | |
tree | cee0874824b0b605086055c927671a15ce1bbd68 /drivers | |
parent | eee031649707db3c9920d9498f8d03819b74fc23 (diff) |
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: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/platform.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4f8bef3eb5a8..47051cd25113 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -488,6 +488,11 @@ static int platform_drv_probe(struct device *_dev) | |||
488 | if (ret && ACPI_HANDLE(_dev)) | 488 | if (ret && ACPI_HANDLE(_dev)) |
489 | acpi_dev_pm_detach(_dev, true); | 489 | acpi_dev_pm_detach(_dev, true); |
490 | 490 | ||
491 | if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { | ||
492 | dev_warn(_dev, "probe deferral not supported\n"); | ||
493 | ret = -ENXIO; | ||
494 | } | ||
495 | |||
491 | return ret; | 496 | return ret; |
492 | } | 497 | } |
493 | 498 | ||
@@ -553,8 +558,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); | |||
553 | /** | 558 | /** |
554 | * platform_driver_probe - register driver for non-hotpluggable device | 559 | * platform_driver_probe - register driver for non-hotpluggable device |
555 | * @drv: platform driver structure | 560 | * @drv: platform driver structure |
556 | * @probe: the driver probe routine, probably from an __init section, | 561 | * @probe: the driver probe routine, probably from an __init section |
557 | * must not return -EPROBE_DEFER. | ||
558 | * | 562 | * |
559 | * Use this instead of platform_driver_register() when you know the device | 563 | * Use this instead of platform_driver_register() when you know the device |
560 | * is not hotpluggable and has already been registered, and you want to | 564 | * is not hotpluggable and has already been registered, and you want to |
@@ -565,8 +569,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister); | |||
565 | * into system-on-chip processors, where the controller devices have been | 569 | * into system-on-chip processors, where the controller devices have been |
566 | * configured as part of board setup. | 570 | * configured as part of board setup. |
567 | * | 571 | * |
568 | * This is incompatible with deferred probing so probe() must not | 572 | * Note that this is incompatible with deferred probing. |
569 | * return -EPROBE_DEFER. | ||
570 | * | 573 | * |
571 | * Returns zero if the driver registered and bound to a device, else returns | 574 | * Returns zero if the driver registered and bound to a device, else returns |
572 | * a negative error code and with the driver not registered. | 575 | * 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 | { | 579 | { |
577 | int retval, code; | 580 | int retval, code; |
578 | 581 | ||
582 | /* | ||
583 | * Prevent driver from requesting probe deferral to avoid further | ||
584 | * futile probe attempts. | ||
585 | */ | ||
586 | drv->prevent_deferred_probe = true; | ||
587 | |||
579 | /* make sure driver won't have bind/unbind attributes */ | 588 | /* make sure driver won't have bind/unbind attributes */ |
580 | drv->driver.suppress_bind_attrs = true; | 589 | drv->driver.suppress_bind_attrs = true; |
581 | 590 | ||