From patchwork Fri May 30 12:26:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 31178 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7CF3F20E7C for ; Fri, 30 May 2014 12:26:54 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf6935112pbb.1 for ; Fri, 30 May 2014 05:26:53 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=B0pcmzzm1VwRY72uTs4+xNH9O7EfjxBLEuRLjM8p1Tw=; b=QXTqtA/Ew9wUhegPG+GK91SFKc2GPdeVJ3+kueJqGqh2hOWHVYtxs4L0ICxZnDrEQf 8QQP3KBMTs5646rUuDZfHBRINvXmxjbswaKKTJLQXNnzAJUlm1HAs9GoZNTGcdFg574n /hKEKUdCHZDvwlVcMHl7fwdxvS0zsmDQY8tBUCxlxDWbDYKsVFe7AHYCctaheow135Mz S5OyzRNXTuAYpVR7PyPtvWnv55MsyAl+7nqhzH7OLlvnrEKpZs5ZboUy4WXbwLiMd2Qx yH4HqgFl923SQo/mNu/2UrJgK6+K80AfwDzMSVJIlywsyBsl29wU+bYKhoxRl79CvN3j jegQ== X-Gm-Message-State: ALoCoQk9B4J9Vt7ylxB7RQz6tqfU4Qkby8lTszaXEUKVu+3xt+Zgfv0sSqIepS6tKOcPW+jrSLac X-Received: by 10.66.249.68 with SMTP id ys4mr1776467pac.31.1401452813581; Fri, 30 May 2014 05:26:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.209 with SMTP id x75ls967329qgx.46.gmail; Fri, 30 May 2014 05:26:53 -0700 (PDT) X-Received: by 10.220.249.198 with SMTP id ml6mr13405585vcb.36.1401452813408; Fri, 30 May 2014 05:26:53 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id na9si2877332vcb.64.2014.05.30.05.26.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 05:26:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id oz11so2011337veb.31 for ; Fri, 30 May 2014 05:26:53 -0700 (PDT) X-Received: by 10.220.7.131 with SMTP id d3mr948760vcd.45.1401452813334; Fri, 30 May 2014 05:26:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp108122vcb; Fri, 30 May 2014 05:26:52 -0700 (PDT) X-Received: by 10.50.129.104 with SMTP id nv8mr5091576igb.45.1401452811687; Fri, 30 May 2014 05:26:51 -0700 (PDT) Received: from mail-ig0-f172.google.com (mail-ig0-f172.google.com [209.85.213.172]) by mx.google.com with ESMTPS id p3si8052742icv.38.2014.05.30.05.26.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 05:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.213.172 as permitted sender) client-ip=209.85.213.172; Received: by mail-ig0-f172.google.com with SMTP id uy17so715844igb.5 for ; Fri, 30 May 2014 05:26:51 -0700 (PDT) X-Received: by 10.42.4.201 with SMTP id 9mr15067579ict.57.1401452811485; Fri, 30 May 2014 05:26:51 -0700 (PDT) Received: from localhost.localdomain (host109-148-113-200.range109-148.btcentralplus.com. [109.148.113.200]) by mx.google.com with ESMTPSA id g2sm5152788igc.12.2014.05.30.05.26.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 05:26:51 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, wsa@the-dreams.de Cc: grant.likely@linaro.org, linus.walleij@linaro.org, linux-i2c@vger.kernel.org, Lee Jones Subject: [PATCH] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices Date: Fri, 30 May 2014 13:26:37 +0100 Message-Id: <1401452797-29521-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401452797-29521-1-git-send-email-lee.jones@linaro.org> References: <1401452797-29521-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 either DT and/or ACPI match tables instead. Signed-off-by: Lee Jones --- drivers/i2c/i2c-core.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7c7f4b8..49c534d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -260,13 +260,29 @@ static int i2c_device_probe(struct device *dev) { struct i2c_client *client = i2c_verify_client(dev); struct i2c_driver *driver; + const struct of_device_id *of_match = dev->driver->of_match_table; + const struct acpi_device_id *acpi_match = dev->driver->acpi_match_table; + const struct i2c_device_id *id; int status; if (!client) return 0; driver = to_i2c_driver(dev->driver); - if (!driver->probe || !driver->id_table) + if (!driver->probe) + return -EINVAL; + + /* + * An I2C ID table is not madatory, if and only if, a suitable Device + * Tree and/or ACPI match table entry is supplied for the probing + * device. + */ + if (driver->id_table) + id = i2c_match_id(driver->id_table, client); + else if (of_match_device(of_match, dev) || + acpi_match_device(acpi_match, dev)) + id = NULL; + else return -ENODEV; if (!device_can_wakeup(&client->dev)) @@ -275,7 +291,7 @@ static int i2c_device_probe(struct device *dev) dev_dbg(dev, "probe\n"); acpi_dev_pm_attach(&client->dev, true); - status = driver->probe(client, i2c_match_id(driver->id_table, client)); + status = driver->probe(client, id); if (status) acpi_dev_pm_detach(&client->dev, true);