* [PATCH 3/4] i2c: Document reserved I2C addresses
@ 2010-04-09 14:54 Jean Delvare
0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2010-04-09 14:54 UTC (permalink / raw)
To: Linux I2C; +Cc: Hans Verkuil
Move strict I2C address validity check to a single function, and
document the reserved I2C addresses there.
Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
---
drivers/i2c/i2c-core.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
--- linux-2.6.34-rc3.orig/drivers/i2c/i2c-core.c 2010-04-08 13:52:42.000000000 +0200
+++ linux-2.6.34-rc3/drivers/i2c/i2c-core.c 2010-04-08 14:20:32.000000000 +0200
@@ -388,6 +388,27 @@ static int i2c_check_client_addr_validit
return 0;
}
+/* And this is a strict address validity check, used when probing. If a
+ * device uses a reserved address, then it shouldn't be probed. 7-bit
+ * addressing is assumed, 10-bit address devices are rare and should be
+ * explicitly enumerated. */
+static int i2c_check_addr_validity(unsigned short addr)
+{
+ /*
+ * Reserved addresses per I2C specification:
+ * 0x00 General call address / START byte
+ * 0x01 CBUS address
+ * 0x02 Reserved for different bus format
+ * 0x03 Reserved for future purposes
+ * 0x04-0x07 Hs-mode master code
+ * 0x78-0x7b 10-bit slave addressing
+ * 0x7c-0x7f Reserved for future purposes
+ */
+ if (addr < 0x08 || addr > 0x77)
+ return -EINVAL;
+ return 0;
+}
+
/**
* i2c_new_device - instantiate an i2c device
* @adap: the adapter managing the device
@@ -1335,10 +1356,11 @@ static int i2c_detect_address(struct i2c
int err;
/* Make sure the address is valid */
- if (addr < 0x03 || addr > 0x77) {
+ err = i2c_check_addr_validity(addr);
+ if (err) {
dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
addr);
- return -EINVAL;
+ return err;
}
/* Skip if already in use */
@@ -1452,7 +1474,7 @@ i2c_new_probed_device(struct i2c_adapter
for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
/* Check address validity */
- if (addr_list[i] < 0x03 || addr_list[i] > 0x77) {
+ if (i2c_check_addr_validity(addr_list[i]) < 0) {
dev_warn(&adap->dev, "Invalid 7-bit address "
"0x%02x\n", addr_list[i]);
continue;
--
Jean Delvare
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 0/4] Clean up address probing and validity checking code
@ 2010-05-31 11:22 Jean Delvare
[not found] ` <20100531132213.65f20b8f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Jean Delvare @ 2010-05-31 11:22 UTC (permalink / raw)
To: Linux I2C; +Cc: Matthieu Castet, Hans Verkuil
Here comes an update of the patchset I posted on April 9th, 2010. Now
applies cleanly on top of Linus' tree.
[PATCH 1/4] i2c: Share the I2C device presence detection code
[PATCH 2/4] i2c: Check for address validity on client registration
[PATCH 3/4] i2c: Document reserved I2C addresses
[PATCH 4/4] i2c: Rename i2c_check_addr to i2c_check_addr_busy
--
Jean Delvare
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-31 11:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-09 14:54 [PATCH 3/4] i2c: Document reserved I2C addresses Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2010-05-31 11:22 [PATCH 0/4] Clean up address probing and validity checking code Jean Delvare
[not found] ` <20100531132213.65f20b8f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-05-31 11:31 ` [PATCH 3/4] i2c: Document reserved I2C addresses Jean Delvare
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.