From patchwork Thu Aug 28 14:35:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E4D18202DD for ; Thu, 28 Aug 2014 14:37:24 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf8313916oag.4 for ; Thu, 28 Aug 2014 07:37:24 -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=2ms3oBN+kGD5ZJZvvTqgScNpyA//2fzqtPOy5KSjJCQ=; b=Q60NBr8X+HQpjCGfqDJBG549ODAXfit9wpOIKldev5qIJp29QFSVqKwtEZ1FmOsXFn xymL6QWPSCwC3vm/8XiggmenpCh20oHMBfhHk66mRaZjZdm/0T6BZOyQy8ntVqWyKl2D uvMUfbOaZVd2Nkcdlj5b8u0yBcEpk7dxymLtWTS6iTySmRC1fZ/FkylIy6de87/4LaBt XkvyHv6y8oHoGjGmZhb6Vs1D0vNrNtUi+LS/9QzSo054pVpkndTO+Xfz+vfwFXRknvVI yM32/YsWxyiY8zw5ejaciVbyD/qISuBtpwXwPhoLqEZjQ5kCAmfx2ewKy3ePlhnqdBW7 JxgQ== X-Gm-Message-State: ALoCoQnft+ZpcV6KmXy2LcUjwp3pHyRtehLOImzd663fGN0SZQgwQMoJwKhNtl+jvelY13uUFtNy X-Received: by 10.50.117.10 with SMTP id ka10mr2942182igb.1.1409236644475; Thu, 28 Aug 2014 07:37:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.38 with SMTP id i35ls581252qgf.76.gmail; Thu, 28 Aug 2014 07:37:24 -0700 (PDT) X-Received: by 10.52.234.228 with SMTP id uh4mr1832347vdc.34.1409236644344; Thu, 28 Aug 2014 07:37:24 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id og3si3681514vcb.37.2014.08.28.07.37.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 07:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hy4so909843vcb.33 for ; Thu, 28 Aug 2014 07:37:24 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr3680926vcn.16.1409236644254; Thu, 28 Aug 2014 07:37:24 -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.221.45.67 with SMTP id uj3csp246787vcb; Thu, 28 Aug 2014 07:37:23 -0700 (PDT) X-Received: by 10.70.37.67 with SMTP id w3mr6376426pdj.107.1409236643475; Thu, 28 Aug 2014 07:37:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id so2si6871082pab.132.2014.08.28.07.37.22 for ; Thu, 28 Aug 2014 07:37:23 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752032AbaH1OhO (ORCPT + 26 others); Thu, 28 Aug 2014 10:37:14 -0400 Received: from mail-qc0-f182.google.com ([209.85.216.182]:55134 "EHLO mail-qc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbaH1OgB (ORCPT ); Thu, 28 Aug 2014 10:36:01 -0400 Received: by mail-qc0-f182.google.com with SMTP id m20so840538qcx.41 for ; Thu, 28 Aug 2014 07:36:00 -0700 (PDT) X-Received: by 10.140.30.136 with SMTP id d8mr6661489qgd.55.1409236560350; Thu, 28 Aug 2014 07:36:00 -0700 (PDT) Received: from localhost.localdomain (host86-152-0-170.range86-152.btcentralplus.com. [86.152.0.170]) by mx.google.com with ESMTPSA id o2sm5797541qgo.17.2014.08.28.07.35.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 07:35:59 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, wsa@the-dreams.de, grant.likely@linaro.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linus.walleij@linaro.org Subject: [PATCH 4/8] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Thu, 28 Aug 2014 15:35:34 +0100 Message-Id: <1409236538-21274-5-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409236538-21274-1-git-send-email-lee.jones@linaro.org> References: <1409236538-21274-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , 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 5728b2e..c6013cd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -101,7 +101,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 */ @@ -269,7 +269,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))