From patchwork Thu Aug 28 14:35:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36228 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AED02202DD for ; Thu, 28 Aug 2014 14:37:15 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id q200sf5156332ykb.1 for ; Thu, 28 Aug 2014 07:37:15 -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=CdoMJKOuIYq+fSg8hji0VS8GFm/Y7102ETIUv7ghr08=; b=E1ml2djUlcMv+O58EtHH+SflKJ27jSlHDQQ81Zf8yK5yhqwGwjRDJq8eVeI/Q5S7NG uy7qYy+iwnKUqUm/8qgJihWRtzjc0eCq8lEcCGiWpVyS6NI7n//nVHoc1tmYY7uhtxQu 00sw0KjjBIWNai3oRhlbP6W8j921+ir23DTVfXXgpNywBkNQEDJvwU+82BR2KEc15piB 236IpRMwASC3e1F/xAZq6W4N15afDLjo/pfW09oEqAn3tTegDISOGJAwRak65d8ju5Z4 ddX/J8St+l+YCDBX/ZwU96Sx4BR+pTOJ+beaP6AdMnCBlgz1GKn0vUSRnzRmhX9TQUrV uObQ== X-Gm-Message-State: ALoCoQmrZeUgYiaXOcWG3yNlGwzgHzJvBk1mgnYCf0EXb/2TkSqvfB6kQFyWcgQB1EpfbT6izh3a X-Received: by 10.236.159.198 with SMTP id s46mr387757yhk.17.1409236635560; Thu, 28 Aug 2014 07:37:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.177 with SMTP id y46ls543693qge.79.gmail; Thu, 28 Aug 2014 07:37:15 -0700 (PDT) X-Received: by 10.221.21.8 with SMTP id qq8mr1131125vcb.57.1409236635364; Thu, 28 Aug 2014 07:37:15 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ci16si3651995vdb.93.2014.08.28.07.37.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 07:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so911059vcb.30 for ; Thu, 28 Aug 2014 07:37:15 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr2966376vdb.27.1409236635253; Thu, 28 Aug 2014 07:37:15 -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 uj3csp246754vcb; Thu, 28 Aug 2014 07:37:14 -0700 (PDT) X-Received: by 10.68.69.46 with SMTP id b14mr6598006pbu.70.1409236634102; Thu, 28 Aug 2014 07:37:14 -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.11 for ; Thu, 28 Aug 2014 07:37:14 -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 S1751795AbaH1OgB (ORCPT + 26 others); Thu, 28 Aug 2014 10:36:01 -0400 Received: from mail-qc0-f171.google.com ([209.85.216.171]:48207 "EHLO mail-qc0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbaH1Of7 (ORCPT ); Thu, 28 Aug 2014 10:35:59 -0400 Received: by mail-qc0-f171.google.com with SMTP id x3so858766qcv.16 for ; Thu, 28 Aug 2014 07:35:58 -0700 (PDT) X-Received: by 10.224.173.7 with SMTP id n7mr7117451qaz.57.1409236557933; Thu, 28 Aug 2014 07:35:57 -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.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 07:35:57 -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 3/8] i2c: Match using traditional OF methods, then by vendor-less compatible strings Date: Thu, 28 Aug 2014 15:35:33 +0100 Message-Id: <1409236538-21274-4-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.171 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: , 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. Acked-by: Grant Likely Signed-off-by: Lee Jones --- drivers/i2c/i2c-core.c | 16 ++++++++++++++++ include/linux/i2c.h | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index eb46d15..5728b2e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1116,6 +1116,22 @@ i2c_of_match_device_strip_vendor(const struct of_device_id *matches, return NULL; } +const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, + struct i2c_client *client) +{ + const struct of_device_id *match; + + if (!(client && matches)) + return NULL; + + match = of_match_device(matches, &client->dev); + if (match) + return match; + + return i2c_of_match_device_strip_vendor(matches, client); +} +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 a95efeb..a48eadd 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -564,6 +564,10 @@ extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); /* must call put_device() when done with returned i2c_adapter device */ 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 i2c_client *client); + #else static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) @@ -575,6 +579,14 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node { return NULL; } + +const struct of_device_id +*i2c_of_match_device(const struct of_device_id *matches, + struct i2c_client *client) +{ + return NULL; +} + #endif /* CONFIG_OF */ #ifdef CONFIG_ACPI