From patchwork Mon Sep 5 20:40:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 666062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sSjj35glYz9s9N for ; Tue, 6 Sep 2016 07:36:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=lechnology.com header.i=@lechnology.com header.b=hDsy1s9N; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932183AbcIEVgX (ORCPT ); Mon, 5 Sep 2016 17:36:23 -0400 Received: from vern.gendns.com ([206.190.152.46]:35588 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932119AbcIEVgW (ORCPT ); Mon, 5 Sep 2016 17:36:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=q321HTAlT/3HWXYaxPyhC0W5mqWfi5zJx07kjybsf1k=; b=hDsy1s9ND/WdNdlEKxLEIb7D0 Aq6L6h5ADOE9QO5o5fq7UwKl5EeQJOSRY6UUbV2u3uO4KuULdtl+/iz3PBy7uoKuKktxrPndyVF9o D9wRU9pdiPWnZEiRQl5DGE+3ebAnEo5YEktY/NnaT7rla5TpDpgjzdaGwY/cHRR/z0fyYTH02PPms gjNjdQRYwmIx9r0lFV2ClGK9cRA+tjPF8+TeGWlBGG6cOLNuwtTIXGeEIfqMrdpejqN5AKFmHYS1R CEE2LQN7cO2itGEszwRC+cJCTw2EkHGOxY5r01GNNYA9MTcCAP18jmRgHNZBAl2ixX3fry4JFtU1e 0UX9tcnag==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:55950 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.87) (envelope-from ) id 1bh0hI-002Cuf-UA; Mon, 05 Sep 2016 16:40:53 -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-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 */