linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 3/5] driver core: platform: apply driver_register_sync for platform_driver_probe
Date: Sun,  9 Sep 2012 07:25:18 +0800	[thread overview]
Message-ID: <1347146720-28596-4-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1347146720-28596-1-git-send-email-ming.lei@canonical.com>

platform_driver_probe supposes that the driver's probe is always called
inside platform_driver_probe, so apply driver_register_sync for it.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/base/platform.c         |   11 +++++++----
 include/linux/platform_device.h |   12 +++++++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 42ca90c..f1d3507 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -500,7 +500,7 @@ static void platform_drv_shutdown(struct device *_dev)
  * platform_driver_register - register a driver for platform-level devices
  * @drv: platform driver structure
  */
-int platform_driver_register(struct platform_driver *drv)
+int __platform_driver_register(struct platform_driver *drv, int sync)
 {
 	drv->driver.bus = &platform_bus_type;
 	if (drv->probe)
@@ -510,9 +510,12 @@ int platform_driver_register(struct platform_driver *drv)
 	if (drv->shutdown)
 		drv->driver.shutdown = platform_drv_shutdown;
 
-	return driver_register(&drv->driver);
+	if (sync)
+		return driver_register_sync(&drv->driver);
+	else
+		return driver_register(&drv->driver);
 }
-EXPORT_SYMBOL_GPL(platform_driver_register);
+EXPORT_SYMBOL_GPL(__platform_driver_register);
 
 /**
  * platform_driver_unregister - unregister a driver for platform-level devices
@@ -551,7 +554,7 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
 
 	/* temporary section violation during probe() */
 	drv->probe = probe;
-	retval = code = platform_driver_register(drv);
+	retval = code = platform_driver_register_sync(drv);
 
 	/*
 	 * Fixup that section violation, being paranoid about code scanning
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 5711e95..f791a59 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -175,9 +175,19 @@ struct platform_driver {
 	const struct platform_device_id *id_table;
 };
 
-extern int platform_driver_register(struct platform_driver *);
+extern int __platform_driver_register(struct platform_driver *, int sync);
 extern void platform_driver_unregister(struct platform_driver *);
 
+static inline int platform_driver_register(struct platform_driver *drv)
+{
+	return __platform_driver_register(drv, 0);
+}
+
+static inline int platform_driver_register_sync(struct platform_driver *drv)
+{
+	return __platform_driver_register(drv, 1);
+}
+
 /* non-hotpluggable platform devices may use this so that probe() and
  * its support may live in __init sections, conserving runtime memory.
  */
-- 
1.7.9.5


  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 ` Ming Lei [this message]
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 ` [RFC PATCH 5/5] driver core: implement asynchorous probe() inside driver_register Ming Lei
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-4-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).