From patchwork Fri Jun 20 12:02:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 32265 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7CFC1203C2 for ; Fri, 20 Jun 2014 12:03:24 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id il7sf10985065vcb.8 for ; Fri, 20 Jun 2014 05:03:24 -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=WL197FXGRSTCLwbwM3rF6zFKUuk1EMvRbfmz299v2j8=; b=ZvBnmHhI93W9VaTzErzwlKuCcPgAc1mn8Vg2XyxN749U9xnJM6gZ/dHvB9L2GDTzAq UqXzOCesOGnZFyBbHNOQVzHhki/TokNNXSa9s06eUoaZ3RLTCzJKrO34aEOGaD3Ft4Zl 0J6UGHxmqvhg5drRRB19URU3TIvLzo6Sq27Vf85t0jv7O6z+pue0oD8xTVTCPt5E+xN3 TsT06RsIhTWSdCY7EWHGrx7xFvOYctwp72Kui+aUed1MCRYNLFtyjn5Q5EmrL3IiWgsK tSlgie2g9uU/VVZ1N9BQunmgnOqqUgaFPFRfzVaJJXlCs93Y671MTJJrxU5/f2iei5A8 8uXg== X-Gm-Message-State: ALoCoQmsroYcZzK+ozx9XEoz/HZxgWOWAyRYaWR7i/z0ZJauJa3i+XlIqnaNFOSHmjBKio/mhmjF X-Received: by 10.58.94.166 with SMTP id dd6mr1192804veb.12.1403265804310; Fri, 20 Jun 2014 05:03:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.42 with SMTP id 39ls882123qgq.26.gmail; Fri, 20 Jun 2014 05:03:24 -0700 (PDT) X-Received: by 10.58.188.37 with SMTP id fx5mr2688742vec.17.1403265804237; Fri, 20 Jun 2014 05:03:24 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id fj4si441574vcb.24.2014.06.20.05.03.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id la4so3418773vcb.28 for ; Fri, 20 Jun 2014 05:03:24 -0700 (PDT) X-Received: by 10.220.80.70 with SMTP id s6mr227525vck.44.1403265804161; Fri, 20 Jun 2014 05:03:24 -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 tc5csp16583vcb; Fri, 20 Jun 2014 05:03:23 -0700 (PDT) X-Received: by 10.42.11.74 with SMTP id t10mr2992830ict.27.1403265803150; Fri, 20 Jun 2014 05:03:23 -0700 (PDT) Received: from mail-ig0-f180.google.com (mail-ig0-f180.google.com [209.85.213.180]) by mx.google.com with ESMTPS id d7si2466578igc.38.2014.06.20.05.03.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.213.180 as permitted sender) client-ip=209.85.213.180; Received: by mail-ig0-f180.google.com with SMTP id h18so424081igc.7 for ; Fri, 20 Jun 2014 05:03:23 -0700 (PDT) X-Received: by 10.42.111.135 with SMTP id u7mr3161054icp.80.1403265802952; Fri, 20 Jun 2014 05:03:22 -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.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:22 -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 3/9] i2c: Add the ability to match device to compatible string without an of_node Date: Fri, 20 Jun 2014 13:02:27 +0100 Message-Id: <1403265753-25851-5-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.220.169 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: , 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 d3802dc..8a37745 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1090,6 +1090,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 */