From patchwork Fri Jun 6 15:52:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 31494 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DBF6202DA for ; Fri, 6 Jun 2014 15:52:55 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rp18sf12649739iec.9 for ; Fri, 06 Jun 2014 08:52:54 -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=IQIhGfUsL7xcipcdl54lYxoP1jWd52M07TzZdWfbZWc=; b=aSWRui0ZBHVy5eoY2WmHXubFawozJ8P0xIbMLzf02aO7Ie8CVru/8TLeFHvA34mCuN EaZRuOI2BjhJgjgzU8Xz8AVOwUHk3qx7KBdUICKhDEBoVJqh+ZMgxwmAIlowFfwwtvrO UUoBIHOx2bYWSxMOvkdN4QHunqfQZtNqxjhqgom1g/YiWVHZzon0wjU3uJBqcojurd0y F4r/4fcdlTyXoxBRNu0pEylzUX8dw9wXg92OPfIpSp8hfkS7xTfCADbf4uFw4zewZy7i PAwB3gUl5lUFvlA4wukzaq9mGkOopQBmjz/EIlAnN8CxPzF3rLHVaClxzsSEE+k/QiPS Otjg== X-Gm-Message-State: ALoCoQliC0DXP8EPxUJYG8Dcbba3gSsoiad24LXe9SfxLl6xL29x2kACQ8KwZA0YNLX/jTqFw6CA X-Received: by 10.42.185.1 with SMTP id cm1mr3479767icb.10.1402069974798; Fri, 06 Jun 2014 08:52:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.4 with SMTP id i4ls765370qgf.78.gmail; Fri, 06 Jun 2014 08:52:54 -0700 (PDT) X-Received: by 10.58.168.146 with SMTP id zw18mr6557438veb.32.1402069974655; Fri, 06 Jun 2014 08:52:54 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id yh7si6651872vdc.93.2014.06.06.08.52.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so3245460vcb.36 for ; Fri, 06 Jun 2014 08:52:54 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr3521672vec.80.1402069974582; Fri, 06 Jun 2014 08:52:54 -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.54.6 with SMTP id vs6csp115250vcb; Fri, 6 Jun 2014 08:52:54 -0700 (PDT) X-Received: by 10.50.79.131 with SMTP id j3mr32580959igx.23.1402069973957; Fri, 06 Jun 2014 08:52:53 -0700 (PDT) Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by mx.google.com with ESMTPS id t8si18973702icf.77.2014.06.06.08.52.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:52:53 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.173 as permitted sender) client-ip=209.85.223.173; Received: by mail-ie0-f173.google.com with SMTP id y20so290409ier.18 for ; Fri, 06 Jun 2014 08:52:53 -0700 (PDT) X-Received: by 10.42.109.79 with SMTP id k15mr7135230icp.15.1402069973747; Fri, 06 Jun 2014 08:52:53 -0700 (PDT) Received: from localhost.localdomain (host86-181-29-77.range86-181.btcentralplus.com. [86.181.29.77]) by mx.google.com with ESMTPSA id j1sm27388094ige.0.2014.06.06.08.52.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:52:53 -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, linus.walleij@linaro.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH 3/9] i2c: Match using traditional OF methods, then by vendor-less compatible strings Date: Fri, 6 Jun 2014 16:52:26 +0100 Message-Id: <1402069952-28022-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1402069952-28022-1-git-send-email-lee.jones@linaro.org> References: <1402069952-28022-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.177 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: , This function provides a single call for all I2C devices which need to match firstly using traditional OF means i.e by of_node, then if that fails we attempt to match using the supplied I2C client name with a list of supplied compatible strings with the ',' string removed. The latter is required due to the unruly naming conventions used currently by I2C devices. Signed-off-by: Lee Jones --- drivers/i2c/i2c-core.c | 13 +++++++++++++ include/linux/i2c.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index face8f9..80a2f2e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1115,6 +1115,19 @@ const struct of_device_id return NULL; } EXPORT_SYMBOL_GPL(i2c_of_match_device_strip_vendor); + +const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, struct device *dev) +{ + const struct of_device_id *match; + + match = of_match_device(matches, dev); + if (match) + return match; + + return i2c_of_match_device_strip_vendor(matches, dev); +} +EXPORT_SYMBOL_GPL(i2c_of_match_device); #else static void of_i2c_register_devices(struct i2c_adapter *adap) { } #endif /* CONFIG_OF */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index f7ec75b..ab5866f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -565,6 +565,9 @@ extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); extern struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node); extern const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, struct device *dev); + +extern const struct of_device_id *i2c_of_match_device_strip_vendor(const struct of_device_id *matches, struct device *dev); #else @@ -580,6 +583,12 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node } const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, struct device *dev) +{ + return NULL; +} + +const struct of_device_id *i2c_of_match_device_strip_vendor(const struct of_device_id *matches, struct device *dev) {