From patchwork Wed Jun 4 12:09:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 4293681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E95BBEEA7 for ; Wed, 4 Jun 2014 12:13:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E28A202E5 for ; Wed, 4 Jun 2014 12:13:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC471201C7 for ; Wed, 4 Jun 2014 12:13:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WsA21-0001po-FT; Wed, 04 Jun 2014 12:11:01 +0000 Received: from mail-ig0-f179.google.com ([209.85.213.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WsA1i-0001Xb-PY for linux-arm-kernel@lists.infradead.org; Wed, 04 Jun 2014 12:10:43 +0000 Received: by mail-ig0-f179.google.com with SMTP id hn18so939895igb.0 for ; Wed, 04 Jun 2014 05:10:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SgKrFDbI5XvOJ4vCGvH9bJjaEKB5YqBx8Mi+zninKt4=; b=Az24HXpnfAowsm0WgnSL5m+moOssIcrDBfNN8ZPt40fecWK4vUtkFy487sHQBPqq/f whQroB2W4vwvGdEls1Zfd8wrtHHHPKJeye5S7hJUBPwYB4ccLy5VrxO/YvNBcTAIQwvh U0vhNVEhwow2+wAvF1eP+HXdoKn2RpLzrlgC96bn0bXlvWQEiabtifgTBKJxFqBQqjcL D5rFnZ9+6aoGiN4tQgY5DyRXe4N2jMDDIv+69TF7wRenXwfIRUEYpLxxTDS7AmNf6NzW 8vbzvkQ3dGSycah9//daADy+3HFEMzhANaW/ZdsCjoKEXla3vJK9UpHw8Am9YRdMksBr hTCw== X-Gm-Message-State: ALoCoQkiVghNC2nAYuaN1lGg2ZCW9dkEGPJqRPyiERapqJyxbUZfpt1pc2mWGx1XCfAZcDXeuncP X-Received: by 10.50.50.231 with SMTP id f7mr6389916igo.42.1401883821249; Wed, 04 Jun 2014 05:10:21 -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 on9sm10028136igb.11.2014.06.04.05.10.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 05:10:20 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] i2c: Match using traditional OF methods, then by vendor-less compatible strings Date: Wed, 4 Jun 2014 13:09:53 +0100 Message-Id: <1401883796-17841-5-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401883796-17841-1-git-send-email-lee.jones@linaro.org> References: <1401883796-17841-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140604_051042_912869_B62AE415 X-CRM114-Status: GOOD ( 11.48 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, wsa@the-dreams.de, linus.walleij@linaro.org, linux-i2c@vger.kernel.org, grant.likely@linaro.org, Lee Jones X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 7dcd5c3..e8c2cba 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) {