From patchwork Tue Apr 22 13:14:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 28804 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 92E83203AC for ; Tue, 22 Apr 2014 13:16:16 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id v10sf1763722pde.11 for ; Tue, 22 Apr 2014 06:16:15 -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=8yoqKdob/onlrEjwZKqqgIZBvXGqUftMbLAxg+OqDb4=; b=d4N5yXYCX2ZgvF9OTuORX5o/02fnYZjJ5FojSjRUI5RlpIhw3GRutrXPWr75qCTJ8S fp2DSWG+2ODoD2+jZYHJQJUsbkxJW8To4KEoNakuXiSojc8sdKQu5dCjs/4YI/LKpen8 qDpfCHAR9VpNm73we5TKgC6bHi+7bc/G6mo50Ebno94yNgPI9z55YqS+Cv9RYGCMD+E7 O5LcQhXUlDNnAyq3DdrA14XiCzPgUqSz8cfwMgBEmWuYcpYFvyNOItJAQzZWP2ZgfVmG +Ky3k0Ly69uECRE/DtE96KtgiMxZ97i6whoOZ4fFwlQTvcdm6iQpiT+8VaV26fzF2QHN ijNQ== X-Gm-Message-State: ALoCoQmn+l4nbYefQ1A4PRFoDEBNVbP4mZH2NRLJQcY+7u64sgzP6w0ff7c4D60HeL9OyS/hTugx X-Received: by 10.66.148.10 with SMTP id to10mr21970694pab.12.1398172575827; Tue, 22 Apr 2014 06:16:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.70 with SMTP id u64ls97574qgd.80.gmail; Tue, 22 Apr 2014 06:16:15 -0700 (PDT) X-Received: by 10.58.181.170 with SMTP id dx10mr7682857vec.25.1398172575653; Tue, 22 Apr 2014 06:16:15 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id dr8si6898197vcb.13.2014.04.22.06.16.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 06:16:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so9419300veb.18 for ; Tue, 22 Apr 2014 06:16:15 -0700 (PDT) X-Received: by 10.52.230.161 with SMTP id sz1mr36299vdc.64.1398172575494; Tue, 22 Apr 2014 06:16:15 -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.221.72 with SMTP id ib8csp23844vcb; Tue, 22 Apr 2014 06:16:15 -0700 (PDT) X-Received: by 10.50.112.202 with SMTP id is10mr29398486igb.7.1398172574700; Tue, 22 Apr 2014 06:16:14 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id la8si11999424igb.40.2014.04.22.06.16.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Apr 2014 06:16:13 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) 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 1WcaXN-0005yc-FC; Tue, 22 Apr 2014 13:15:01 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WcaXK-0005uE-Hi for xen-devel@lists.xenproject.org; Tue, 22 Apr 2014 13:14:58 +0000 Received: from [85.158.139.211:37866] by server-2.bemta-5.messagelabs.com id 07/26-12074-15B66535; Tue, 22 Apr 2014 13:14:57 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1398172496!2839168!1 X-Originating-IP: [74.125.83.52] 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 24731 invoked from network); 22 Apr 2014 13:14:57 -0000 Received: from mail-ee0-f52.google.com (HELO mail-ee0-f52.google.com) (74.125.83.52) by server-14.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Apr 2014 13:14:57 -0000 Received: by mail-ee0-f52.google.com with SMTP id e49so4603238eek.39 for ; Tue, 22 Apr 2014 06:14:56 -0700 (PDT) X-Received: by 10.14.200.131 with SMTP id z3mr2198229een.109.1398172496848; Tue, 22 Apr 2014 06:14:56 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id 45sm112969867eeh.9.2014.04.22.06.14.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 06:14:56 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 22 Apr 2014 14:14:23 +0100 Message-Id: <1398172475-27873-10-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> References: <1398172475-27873-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 v4 09/21] 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.173 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 74425ab..016aecf 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 76faf11..9c396ee 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 @@ -348,6 +349,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 @@ -370,6 +375,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