From patchwork Thu Aug 28 14:35:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36227 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E3522202DD for ; Thu, 28 Aug 2014 14:37:12 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id v1sf5514073yhn.8 for ; Thu, 28 Aug 2014 07:37:12 -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=7HnZP7dVsuwj6GU5vHNfTgmxpKDByS4bHWE0/A7ENYk=; b=WtyK+iteioG2LENfJLZchxp2X/GE1/mL/PZP7s3rOTFiqZlgpdKxbrkKvrON7AP7ck m3MbqL5Gptl31pnuY7eA04xid99BlRgiT8teEvnZP39i3FP0orSUxJg8iLyWP7gqseTC BkvHr+QVPkzIlrbCdsRbZGIljWHoslWAZDe3D72PGaQJQTE0jn1p4CB/+RLX7aUbo0+B xwNHTsLhClGU17xpoKt+aULSQmY7iJg5ZQrcY8DCERzgAfIyrCnVaL3wJc/yS4U6kZaB mWEGl98N7wHDbeM/QPVdUjm1aKGj6PmxrPYRZO3CDzVWqwanA43deqP5nEY7LcmmkNXy dF6Q== X-Gm-Message-State: ALoCoQmFQc4cSFxEwYOtlg2khUWeAnKGpT3CigzyU9f1XICl7VwAXHABd29FqqJzLnfPA5NsMAHw X-Received: by 10.236.118.195 with SMTP id l43mr413753yhh.52.1409236632766; Thu, 28 Aug 2014 07:37:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.246 with SMTP id l109ls585319qgf.1.gmail; Thu, 28 Aug 2014 07:37:12 -0700 (PDT) X-Received: by 10.220.1.5 with SMTP id 5mr966462vcd.74.1409236632632; Thu, 28 Aug 2014 07:37:12 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id wu1si3647601vdb.101.2014.08.28.07.37.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 07:37:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ij19so899144vcb.40 for ; Thu, 28 Aug 2014 07:37:12 -0700 (PDT) X-Received: by 10.220.187.134 with SMTP id cw6mr967924vcb.71.1409236632551; Thu, 28 Aug 2014 07:37:12 -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 uj3csp246750vcb; Thu, 28 Aug 2014 07:37:12 -0700 (PDT) X-Received: by 10.68.171.101 with SMTP id at5mr6361039pbc.107.1409236631620; Thu, 28 Aug 2014 07:37:11 -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.10 for ; Thu, 28 Aug 2014 07:37:11 -0700 (PDT) Received-SPF: none (google.com: devicetree-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 S1751669AbaH1Of5 (ORCPT + 6 others); Thu, 28 Aug 2014 10:35:57 -0400 Received: from mail-qg0-f50.google.com ([209.85.192.50]:52074 "EHLO mail-qg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751578AbaH1Of4 (ORCPT ); Thu, 28 Aug 2014 10:35:56 -0400 Received: by mail-qg0-f50.google.com with SMTP id q108so833694qgd.9 for ; Thu, 28 Aug 2014 07:35:55 -0700 (PDT) X-Received: by 10.140.22.243 with SMTP id 106mr6774060qgn.86.1409236555582; Thu, 28 Aug 2014 07:35:55 -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.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 07:35:55 -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 2/8] i2c: Add the ability to match device to compatible string without an of_node Date: Thu, 28 Aug 2014 15:35:32 +0100 Message-Id: <1409236538-21274-3-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: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.181 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: , A great deal of I2C devices are currently matched via DT node name, and as such the compatible naming convention of ',' has gone somewhat awry - some nodes don't supply one, some supply an arbitrary string and others the correct device name with an arbitrary vendor prefix. In an effort to correct this problem we have to supply a mechanism to match a device by compatible string AND by simple device name. This function strips off the ',' part of a supplied compatible string and attempts to match without it. The plan is to remove this function once all of the compatible strings for each device have been brought into line. Acked-by: Grant Likely Signed-off-by: Lee Jones --- drivers/i2c/i2c-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index d3c8e9f..eb46d15 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1095,6 +1095,27 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) return i2c_verify_adapter(dev); } EXPORT_SYMBOL(of_find_i2c_adapter_by_node); + +static const struct of_device_id* +i2c_of_match_device_strip_vendor(const struct of_device_id *matches, + struct i2c_client *client) +{ + const char *name; + + for (; matches->compatible[0]; matches++) { + name = strchr(matches->compatible, ','); + if (!name) + name = matches->compatible; + else + name++; + + if (!strnicmp(client->name, name, strlen(client->name))) + return matches; + } + + return NULL; +} + #else static void of_i2c_register_devices(struct i2c_adapter *adap) { } #endif /* CONFIG_OF */