From patchwork Fri Feb 7 17:43:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 24303 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 661F22096A for ; Fri, 7 Feb 2014 17:43:34 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp4sf14955849obc.5 for ; Fri, 07 Feb 2014 09:43:33 -0800 (PST) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=XWqALXRj576Gk9ZaYAsA1jX5pC5564URrjKEcU85iMQ=; b=ZxC3cWenjzwqKGYJXLGz8DfjoMwArSNFpZaL4lNSV3nxCly7KQbBVYlcOTFy3z6/FL 6RIUqb/Ahtgttd9OpInqaiBVnx29SbjRfN6JIQxFar55CnOXfpTuG1YgQaA6CfdQuIzc fBTAeS1+9D9dgiEOLV/2ujEUmnlpXO0GY/neE5raWItTwy/afQwlzrRW5hyb8134VRbJ 4j1J9krfr2froIQQvmgTvVCCUrzU5LKssIWAdqEGgyaO4z32O3rLCJToJc1a5QCj6dH1 Ux2M1foh0wMKDxrHByZ9en/PFcg6SEeniStwMJBhTsFWvwQzWN2M9PW0HuVTvgXUkrpb hdnw== X-Gm-Message-State: ALoCoQkT6DaVgYkKMwHfZ5jKzQHQc60Rn1UzIzQuIlQCliwAKq0bThe9aflfIUlHN6dS8BkivHoW X-Received: by 10.182.246.39 with SMTP id xt7mr6589778obc.40.1391795013477; Fri, 07 Feb 2014 09:43:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.49 with SMTP id 46ls1126700qgq.21.gmail; Fri, 07 Feb 2014 09:43:33 -0800 (PST) X-Received: by 10.58.209.36 with SMTP id mj4mr72419vec.47.1391795013335; Fri, 07 Feb 2014 09:43:33 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id a8si1544515vej.93.2014.02.07.09.43.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Feb 2014 09:43:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so2988730veb.21 for ; Fri, 07 Feb 2014 09:43:33 -0800 (PST) X-Received: by 10.58.252.8 with SMTP id zo8mr31483vec.55.1391795013262; Fri, 07 Feb 2014 09:43:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp123588vcz; Fri, 7 Feb 2014 09:43:32 -0800 (PST) X-Received: by 10.14.95.2 with SMTP id o2mr5745629eef.69.1391795009566; Fri, 07 Feb 2014 09:43:29 -0800 (PST) Received: from mail-ea0-f175.google.com (mail-ea0-f175.google.com [209.85.215.175]) by mx.google.com with ESMTPS id y5si9571253eee.123.2014.02.07.09.43.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Feb 2014 09:43:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.175 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.175; Received: by mail-ea0-f175.google.com with SMTP id z10so1719227ead.20 for ; Fri, 07 Feb 2014 09:43:29 -0800 (PST) X-Received: by 10.14.203.197 with SMTP id f45mr4543645eeo.90.1391795008955; Fri, 07 Feb 2014 09:43:28 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id 8sm18849063eef.1.2014.02.07.09.43.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2014 09:43:28 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [RFC for-4.5 04/12] xen/dts: Add dt_property_read_bool Date: Fri, 7 Feb 2014 17:43:03 +0000 Message-Id: <1391794991-5919-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391794991-5919-1-git-send-email-julien.grall@linaro.org> References: <1391794991-5919-1-git-send-email-julien.grall@linaro.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.176 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The function check if property exists in a specific node. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- 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