From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] i2c: Create for_each_i2c_adapter()
Date: Wed, 11 Nov 2015 17:05:00 +0100 [thread overview]
Message-ID: <1447257901-8011-1-git-send-email-s.hauer@pengutronix.de> (raw)
This can be used by the i2c_probe command to iterate over i2c adapters.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/i2c/i2c.c | 8 ++++----
include/i2c/i2c.h | 4 ++++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 52aaea8..9ed96da 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -42,7 +42,7 @@ struct boardinfo {
};
static LIST_HEAD(board_list);
-static LIST_HEAD(adapter_list);
+LIST_HEAD(i2c_adapter_list);
/**
* i2c_transfer - execute a single or combined I2C message
@@ -529,7 +529,7 @@ struct i2c_adapter *i2c_get_adapter(int busnum)
{
struct i2c_adapter *adap;
- list_for_each_entry(adap, &adapter_list, list)
+ for_each_i2c_adapter(adap)
if (adap->nr == busnum)
return adap;
return NULL;
@@ -539,7 +539,7 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
{
struct i2c_adapter *adap;
- list_for_each_entry(adap, &adapter_list, list)
+ for_each_i2c_adapter(adap)
if (adap->dev.device_node == node)
return adap;
@@ -584,7 +584,7 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
if (ret)
return ret;
- list_add_tail(&adapter->list, &adapter_list);
+ list_add_tail(&adapter->list, &i2c_adapter_list);
/* populate children from any i2c device tables */
scan_boardinfo(adapter);
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 12e4827..3fab76d9 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -235,6 +235,10 @@ extern int i2c_add_numbered_adapter(struct i2c_adapter *adapter);
struct i2c_adapter *i2c_get_adapter(int busnum);
struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
+extern struct list_head i2c_adapter_list;
+#define for_each_i2c_adapter(adap) \
+ list_for_each_entry(adap, &i2c_adapter_list, list)
+
/* For devices that use several addresses, use i2c_new_dummy() to make
* client handles for the extra addresses.
*/
--
2.6.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2015-11-11 16:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 16:05 Sascha Hauer [this message]
2015-11-11 16:05 ` [PATCH 2/2] i2c_probe: Make command easier to work with Sascha Hauer
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=1447257901-8011-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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