[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1347146720-28596-3-git-send-email-ming.lei@canonical.com>
Date: Sun, 9 Sep 2012 07:25:17 +0800
From: Ming Lei <ming.lei@...onical.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Takashi Iwai <tiwai@...e.de>,
Alan Cox <alan@...rguk.ukuu.org.uk>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
linux-kernel@...r.kernel.org, Ming Lei <ming.lei@...onical.com>
Subject: [RFC PATCH 2/5] driver core: introduce driver_register_sync helper
This patch introduces driver_register_sync helper to make
driver's probe called synchronously inside driver_register
path.
platform_driver_probe should use driver_register_sync.
Signed-off-by: Ming Lei <ming.lei@...onical.com>
---
drivers/base/driver.c | 5 +++--
include/linux/device.h | 13 ++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 27f4c85..9365076 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -156,12 +156,13 @@ static void driver_remove_groups(struct device_driver *drv,
/**
* driver_register - register driver with bus
* @drv: driver to register
+ * @sync: if the .probe() is called synchronously
*
* We pass off most of the work to the bus_add_driver() call,
* since most of the things we have to do deal with the bus
* structures.
*/
-int driver_register(struct device_driver *drv)
+int __driver_register(struct device_driver *drv, int sync)
{
int ret;
struct device_driver *other;
@@ -197,7 +198,7 @@ int driver_register(struct device_driver *drv)
return ret;
}
-EXPORT_SYMBOL_GPL(driver_register);
+EXPORT_SYMBOL_GPL(__driver_register);
/**
* driver_unregister - remove driver from system.
diff --git a/include/linux/device.h b/include/linux/device.h
index dd0d684..7222c0b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -237,9 +237,20 @@ struct device_driver {
};
-extern int __must_check driver_register(struct device_driver *drv);
+extern int __must_check __driver_register(struct device_driver *drv,
+ int sync);
extern void driver_unregister(struct device_driver *drv);
+static inline int __must_check driver_register(struct device_driver *drv)
+{
+ return __driver_register(drv, 0);
+}
+
+static inline int __must_check driver_register_sync(struct device_driver *drv)
+{
+ return __driver_register(drv, 1);
+}
+
extern struct device_driver *driver_find(const char *name,
struct bus_type *bus);
extern int driver_probe_done(void);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists