From patchwork Fri Jun 24 22:47:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 640465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rbtnW2L0pz9s0M for ; Sat, 25 Jun 2016 08:49:51 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rbtnW1T3bzDqnG for ; Sat, 25 Jun 2016 08:49:51 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rbtm261Q3zDqlV for ; Sat, 25 Jun 2016 08:48:34 +1000 (AEST) Received: from pasglop.au.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id u5OMm2Mk022384; Fri, 24 Jun 2016 17:48:29 -0500 From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Sat, 25 Jun 2016 08:47:34 +1000 Message-Id: <1466808476-32690-11-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466808476-32690-1-git-send-email-benh@kernel.crashing.org> References: <1466808476-32690-1-git-send-email-benh@kernel.crashing.org> Subject: [Skiboot] [PATCH 11/33] devicetree: Add dt_node_is_enabled() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This accessor tests the "status" property allowing us to represent disabled devices in the device-tree. It will be used by PHB4 initially but its usage could be made more widespread. Signed-off-by: Benjamin Herrenschmidt Acked-by: Michael Neuling --- core/device.c | 10 ++++++++++ include/device.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/core/device.c b/core/device.c index 4818d40..9e7ef0d 100644 --- a/core/device.c +++ b/core/device.c @@ -910,3 +910,13 @@ u64 dt_translate_address(const struct dt_node *node, unsigned int index, /* XXX TODO */ return dt_get_address(node, index, out_size); } + +bool dt_node_is_enabled(struct dt_node *node) +{ + const struct dt_property *p = dt_find_property(node, "status"); + + if (!p) + return true; + + return p->len > 1 && p->prop[0] == 'o' && p->prop[1] == 'k'; +} diff --git a/include/device.h b/include/device.h index 28dbd5d..ed4fc46 100644 --- a/include/device.h +++ b/include/device.h @@ -161,6 +161,8 @@ struct dt_node *dt_find_compatible_node_on_chip(struct dt_node *root, for (node = NULL; \ (node = dt_find_compatible_node_on_chip(root, node,\ compat, chip_id)) != NULL;) +/* Check status property */ +bool dt_node_is_enabled(struct dt_node *node); /* Build the full path for a node. Return a new block of memory, caller * shall free() it