public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver core: prevent deferred probe with platform_driver_probe
@ 2013-09-23  8:48 Johan Hovold
  2013-09-23 11:01 ` Mark Brown
  0 siblings, 1 reply; 16+ messages in thread
From: Johan Hovold @ 2013-09-23  8:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Grant Likely, Mark Brown, linux-kernel, Johan Hovold

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).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/base/platform.c         | 17 +++++++++++++----
 include/linux/platform_device.h |  1 +
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4f8bef3..47051cd 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -488,6 +488,11 @@ static int platform_drv_probe(struct device *_dev)
 	if (ret && ACPI_HANDLE(_dev))
 		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;
 }
 
@@ -553,8 +558,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister);
 /**
  * platform_driver_probe - register driver for non-hotpluggable device
  * @drv: platform driver structure
- * @probe: the driver probe routine, probably from an __init section,
- *         must not return -EPROBE_DEFER.
+ * @probe: the driver probe routine, probably from an __init section
  *
  * Use this instead of platform_driver_register() when you know the device
  * is not hotpluggable and has already been registered, and you want to
@@ -565,8 +569,7 @@ EXPORT_SYMBOL_GPL(platform_driver_unregister);
  * into system-on-chip processors, where the controller devices have been
  * configured as part of board setup.
  *
- * This is incompatible with deferred probing so probe() must not
- * return -EPROBE_DEFER.
+ * Note that this is incompatible with deferred probing.
  *
  * Returns zero if the driver registered and bound to a device, else returns
  * 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,
 {
 	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 */
 	drv->driver.suppress_bind_attrs = true;
 
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index ce8e4ff..16f6654 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -178,6 +178,7 @@ struct platform_driver {
 	int (*resume)(struct platform_device *);
 	struct device_driver driver;
 	const struct platform_device_id *id_table;
+	bool prevent_deferred_probe;
 };
 
 #define to_platform_driver(drv)	(container_of((drv), struct platform_driver, \
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-09-23 16:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23  8:48 [PATCH] driver core: prevent deferred probe with platform_driver_probe Johan Hovold
2013-09-23 11:01 ` Mark Brown
2013-09-23 12:28   ` Johan Hovold
2013-09-23 13:40     ` Mark Brown
2013-09-23 14:27       ` [PATCH 0/7] " Johan Hovold
2013-09-23 14:27         ` [PATCH 1/7] " Johan Hovold
2013-09-23 14:27         ` [PATCH 2/7] mmc: mvsdio: fix deferred probe from __init Johan Hovold
2013-09-23 14:27         ` [PATCH 3/7] mtd: atmel_nand: " Johan Hovold
2013-09-23 14:27         ` [PATCH 4/7] pcmcia: at91_cf: " Johan Hovold
2013-09-23 16:53           ` Nicolas Ferre
2013-09-23 14:27         ` [PATCH 5/7] usb: gadget: pxa25x_udc: " Johan Hovold
2013-09-23 14:27         ` [PATCH 6/7] usb: phy: gpio-vbus: " Johan Hovold
2013-09-23 14:27         ` [PATCH 7/7] backlight: atmel-pwm-bl: " Johan Hovold
2013-09-23 14:50         ` [PATCH 0/7] driver core: prevent deferred probe with platform_driver_probe Sascha Hauer
2013-09-23 15:20           ` Johan Hovold
2013-09-23 15:24             ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox