[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1465462435-5240-3-git-send-email-chris@chris-wilson.co.uk>
Date: Thu, 9 Jun 2016 09:53:55 +0100
From: Chris Wilson <chris@...is-wilson.co.uk>
To: linux-i2c@...r.kernel.org
Cc: Chris Wilson <chris@...is-wilson.co.uk>,
Ville Syrjälä
<ville.syrjala@...ux.intel.com>, Wolfram Sang <wsa@...-dreams.de>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org
Subject: [PATCH 3/3] i2c: Export i2c_init_adapter() for use by drivers in early initialisation
Some drivers require use of their i2c adapter long before they can add
the adapter to userspace (i.e. before they establish and expose their
objects in the sysfs kobject tree). Currently i2c_add_adapter()
registers the adapter with userspace, which causes a conflict in the
ordering of the driver's initialisation. Exporting i2c_init_adapter()
allows for the i2c adapter to be used early in the initialisation in
order to detect whether the device the adapter is attached to is even
present. The drivers still need to call i2c_add_adapter() (or
i2c_add_number_adapter()) as per normal to complete their registration.
Signed-off-by: Chris Wilson <chris@...is-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@...ux.intel.com>
Cc: Wolfram Sang <wsa@...-dreams.de>
Cc: linux-i2c@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: dri-devel@...ts.freedesktop.org
---
drivers/i2c/i2c-core.c | 16 +++++++++++++++-
include/linux/i2c.h | 1 +
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 91ff70d31ec8..0a3bdb048d65 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1511,7 +1511,20 @@ static int __process_new_adapter(struct device_driver *d, void *data)
return i2c_do_add_adapter(to_i2c_driver(d), data);
}
-static int i2c_init_adapter(struct i2c_adapter *adap)
+/**
+ * i2c_init_adapter - initialise i2c adapter for internal use
+ * @adapter: the adapter to initialise
+ * Context: any
+ *
+ * This routine is used to initialise an I2C adapter for internal use
+ * prior to registering it with third parties (including userspace). The
+ * driver should still call i2c_add_adapter() or i2c_add_numbered_adapter()
+ * when it is ready to expose the adapter to userspace.
+ *
+ * Returns: 0 on success, or a negative error value if the adapter is not
+ * fully specified for use.
+ */
+int i2c_init_adapter(struct i2c_adapter *adap)
{
/* Only initialise the adapter once. */
if (list_empty(&adap->userspace_clients))
@@ -1546,6 +1559,7 @@ static int i2c_init_adapter(struct i2c_adapter *adap)
return 0;
}
+EXPORT_SYMBOL(i2c_init_adapter);
static int i2c_register_adapter(struct i2c_adapter *adap)
{
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 96a25ae14494..72c76c5efba5 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -639,6 +639,7 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
/* administration...
*/
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+extern int i2c_init_adapter(struct i2c_adapter *);
extern int i2c_add_adapter(struct i2c_adapter *);
extern void i2c_del_adapter(struct i2c_adapter *);
extern int i2c_add_numbered_adapter(struct i2c_adapter *);
--
2.8.1
Powered by blists - more mailing lists