linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: linux-i2c@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, Wolfram Sang <wsa@the-dreams.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] i2c: Export i2c_init_adapter() for use by drivers in early initialisation
Date: Thu,  9 Jun 2016 09:53:55 +0100	[thread overview]
Message-ID: <1465462435-5240-3-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1465462435-5240-1-git-send-email-chris@chris-wilson.co.uk>

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@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: dri-devel@lists.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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2016-06-09  8:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09  8:53 [PATCH 1/3] i2c: Split adapter initialisation from registers Chris Wilson
2016-06-09  8:53 ` [PATCH 2/3] i2c: Mark adapter as initialised Chris Wilson
2016-06-09  8:53 ` Chris Wilson [this message]
2016-08-23 21:33   ` [PATCH 3/3] i2c: Export i2c_init_adapter() for use by drivers in early initialisation Wolfram Sang

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=1465462435-5240-3-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /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).