From patchwork Fri Sep 11 11:55:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 53441 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 6961D215BF for ; Fri, 11 Sep 2015 11:58:18 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf23587915lbb.3 for ; Fri, 11 Sep 2015 04:58:17 -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=+xdn9DZBPyfCDiQ3gYnrs5TvEHGSQWxmMSBSEk9C4B4=; b=jPRWObFP6ToOtHaC5CvZUjFZ7qEU18v2h4ZfrqweUVTtkkpeWJrEkjbGAWCGGuViHA Cg00wauGG/10vXig7jocpPTmYo9vq1mupZTlFWA0wvIYkh/zgZh/wElxYms4dxNUo7Qn J143gJAuQIz1xG2zwKBl6wsEaOPBqwEYgbD1hwcgB+Z8qGJwqbSKclEP66IDajFz6zFS X8nGw72n8OGmPjMOKZUPynjj5Xqm5vgF2W3H3o4JnKtIWp5PcJEM3s5JfvBCujafSJzU iccDzGdDfoG/n3Rw9ImUkNwUyYzOIKadG8u1gbV0GCmSfSo+b9/HX3qYmaYePH+kvdZJ 59lg== X-Gm-Message-State: ALoCoQmdIWsZlLSRBNBW0T7V0AxGL/MFu4kDIIaO83LSQRCuqEjT98z8NYXTJNjbJFD/OYACWZHK X-Received: by 10.194.59.166 with SMTP id a6mr6405460wjr.6.1441972697067; Fri, 11 Sep 2015 04:58:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.229 with SMTP id q5ls263904lae.17.gmail; Fri, 11 Sep 2015 04:58:16 -0700 (PDT) X-Received: by 10.112.13.40 with SMTP id e8mr21943608lbc.82.1441972696864; Fri, 11 Sep 2015 04:58:16 -0700 (PDT) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com. [2a00:1450:4010:c03::236]) by mx.google.com with ESMTPS id dv2si761665lac.156.2015.09.11.04.58.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 04:58:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) client-ip=2a00:1450:4010:c03::236; Received: by lahg1 with SMTP id g1so16220282lah.1 for ; Fri, 11 Sep 2015 04:58:16 -0700 (PDT) X-Received: by 10.152.203.134 with SMTP id kq6mr41892452lac.106.1441972696751; Fri, 11 Sep 2015 04:58:16 -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.112.59.35 with SMTP id w3csp1541885lbq; Fri, 11 Sep 2015 04:58:15 -0700 (PDT) X-Received: by 10.107.165.140 with SMTP id o134mr2810887ioe.29.1441972695622; Fri, 11 Sep 2015 04:58:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y66si118930ioi.149.2015.09.11.04.58.14; Fri, 11 Sep 2015 04:58:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752782AbbIKL5w (ORCPT + 28 others); Fri, 11 Sep 2015 07:57:52 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:36560 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752493AbbIKL5s (ORCPT ); Fri, 11 Sep 2015 07:57:48 -0400 Received: by wicgb1 with SMTP id gb1so59620059wic.1; Fri, 11 Sep 2015 04:57:47 -0700 (PDT) X-Received: by 10.194.187.206 with SMTP id fu14mr63264955wjc.19.1441972667352; Fri, 11 Sep 2015 04:57:47 -0700 (PDT) Received: from localhost.localdomain (cpc17-aztw24-2-0-cust759.aztw.cable.virginm.net. [92.237.134.248]) by smtp.gmail.com with ESMTPSA id wj4sm25354wjb.10.2015.09.11.04.57.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 04:57:46 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Samuel Ortiz , Lee Jones Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, grant.likely@linaro.org, javier@osg.samsung.com, Kieran Bingham Subject: [RESEND PATCH v4 2/8] i2c: Add the ability to match device to compatible string without an of_node Date: Fri, 11 Sep 2015 12:55:58 +0100 Message-Id: <1441972564-9621-3-git-send-email-kieranbingham@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> References: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: kieranbingham@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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: , From: Lee Jones 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 [Kieran: strnicmp to strncasecmp] Signed-off-by: Kieran Bingham --- 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 30d8a77..0788c1f 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1373,6 +1373,27 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) return adapter; } 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 (!strncasecmp(client->name, name, strlen(client->name))) + return matches; + } + + return NULL; +} + #else static void of_i2c_register_devices(struct i2c_adapter *adap) { } #endif /* CONFIG_OF */