[RFC PATCH 5/5] driver core: implement asynchorous probe() inside driver_register

From: Ming Lei
Date: Sat Sep 08 2012 - 19:26:33 EST



Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxxxxx>
---
drivers/base/driver.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 9365076..67fb63c 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -15,6 +15,7 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/async.h>
#include "base.h"

static struct device *next_device(struct klist_iter *i)
@@ -153,6 +154,13 @@ static void driver_remove_groups(struct device_driver *drv,
sysfs_remove_group(&drv->p->kobj, groups[i]);
}

+static void async_driver_attach(void *data, async_cookie_t cookie)
+{
+ struct device_driver *drv = data;
+
+ driver_attach(drv);
+}
+
/**
* driver_register - register driver with bus
* @drv: driver to register
@@ -193,8 +201,12 @@ int __driver_register(struct device_driver *drv, int sync)
kobject_uevent(&drv->p->kobj, KOBJ_ADD);

/* driver probe at the last minute */
- if (drv->bus->p->drivers_autoprobe)
- ret = driver_attach(drv);
+ if (drv->bus->p->drivers_autoprobe) {
+ if (sync)
+ ret = driver_attach(drv);
+ else
+ async_schedule(async_driver_attach, drv);
+ }

return ret;
}
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/