Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
3f9120b0 eee03164

+14 -4
+13 -4
drivers/base/platform.c
··· 488 488 if (ret && ACPI_HANDLE(_dev)) 489 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 496 return ret; 492 497 } 493 498 ··· 558 553 /** 559 554 * platform_driver_probe - register driver for non-hotpluggable device 560 555 * @drv: platform driver structure 561 - * @probe: the driver probe routine, probably from an __init section, 562 - * must not return -EPROBE_DEFER. 556 + * @probe: the driver probe routine, probably from an __init section 563 557 * 564 558 * Use this instead of platform_driver_register() when you know the device 565 559 * is not hotpluggable and has already been registered, and you want to ··· 569 565 * into system-on-chip processors, where the controller devices have been 570 566 * configured as part of board setup. 571 567 * 572 - * This is incompatible with deferred probing so probe() must not 573 - * return -EPROBE_DEFER. 568 + * Note that this is incompatible with deferred probing. 574 569 * 575 570 * Returns zero if the driver registered and bound to a device, else returns 576 571 * a negative error code and with the driver not registered. ··· 578 575 int (*probe)(struct platform_device *)) 579 576 { 580 577 int retval, code; 578 + 579 + /* 580 + * Prevent driver from requesting probe deferral to avoid further 581 + * futile probe attempts. 582 + */ 583 + drv->prevent_deferred_probe = true; 581 584 582 585 /* make sure driver won't have bind/unbind attributes */ 583 586 drv->driver.suppress_bind_attrs = true;
+1
include/linux/platform_device.h
··· 178 178 int (*resume)(struct platform_device *); 179 179 struct device_driver driver; 180 180 const struct platform_device_id *id_table; 181 + bool prevent_deferred_probe; 181 182 }; 182 183 183 184 #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \