From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH v3 03/13] xen/dts: Add dt_property_read_bool Date: Tue, 11 Mar 2014 15:49:49 +0000 Message-ID: <1394552999-14171-4-git-send-email-julien.grall@linaro.org> References: <1394552999-14171-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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: by mail-wi0-f176.google.com with SMTP id hr14so1100462wib.3 for ; Tue, 11 Mar 2014 08:50:13 -0700 (PDT) In-Reply-To: <1394552999-14171-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org 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 -- 1.7.10.4