From: Ming Lei <ming.lei@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Takashi Iwai <tiwai@suse.de>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linux-kernel@vger.kernel.org, Ming Lei <ming.lei@canonical.com>
Subject: [RFC PATCH 5/5] driver core: implement asynchorous probe() inside driver_register
Date: Sun, 9 Sep 2012 07:25:20 +0800 [thread overview]
Message-ID: <1347146720-28596-6-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1347146720-28596-1-git-send-email-ming.lei@canonical.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
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
next prev parent reply other threads:[~2012-09-08 23:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-08 23:25 [RFC PATCH 0/5] driver core: driver probe asynchronously Ming Lei
2012-09-08 23:25 ` [RFC PATCH 1/5] driver core: driver probe at the last minute in driver_register Ming Lei
2012-09-08 23:25 ` [RFC PATCH 2/5] driver core: introduce driver_register_sync helper Ming Lei
2012-09-08 23:25 ` [RFC PATCH 3/5] driver core: platform: apply driver_register_sync for platform_driver_probe Ming Lei
2012-09-08 23:25 ` [RFC PATCH 4/5] driver core: remove __must_check on declaration of driver_attach Ming Lei
2012-09-08 23:25 ` Ming Lei [this message]
2012-09-09 2:57 ` [RFC PATCH 0/5] driver core: driver probe asynchronously Greg Kroah-Hartman
2012-09-09 7:47 ` Benjamin Herrenschmidt
2012-09-09 7:56 ` Takashi Iwai
2012-09-09 10:44 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347146720-28596-6-git-send-email-ming.lei@canonical.com \
--to=ming.lei@canonical.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=benh@kernel.crashing.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).