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: 31349 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DF46203AC for ; Wed, 4 Jun 2014 12:10:23 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf3068440igq.2 for ; Wed, 04 Jun 2014 05:10:22 -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=SgKrFDbI5XvOJ4vCGvH9bJjaEKB5YqBx8Mi+zninKt4=; b=kKGiJN+PcyMHDfeMqsmmFTRjJXcDo8hlW+8xTGJ3FP/+E903S6Ke/EuPkenu79A3Cx +98X/VdRFlEkonOV0UZuWQkWEKDaU5gxMeDOj+4mJGM/BbVnzThs/47w5wRQqeS+dgzn K1J/GqVRUYN7tK/YOBjRDg/W+qcUm2XTX5Eem+mgWFYHlFq+O3vHi9kHvC81UYWbrt75 w73xnf+R3OYKTqu5nQ2YasJNV7jAOO08undw3MEUqpeC/1F+TTq3uPcvJcmQXsMqG5hm t85jFu+Q+vA7smXGUfOTPAX+Kcq7hiutanooJI1z7WNhFfCF7xCW6GRyZL8+zcDXDAUc FZXg== X-Gm-Message-State: ALoCoQkr2fr6Z8f/zzprsnlW+ti9ZBxJWeYnATfGcLJKxPhQcBBzeGeFl3etyR3PTuC1EMs33PSh X-Received: by 10.182.104.161 with SMTP id gf1mr10873901obb.45.1401883822606; Wed, 04 Jun 2014 05:10:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.67 with SMTP id g61ls2994921qgg.12.gmail; Wed, 04 Jun 2014 05:10:22 -0700 (PDT) X-Received: by 10.52.27.115 with SMTP id s19mr1197961vdg.51.1401883822502; Wed, 04 Jun 2014 05:10:22 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id 7si106158vcu.41.2014.06.04.05.10.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 05:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id oz11so8594901veb.2 for ; Wed, 04 Jun 2014 05:10:22 -0700 (PDT) X-Received: by 10.58.2.74 with SMTP id 10mr1397167ves.61.1401883822423; Wed, 04 Jun 2014 05:10:22 -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 vs6csp39877vcb; Wed, 4 Jun 2014 05:10:21 -0700 (PDT) X-Received: by 10.50.61.243 with SMTP id t19mr6358336igr.41.1401883821446; Wed, 04 Jun 2014 05:10:21 -0700 (PDT) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by mx.google.com with ESMTPS id ga2si9142613igd.0.2014.06.04.05.10.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 05:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.175 as permitted sender) client-ip=209.85.223.175; Received: by mail-ie0-f175.google.com with SMTP id y20so7204686ier.34 for ; Wed, 04 Jun 2014 05:10:21 -0700 (PDT) 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 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 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-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.128.171 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 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) {