From patchwork Wed Sep 9 18:33:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 53330 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 7F05222B05 for ; Wed, 9 Sep 2015 18:35:59 +0000 (UTC) Received: by lagj9 with SMTP id j9sf7406273lag.0 for ; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=uDi6+bLe0O4EJehbh6uaRw2ClJSzvaSC+i5q069EqI8=; b=Jhg9aDolhUNLevZ+vKRQM5aeDhyFVR+X7VF79RLysOfQidJB8nATt02/tS4ItvjzDb XZbyZwF7DaryoFFLpLMVAD4g/M1+1Sd3Q+pBTjQMitdyS0CCEzdvAtbeTHtCC8iwbLtr OFXcD6FSvmMjAPoQlvKAGpuwciIIJHp+UGhEH2L8TZayg4m5Kw2hRE/h5dOHDI1GV4OW vGqRcmmpEgUTAhtcRWGYCGL2Q2ILUO4Xsf5iCr9p+wvCGkcFrQAdjsYCAF8VssvjP2IF s8d8/KTdZlmvngei1s8Z1Jpn9N9q+AIm30kzJpmTJnGzH87kwUTsJIXc9Re32Jcbp0aq lqkA== X-Gm-Message-State: ALoCoQnNjt5OOx5tzCtA2+lbrTqbX//xjZMlLWyjmqB03bcjQ1463k9Q+Ky0Ecknk4IWCxi4I+4U X-Received: by 10.180.96.226 with SMTP id dv2mr8610817wib.2.1441823758412; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.200 with SMTP id o8ls94963laf.3.gmail; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) X-Received: by 10.152.170.130 with SMTP id am2mr31032876lac.54.1441823758209; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com. [2a00:1450:4010:c04::22c]) by mx.google.com with ESMTPS id b8si7477737lah.113.2015.09.09.11.35.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 11:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) client-ip=2a00:1450:4010:c04::22c; Received: by lbcjc2 with SMTP id jc2so10800068lbc.0 for ; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr30596956lac.73.1441823758078; Wed, 09 Sep 2015 11:35:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp492708lbq; Wed, 9 Sep 2015 11:35:57 -0700 (PDT) X-Received: by 10.50.78.161 with SMTP id c1mr54624508igx.35.1441823756942; Wed, 09 Sep 2015 11:35:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id or4si10104611pdb.35.2015.09.09.11.35.56; Wed, 09 Sep 2015 11:35:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754492AbbIISfy (ORCPT + 28 others); Wed, 9 Sep 2015 14:35:54 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:36837 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754857AbbIISea (ORCPT ); Wed, 9 Sep 2015 14:34:30 -0400 Received: by wicgb1 with SMTP id gb1so127202688wic.1; Wed, 09 Sep 2015 11:34:29 -0700 (PDT) X-Received: by 10.194.77.4 with SMTP id o4mr38375954wjw.4.1441823669468; Wed, 09 Sep 2015 11:34:29 -0700 (PDT) Received: from localhost.localdomain (cpc17-aztw24-2-0-cust759.aztw.cable.virginm.net. [92.237.134.248]) by smtp.gmail.com with ESMTPSA id u1sm5155141wiz.22.2015.09.09.11.34.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 11:34:28 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Samuel Ortiz , Lee Jones Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, grant.likely@linaro.org Subject: [PATCH v4 4/8] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Wed, 9 Sep 2015 19:33:43 +0100 Message-Id: <1441823627-6227-5-git-send-email-kieranbingham@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441823627-6227-1-git-send-email-kieranbingham@gmail.com> References: <1441823627-6227-1-git-send-email-kieranbingham@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: kieranbingham@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Lee Jones Currently the I2C framework insists on devices supplying an I2C ID table. Many of the devices which do so unnecessarily adding quite a few wasted lines to kernel code. This patch allows drivers a means to 'not' supply the aforementioned table and match on DT match tables instead. Acked-by: Grant Likely Signed-off-by: Lee Jones --- drivers/i2c/i2c-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 94ca76e..2ebc64d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -468,7 +468,7 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) /* Attempt an OF style match */ - if (of_driver_match_device(dev, drv)) + if (i2c_of_match_device(drv->of_match_table, client)) return 1; /* Then ACPI style match */ @@ -657,7 +657,15 @@ static int i2c_device_probe(struct device *dev) } driver = to_i2c_driver(dev->driver); - if (!driver->probe || !driver->id_table) + if (!driver->probe) + return -EINVAL; + + /* + * An I2C ID table is not mandatory, if and only if, a suitable Device + * Tree match table entry is supplied for the probing device. + */ + if (!driver->id_table && + !i2c_of_match_device(dev->driver->of_match_table, client)) return -ENODEV; if (!device_can_wakeup(&client->dev))