From patchwork Fri Jun 20 12:02:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 32267 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 25467203C2 for ; Fri, 20 Jun 2014 12:03:29 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id i13sf9484466qae.7 for ; Fri, 20 Jun 2014 05:03:28 -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=rbQN6pv2ONSTz8iUTmbP6u2uSeGx9Fm3mD6ukD4AFqI=; b=kC9GGMZ8vlykJS1PTZcCWh7FYc83yj0ckt9V/Z0pcHkqTHC8B4lpQeP8yoou2UdGy2 83hQLN8s8m4XSbFZ6fc2jpcYJRqO6VVv6/qbNHHG6mt42fkxDk/syjog2qlCRVMt2et1 ia2Wxl5jDDZSj6u/L6pRX8NRqbyGCR2iLwSLx5M7aHGO8w4xK0EZ2lcBDiOntbk1Z1mp Dkg+DK+giUEcScssTnXEQGjmcVTEFGNRDHk1vXNh6jl4OhieW7sS569650gCxCLJn+JF sbR3cpMz/gW4EVoSb1MGOfUMAPvRaHNVMQM6l3W0O90j85HBIeUEjk4TjtUxlgvrCcna sqKw== X-Gm-Message-State: ALoCoQmWavsI2ZSE7SbHlBKbuqA0RnFgjS9jjaHs/3ApPm94t1QGjuAu7o/SZrKSaWXIsxiW2SBN X-Received: by 10.236.189.68 with SMTP id b44mr1050225yhn.4.1403265808914; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.148 with SMTP id r20ls949628qgd.12.gmail; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) X-Received: by 10.58.160.164 with SMTP id xl4mr695577veb.38.1403265808824; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id dj5si3874360vcb.21.2014.06.20.05.03.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id id10so3350574vcb.38 for ; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) X-Received: by 10.58.196.231 with SMTP id ip7mr119489vec.47.1403265808750; Fri, 20 Jun 2014 05:03:28 -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.221.37.5 with SMTP id tc5csp16596vcb; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) X-Received: by 10.43.160.69 with SMTP id mb5mr3106236icc.49.1403265808039; Fri, 20 Jun 2014 05:03:28 -0700 (PDT) Received: from mail-ig0-f175.google.com (mail-ig0-f175.google.com [209.85.213.175]) by mx.google.com with ESMTPS id hg12si14483836icb.17.2014.06.20.05.03.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.213.175 as permitted sender) client-ip=209.85.213.175; Received: by mail-ig0-f175.google.com with SMTP id h3so428894igd.2 for ; Fri, 20 Jun 2014 05:03:27 -0700 (PDT) X-Received: by 10.42.51.204 with SMTP id f12mr3180747icg.21.1403265807819; Fri, 20 Jun 2014 05:03:27 -0700 (PDT) Received: from localhost.localdomain (host109-148-235-194.range109-148.btcentralplus.com. [109.148.235.194]) by mx.google.com with ESMTPSA id qn5sm3890078igb.7.2014.06.20.05.03.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:27 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: wsa@the-dreams.de, grant.likely@linaro.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linus.walleij@linaro.org, Lee Jones Subject: [PATCH 5/9] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Fri, 20 Jun 2014 13:02:29 +0100 Message-Id: <1403265753-25851-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1403265753-25851-1-git-send-email-lee.jones@linaro.org> References: <1403265753-25851-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.220.179 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 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 a9c97c4..ff2919a 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -100,7 +100,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 */ @@ -268,7 +268,15 @@ static int i2c_device_probe(struct device *dev) 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 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))