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: 32907 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55D2C20672 for ; Tue, 1 Jul 2014 16:33:54 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id o8sf22347974qcw.7 for ; Tue, 01 Jul 2014 09:33:54 -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: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=u++w9FvvnBKbu2xNqjI4T3tKY32GarEyBRvjQqa4SUk=; b=c80l1tDrCPU5j2adxTPSG2Iq9WQhZkbn2IjQoUHRJWn+Jrs54VW2CThg1U9Mk5cSem F2tw/aXHlFmwrfSYp/KIDWLYyNfvXTDV5XB5WpGeb5WHqGP79rqkv1EWl/TkU4wiFGQo AL/LiWc8iwg7BoHp7QebmPLR9txyFWda1Yyp7HJTW+O75yCUrZGt/mOmIhPKpDzxdpNf /2DC+xUSeqUVJ5R4KUuuqwxroUVGjzd1/xrurgZHu55ns1Cx11EU4HupL+tbAQqe4m5F ahf9+FH8CrrqQXT8iRUA90nGFYOQwwlZ2IVx9CqaVP28EHAu+w48Xfn37BgeRccSAo2w TvHw== X-Gm-Message-State: ALoCoQnkWZA8ttPLK330huCkNQun7NMgLEEKlMChu0slJ5a/uK+NOFrie62vRRhdYHBqJWslFgMF X-Received: by 10.58.147.69 with SMTP id ti5mr25192792veb.8.1404232434185; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.148 with SMTP id 20ls478069qgb.78.gmail; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) X-Received: by 10.58.18.211 with SMTP id y19mr1557803ved.58.1404232434040; Tue, 01 Jul 2014 09:33:54 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id m4si11645676vev.44.2014.07.01.09.33.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Jul 2014 09:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id ij19so9079640vcb.22 for ; Tue, 01 Jul 2014 09:33:53 -0700 (PDT) X-Received: by 10.58.151.68 with SMTP id uo4mr43835695veb.11.1404232433877; Tue, 01 Jul 2014 09:33:53 -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.37.5 with SMTP id tc5csp228285vcb; Tue, 1 Jul 2014 09:33:53 -0700 (PDT) X-Received: by 10.66.254.198 with SMTP id ak6mr1789183pad.156.1404232433103; Tue, 01 Jul 2014 09:33:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nt4si27551386pbc.39.2014.07.01.09.33.52; Tue, 01 Jul 2014 09:33:52 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1758291AbaGAQdh (ORCPT + 27 others); Tue, 1 Jul 2014 12:33:37 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:51018 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758239AbaGAQde (ORCPT ); Tue, 1 Jul 2014 12:33:34 -0400 Received: by mail-pd0-f177.google.com with SMTP id y10so10349351pdj.36 for ; Tue, 01 Jul 2014 09:33:34 -0700 (PDT) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@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.177 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: , 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)