From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935042AbcIEUmV (ORCPT ); Mon, 5 Sep 2016 16:42:21 -0400 Received: from vern.gendns.com ([206.190.152.46]:60397 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933698AbcIEUkz (ORCPT ); Mon, 5 Sep 2016 16:40:55 -0400 From: David Lechner To: Wolfram Sang Cc: David Lechner , 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 Message-Id: <1473108014-30787-3-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473108014-30787-1-git-send-email-david@lechnology.com> References: <1473108014-30787-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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