From patchwork Fri Sep 11 11:56:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 53442 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 49DF0215BF for ; Fri, 11 Sep 2015 11:58:20 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf17697348wic.2 for ; Fri, 11 Sep 2015 04:58:19 -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=/pU7LPhvFJ5UNiWufZqtzcA1HV2Jc4rDyUqe2dniacc=; b=iO9hQsy3qtzekabygHdrh6jitRxGkiau64KyLwQxu2cjk/erveLYX5uBxXmLccjjwp BPoezgZeJUzZgptGtjwWzBJF1psETEvVIvwUEAHvJE0JF/oDpw95xwnux1DTy8lfTfnv ITC56ET6UCS0EAzdU0yLHGACMDPMzwtvbkr5lu3UWXv59YeacC4xvom006I4TTkXzkpt UKtQ/013RlRnq6KA/XnTaHAqp2zE1/75Mwt3/rSngqVgz176gEAoHJnt7VIc7FUjFlDC spBy6b2+f0zsSmHT750xqYmTSMnMOQgfAm7P7xgbwg6JP4nqc1N2HatzG/5TXxVBl/RW pA9A== X-Gm-Message-State: ALoCoQkJ7hZ6ol9sAJHBUaqHW6xHPsGMyw5v0EhKTls76qQsTtUT3TycedVXQjVcBzqKG8KPhZdT X-Received: by 10.180.188.211 with SMTP id gc19mr2309539wic.6.1441972699552; Fri, 11 Sep 2015 04:58:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.169 with SMTP id f9ls337496lam.93.gmail; Fri, 11 Sep 2015 04:58:19 -0700 (PDT) X-Received: by 10.112.132.1 with SMTP id oq1mr882634lbb.108.1441972699377; Fri, 11 Sep 2015 04:58:19 -0700 (PDT) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com. [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id zk1si16547lbb.30.2015.09.11.04.58.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 04:58:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by lahg1 with SMTP id g1so16220932lah.1 for ; Fri, 11 Sep 2015 04:58:19 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr17021277lbb.112.1441972699277; Fri, 11 Sep 2015 04:58:19 -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 w3csp1541905lbq; Fri, 11 Sep 2015 04:58:18 -0700 (PDT) X-Received: by 10.50.13.72 with SMTP id f8mr2961172igc.50.1441972696403; Fri, 11 Sep 2015 04:58:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y66si118930ioi.149.2015.09.11.04.58.15; Fri, 11 Sep 2015 04:58:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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 S1752808AbbIKL5z (ORCPT + 1 other); Fri, 11 Sep 2015 07:57:55 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:36612 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbbIKL5w (ORCPT ); Fri, 11 Sep 2015 07:57:52 -0400 Received: by wicgb1 with SMTP id gb1so59621508wic.1; Fri, 11 Sep 2015 04:57:50 -0700 (PDT) X-Received: by 10.194.95.103 with SMTP id dj7mr80989943wjb.118.1441972670418; Fri, 11 Sep 2015 04:57:50 -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 wj4sm25354wjb.10.2015.09.11.04.57.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 04:57:49 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Samuel Ortiz , Lee Jones Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, grant.likely@linaro.org, javier@osg.samsung.com, Kieran Bingham Subject: [RESEND PATCH v4 4/8] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Fri, 11 Sep 2015 12:56:00 +0100 Message-Id: <1441972564-9621-5-git-send-email-kieranbingham@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> References: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-i2c@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:c03::229 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 Signed-off-by: Kieran Bingham --- 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))