driver-core: platform_driver_probe() must probe synchronously
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 30 Mar 2015 23:20:07 +0000 (16:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2015 07:25:25 +0000 (00:25 -0700)
Because platform_driver_probe() checks, after trying to register driver,
if there are any devices that driver successfully bound to, driver's
probe routine must be run synchronously.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/platform.c

index ebf034b97278592ab57cbd24ef0f53d3cfc56e0a..063f0ab152590dfeea4488d2686b8ff13b99a7bf 100644 (file)
@@ -613,6 +613,19 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv,
 {
        int retval, code;
 
+       if (drv->driver.probe_type == PROBE_PREFER_ASYNCHRONOUS) {
+               pr_err("%s: drivers registered with %s can not be probed asynchronously\n",
+                        drv->driver.name, __func__);
+               return -EINVAL;
+       }
+
+       /*
+        * We have to run our probes synchronously because we check if
+        * we find any devices to bind to and exit with error if there
+        * are any.
+        */
+       drv->driver.probe_type = PROBE_FORCE_SYNCHRONOUS;
+
        /*
         * Prevent driver from requesting probe deferral to avoid further
         * futile probe attempts.