From patchwork Sun Feb 23 22:16:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 25145 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 71DF220972 for ; Sun, 23 Feb 2014 22:18:06 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf16631986pab.9 for ; Sun, 23 Feb 2014 14:18:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=flHGsggXf3P2wl9xXNdmXu93RZn3/agsC0xYHfGHUUQ=; b=E6BL8/epfyPoOQvPFQrIJNmnQnhKc+1gyQCJxM0RTvVquioDRwj1dft0e7ZQ+EUm+R 6jFaKHECrx36z3GkIU1+gvg4ZlMnOQwXGP0M/X96uN5Gi9eGnG0CQh/V48k8wsD2IK6p sclArFbmOoG9rV9ipAmcBMeHgAiXpAM8NXneiJlK+8X7AVAgN6DNl4t30O2+qJMCQusd 7PXfAYKeGCqTMRk4O4TZ35i6UVqs/9t1Bxv5aKRE6fRCyjc/X9c2e2W326ck/6kGB+Xw oZ9w7X7WRYidkA2al415gn4iY8iVlm81/GUQjzwy+e4zQnfV9hpDxs5WBh1ylaH6HGMB Q/GA== X-Gm-Message-State: ALoCoQn/Md2iLcLUdYzMr3Ojc1vqRtXRmBfQ2nkEIqq0JuCqSLKnUh/xkZcaBoo6iX6KVQ0uZbQ7 X-Received: by 10.67.4.202 with SMTP id cg10mr8995417pad.42.1393193885613; Sun, 23 Feb 2014 14:18:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.33 with SMTP id c30ls754807qge.9.gmail; Sun, 23 Feb 2014 14:18:05 -0800 (PST) X-Received: by 10.221.2.138 with SMTP id nu10mr10708478vcb.52.1393193885411; Sun, 23 Feb 2014 14:18:05 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id e9si5299799vct.109.2014.02.23.14.18.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 23 Feb 2014 14:18:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so5120826vcb.13 for ; Sun, 23 Feb 2014 14:18:05 -0800 (PST) X-Received: by 10.52.246.227 with SMTP id xz3mr9011576vdc.95.1393193885342; Sun, 23 Feb 2014 14:18:05 -0800 (PST) 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.220.174.196 with SMTP id u4csp20461vcz; Sun, 23 Feb 2014 14:18:05 -0800 (PST) X-Received: by 10.220.98.204 with SMTP id r12mr10813754vcn.48.1393193884936; Sun, 23 Feb 2014 14:18:04 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id at8si5295159vec.151.2014.02.23.14.18.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 23 Feb 2014 14:18:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WHhLr-0006pq-0B; Sun, 23 Feb 2014 22:16:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WHhLp-0006pU-F6 for xen-devel@lists.xenproject.org; Sun, 23 Feb 2014 22:16:45 +0000 Received: from [85.158.137.68:18589] by server-15.bemta-3.messagelabs.com id A8/67-19263-C437A035; Sun, 23 Feb 2014 22:16:44 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-6.tower-31.messagelabs.com!1393193802!3654091!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4992 invoked from network); 23 Feb 2014 22:16:42 -0000 Received: from mail-ee0-f44.google.com (HELO mail-ee0-f44.google.com) (74.125.83.44) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 23 Feb 2014 22:16:42 -0000 Received: by mail-ee0-f44.google.com with SMTP id d49so379504eek.31 for ; Sun, 23 Feb 2014 14:16:42 -0800 (PST) X-Received: by 10.15.56.8 with SMTP id x8mr20588886eew.83.1393193802345; Sun, 23 Feb 2014 14:16:42 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id g1sm55994749eet.6.2014.02.23.14.16.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2014 14:16:41 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Sun, 23 Feb 2014 22:16:21 +0000 Message-Id: <1393193792-20008-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393193792-20008-1-git-send-email-julien.grall@linaro.org> References: <1393193792-20008-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v2 04/15] xen/dts: Add dt_property_read_bool X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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-Archive: The function check if a property exists in a specific node. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v2: - Fix typo in commit message --- xen/common/device_tree.c | 6 ++---- xen/include/xen/device_tree.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index c66d1d5..ccdb7ff 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -512,10 +512,8 @@ static void __init *unflatten_dt_alloc(unsigned long *mem, unsigned long size, } /* Find a property with a given name for a given node and return it. */ -static const struct dt_property * -dt_find_property(const struct dt_device_node *np, - const char *name, - u32 *lenp) +const struct dt_property *dt_find_property(const struct dt_device_node *np, + const char *name, u32 *lenp) { const struct dt_property *pp; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 9a8c3de..7c075d9 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -15,6 +15,7 @@ #include #include #include +#include #define DEVICE_TREE_MAX_DEPTH 16 @@ -347,6 +348,10 @@ struct dt_device_node *dt_find_compatible_node(struct dt_device_node *from, const void *dt_get_property(const struct dt_device_node *np, const char *name, u32 *lenp); +const struct dt_property *dt_find_property(const struct dt_device_node *np, + const char *name, u32 *lenp); + + /** * dt_property_read_u32 - Helper to read a u32 property. * @np: node to get the value @@ -369,6 +374,22 @@ bool_t dt_property_read_u64(const struct dt_device_node *np, const char *name, u64 *out_value); /** + * dt_property_read_bool - Check if a property exists + * @np: node to get the value + * @name: name of the property + * + * Search for a property in a device node. + * Return true if the property exists false otherwise. + */ +static inline bool_t dt_property_read_bool(const struct dt_device_node *np, + const char *name) +{ + const struct dt_property *prop = dt_find_property(np, name, NULL); + + return prop ? true : false; +} + +/** * dt_property_read_string - Find and read a string from a property * @np: Device node from which the property value is to be read * @propname: Name of the property to be searched