From: David Lechner <david@lechnology.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: David Lechner <david@lechnology.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] i2c: Add special case for detecting LEGO devices
Date: Mon, 5 Sep 2016 15:40:13 -0500 [thread overview]
Message-ID: <1473108014-30787-3-git-send-email-david@lechnology.com> (raw)
In-Reply-To: <1473108014-30787-1-git-send-email-david@lechnology.com>
LEGO chose to ignore the I2C specification and has created devices with
I2C addresses of 0x01 and 0x02. i2c_check_7bit_addr_validity_strict()
disallows these addresses, so we need a special case to skip this for
LEGO sensors.
Furthermore, LEGO devices do not respond to i2c_default_probe(), so we
skip this as a special case as well.
Signed-off-by: David Lechner <david@lechnology.com>
---
drivers/i2c/i2c-core.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index da3a02e..28436d9 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2591,12 +2591,14 @@ static int i2c_detect_address(struct i2c_client *temp_client,
int addr = temp_client->addr;
int err;
- /* Make sure the address is valid */
- err = i2c_check_7bit_addr_validity_strict(addr);
- if (err) {
- dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
- addr);
- return err;
+ /* Make sure the address is valid - LEGO devices break the rules */
+ if (!(driver->class & I2C_CLASS_LEGO)) {
+ err = i2c_check_7bit_addr_validity_strict(addr);
+ if (err) {
+ dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
+ addr);
+ return err;
+ }
}
/* Skip if already in use (7 bit, no need to encode flags) */
@@ -2604,7 +2606,8 @@ static int i2c_detect_address(struct i2c_client *temp_client,
return 0;
/* Make sure there is something at this address */
- if (!i2c_default_probe(adapter, addr))
+ if (!(driver->class & I2C_CLASS_LEGO) &&
+ !i2c_default_probe(adapter, addr))
return 0;
/* Finally call the custom detection function */
--
2.7.4
next prev parent reply other threads:[~2016-09-05 20:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 20:40 [PATCH 0/3] LEGO MINDSTORMS I2C support David Lechner
2016-09-05 20:40 ` [PATCH 1/3] i2c: Add class for LEGO MINDSTORMS sensors David Lechner
2016-09-06 19:01 ` Uwe Kleine-König
2016-09-05 20:40 ` David Lechner [this message]
2016-09-05 20:40 ` [PATCH 3/3] i2c: expose adapter probe and remove probed functions David Lechner
2016-09-16 21:03 ` Wolfram Sang
2016-09-16 21:09 ` David Lechner
2016-09-15 20:00 ` [PATCH 0/3] LEGO MINDSTORMS I2C support Wolfram Sang
2016-09-16 20:05 ` David Lechner
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=1473108014-30787-3-git-send-email-david@lechnology.com \
--to=david@lechnology.com \
--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).