From patchwork Tue Jul 1 16:32:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 4460761 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 77D0F9F358 for ; Tue, 1 Jul 2014 16:39:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98564203DA for ; Tue, 1 Jul 2014 16:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4BC32015A for ; Tue, 1 Jul 2014 16:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758275AbaGAQdh (ORCPT ); Tue, 1 Jul 2014 12:33:37 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:52565 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758269AbaGAQde (ORCPT ); Tue, 1 Jul 2014 12:33:34 -0400 Received: by mail-pd0-f169.google.com with SMTP id g10so10454297pdj.0 for ; Tue, 01 Jul 2014 09:33:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=X1niPpDu32+3S1ea9NchyPPRqzfKVywyzpsWLoNZRs8=; b=EpZfJMzMDzPQLbWOzd1TRazpil9LrK98xrMyRvaPPz2XjF3t60n25MQnCnaQpxGGJA Wgh4DJcRfBbBW0GQwVzadkrHlGAtn8CgbD5d/xpv7fZwJbygTJiuSPoUph4nXLrHkX6y Dq0H3+m47f/ks+PW0FfOMcM1EQUuLiz/3NP4zeR/OYAaF+Ld/p3CMZpkCGA0kA8H9lQG QnUg2BaUhUqo+1YMc7ZqSgX6RzDsOvI4EZlS2RP7qjipJW00IgCLJFJf00hPwXnpFf84 j9AAHgf7NTwpyrNlqmuYuOaVBiehL6NIeLoUVXWafnLf+nvT6I3EN2zzobW9rWDJoI0v dpWg== X-Gm-Message-State: ALoCoQkYTTKKf2aP3w87t1Fs/xpM00dGYOJ9pb2nD9d6aCYV8qswxGAOJTuRlyW5hs7Or/Z//4iB X-Received: by 10.66.243.225 with SMTP id xb1mr1872465pac.49.1404232414148; Tue, 01 Jul 2014 09:33:34 -0700 (PDT) Received: from localhost ([122.166.172.22]) by mx.google.com with ESMTPSA id wt2sm33382291pbc.93.2014.07.01.09.33.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 09:33:33 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net, shawn.guo@linaro.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, spk.linux@gmail.com, thomas.ab@samsung.com, nm@ti.com, t.figa@samsung.com, Viresh Kumar , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 01/14] of: Create of_property_match() Date: Tue, 1 Jul 2014 22:02:30 +0530 Message-Id: <9a6bdfa64092dd8ee483570880225e08fcbad810.1404231535.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create a new routine of_property_match() that will match a property between two nodes. If they are exactly same, it returns 1 else 0. If the property isn't available in any of the nodes or the API isn't implemented, proper error codes would be returned. The first user of this routine would be cpufreq-cpu0 driver, which requires to match "clock" property between CPU nodes to identify which CPUs share clock line. And hence this routine. Cc: Rob Herring Cc: devicetree@vger.kernel.org Signed-off-by: Viresh Kumar --- drivers/of/base.c | 29 +++++++++++++++++++++++++++++ include/linux/of.h | 10 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index b986480..a036c91 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1490,6 +1490,35 @@ int of_property_count_strings(struct device_node *np, const char *propname) } EXPORT_SYMBOL_GPL(of_property_count_strings); +/** + * of_property_match - Match 'prop' property between two nodes + * @np1, np2: Nodes to match for property + * @prop_name: property to match + * + * Returns 1 on match, 0 on no match, and error for missing property. + */ +int of_property_match(const struct device_node *np1, + const struct device_node *np2, const char *prop_name) +{ + const __be32 *prop1, *prop2; + int size1, size2; + + /* Retrieve property from both nodes */ + prop1 = of_get_property(np1, prop_name, &size1); + if (!prop1) + return -ENOENT; + + prop2 = of_get_property(np2, prop_name, &size2); + if (!prop2) + return -ENOENT; + + if (size1 != size2) + return 0; + + return !memcmp(prop1, prop2, size1); +} +EXPORT_SYMBOL_GPL(of_property_match); + void of_print_phandle_args(const char *msg, const struct of_phandle_args *args) { int i; diff --git a/include/linux/of.h b/include/linux/of.h index 196b34c..4e9cf5a 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -275,6 +275,9 @@ extern int of_property_match_string(struct device_node *np, const char *string); extern int of_property_count_strings(struct device_node *np, const char *propname); +extern int of_property_match(const struct device_node *np1, + const struct device_node *np2, + const char *prop_name); extern int of_device_is_compatible(const struct device_node *device, const char *); extern int of_device_is_available(const struct device_node *device); @@ -498,6 +501,13 @@ static inline int of_property_count_strings(struct device_node *np, return -ENOSYS; } +static inline int of_property_match(const struct device_node *np1, + const struct device_node *np2, + const char *prop_name) +{ + return -ENOSYS; +} + static inline const void *of_get_property(const struct device_node *node, const char *name, int *lenp)