From patchwork Tue Mar 11 15:49:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 26039 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9D73A20068 for ; Tue, 11 Mar 2014 15:52:02 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf34023636obb.3 for ; Tue, 11 Mar 2014 08:52:02 -0700 (PDT) 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=Y1Y+8bPK2+gBXzyZr86iMDSbFsfF31XoKFuD+jA0l7YdT2PWHUnexFUhfAEzFpnV0D 5ublqEh3y/79X022NXupb3bQ0nai9WeHEJbamuhVNioQTwHn2BW2k0MGQ3TuMqD2tjAc chMvfjrExoJ8IWF/GGqLt/i9XZpYeaGlvcvAb9XczRIkH7xqWPfDxjfshzDt7SZLCnUO WMiG7p95vipXyLYTMnlimktciHBCMfZXj0Emu67O1Ku1sIsr3AXuHReacHhsO6S1X8UV gUHbejw0c2c66aiNrlgatAAiLbtfvgpvRRt9FnI49os95EZPTvTaEV3OJ9gpUchVA25b xcwA== X-Gm-Message-State: ALoCoQnfEvftGU5HN3Q1v3N2cGpfY+WPaIAgGXjlBZDA1e1UczDZqJgz8RSwi+5mG0Lgsw8UhE2M X-Received: by 10.50.222.103 with SMTP id ql7mr10190096igc.1.1394553122196; Tue, 11 Mar 2014 08:52:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.212 with SMTP id 78ls2605946qgt.30.gmail; Tue, 11 Mar 2014 08:52:02 -0700 (PDT) X-Received: by 10.58.236.234 with SMTP id ux10mr49779vec.60.1394553122050; Tue, 11 Mar 2014 08:52:02 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id ry8si6555707vdc.45.2014.03.11.08.52.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Mar 2014 08:52:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so8814206veb.33 for ; Tue, 11 Mar 2014 08:52:02 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr28540489vcb.16.1394553121964; Tue, 11 Mar 2014 08:52:01 -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.220.78.9 with SMTP id i9csp215077vck; Tue, 11 Mar 2014 08:52:01 -0700 (PDT) X-Received: by 10.140.101.244 with SMTP id u107mr2587569qge.107.1394553120769; Tue, 11 Mar 2014 08:52:00 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k3si4482785qcz.55.2014.03.11.08.52.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 08:52:00 -0700 (PDT) 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 1WNOwZ-0006n1-W4; Tue, 11 Mar 2014 15:50:16 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNOwZ-0006mq-1E for xen-devel@lists.xenproject.org; Tue, 11 Mar 2014 15:50:15 +0000 Received: from [193.109.254.147:21687] by server-1.bemta-14.messagelabs.com id E0/57-29588-6B03F135; Tue, 11 Mar 2014 15:50:14 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1394553013!933070!1 X-Originating-IP: [209.85.212.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8920 invoked from network); 11 Mar 2014 15:50:13 -0000 Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 11 Mar 2014 15:50:13 -0000 Received: by mail-wi0-f176.google.com with SMTP id hr14so1100462wib.3 for ; Tue, 11 Mar 2014 08:50:13 -0700 (PDT) X-Received: by 10.194.204.199 with SMTP id la7mr33892578wjc.4.1394553013180; Tue, 11 Mar 2014 08:50:13 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id bm8sm62454537wjc.12.2014.03.11.08.50.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Mar 2014 08:50:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 11 Mar 2014 15:49:49 +0000 Message-Id: <1394552999-14171-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394552999-14171-1-git-send-email-julien.grall@linaro.org> References: <1394552999-14171-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 v3 03/13] 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.128.174 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