From patchwork Fri Jun 20 12:02:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 32266 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5BC39203C2 for ; Fri, 20 Jun 2014 12:03:27 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rp16sf12655342pbb.5 for ; Fri, 20 Jun 2014 05:03:26 -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=199P8cc5d7noofhc2/CwjAnIAF7D4Wg1havkp1DBlvk=; b=S2A2P2S2a64QhidGrPswTH0joj24CEhWZDtDI/zLS7+nFkBp4LQMBS+sypOEUU/gj3 xpcjfgMZfGcYoAQOoTaWB1y0bjqSUXGrDzXqghDXijuDkbmUr6DABsKkIoSfcqRlUyIc 4L9ib0V5qKhvADt4qXwiRCnOYsoRAbOE/cjGIOh+dNkRytrjOknEtpI5wa184fXcoEyW nc6rNkqLuDceTongQja2afZyra3U8ACNZYcbIpwvF0qDTsguQgKDnVqAt5TMzyD2ans/ vN2IKNh/ENyWhzlG1CqWQWLoHyNGMyaKhXs75pyMcuKN9Awd//FwQJoRI/q82dF0DJDz Ib+A== X-Gm-Message-State: ALoCoQna17ieD9ewgi0I61pST1ZdOD4S2mGwdX4foLVAe4prJy/2q9xDf+Ef0abldmSA543r//tn X-Received: by 10.67.5.163 with SMTP id cn3mr1147525pad.25.1403265806704; Fri, 20 Jun 2014 05:03:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.33 with SMTP id 30ls241712qgw.13.gmail; Fri, 20 Jun 2014 05:03:26 -0700 (PDT) X-Received: by 10.52.119.179 with SMTP id kv19mr2152369vdb.3.1403265806504; Fri, 20 Jun 2014 05:03:26 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id u5si3862803vcr.104.2014.06.20.05.03.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so3431691veb.40 for ; Fri, 20 Jun 2014 05:03:26 -0700 (PDT) X-Received: by 10.58.119.75 with SMTP id ks11mr2693360veb.20.1403265806431; Fri, 20 Jun 2014 05:03:26 -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.37.5 with SMTP id tc5csp16589vcb; Fri, 20 Jun 2014 05:03:25 -0700 (PDT) X-Received: by 10.50.67.7 with SMTP id j7mr3761865igt.8.1403265805615; Fri, 20 Jun 2014 05:03:25 -0700 (PDT) Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by mx.google.com with ESMTPS id c19si2463803igv.42.2014.06.20.05.03.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.178 as permitted sender) client-ip=209.85.223.178; Received: by mail-ie0-f178.google.com with SMTP id rd18so3051249iec.23 for ; Fri, 20 Jun 2014 05:03:25 -0700 (PDT) X-Received: by 10.50.25.37 with SMTP id z5mr3744026igf.26.1403265805397; Fri, 20 Jun 2014 05:03:25 -0700 (PDT) Received: from localhost.localdomain (host109-148-235-194.range109-148.btcentralplus.com. [109.148.235.194]) by mx.google.com with ESMTPSA id qn5sm3890078igb.7.2014.06.20.05.03.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:24 -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/9] i2c: Match using traditional OF methods, then by vendor-less compatible strings Date: Fri, 20 Jun 2014 13:02:28 +0100 Message-Id: <1403265753-25851-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1403265753-25851-1-git-send-email-lee.jones@linaro.org> References: <1403265753-25851-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.181 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. 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 8a37745..a9c97c4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1111,6 +1111,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 b556e0a..3d0350c 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 */ #endif /* _LINUX_I2C_H */