From patchwork Wed May 4 15:14:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 67149 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp240420qge; Wed, 4 May 2016 08:16:04 -0700 (PDT) X-Received: by 10.66.52.112 with SMTP id s16mr12917414pao.35.1462374964601; Wed, 04 May 2016 08:16:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m76si5255985pfi.178.2016.05.04.08.16.04; Wed, 04 May 2016 08:16:04 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753469AbcEDPPP (ORCPT + 29 others); Wed, 4 May 2016 11:15:15 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33670 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701AbcEDPPM (ORCPT ); Wed, 4 May 2016 11:15:12 -0400 Received: by mail-wm0-f67.google.com with SMTP id r12so10883691wme.0; Wed, 04 May 2016 08:15:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eztDaYcNvOA/Jg5ep1bfQN5qdvTWoXOQge1dHl53Zdw=; b=mRj2xMG5lzEDKRdqOR43Gqi7VCu9FIAZeU+sCjhSnQAgyt3OqrRh+xGoaEOhSNrH04 sIRQk499cUFLnnLkDgi1BQREhU1rJKH8OLnSTgHiOlabaPcev4o+FlIrm+cGEM4F/vif E1V8Bxbq2xI7Eebvy3Fi9FYcDMi6WOv4CFlkcpH1UUnWCHFydpUFvdmOhpW1DdtCD63K YfAK2Wruz9CyB8FGfv/81qkAnyHNwBxHzGholfFYFli8LB17Ir0wbfkZQ8vjmZVqB9m3 DSiBl7Lm29WhL3Ovco5kXbH1cTASPbH8/gpeTeWHnxV0BwmiR5DT/1Y3Pa7C0aGh1p+l 2gsw== X-Gm-Message-State: AOPr4FUmPOkSGkTWFj7NwJuF/covKO9edHugsVgHUfEbEqfghE0hOqVfqq9kseZ4Mi6KbA== X-Received: by 10.28.128.143 with SMTP id b137mr30095651wmd.57.1462374910943; Wed, 04 May 2016 08:15:10 -0700 (PDT) Received: from CookieMonster.cookiemonster.local (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id u187sm5497613wmu.21.2016.05.04.08.15.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 08:15:09 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Lee Jones , javier@osg.samsung.com Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, grant.likely@linaro.org, sameo@linux.intel.com, Kieran Bingham Subject: [PATCHv5 4/8] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Wed, 4 May 2016 16:14:44 +0100 Message-Id: <1462374888-22888-5-git-send-email-kieran@bingham.xyz> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462374888-22888-1-git-send-email-kieran@bingham.xyz> References: <1462374888-22888-1-git-send-email-kieran@bingham.xyz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Kieran Bingham --- drivers/i2c/i2c-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.5.0 diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 88211009d282..dd5a19ee92af 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -511,7 +511,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 */ @@ -696,7 +696,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 (client->flags & I2C_CLIENT_WAKE) {