From patchwork Wed Nov 7 05:39:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 994121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42qZzT25s7z9sCX for ; Wed, 7 Nov 2018 16:41:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42qZzT0DzRzF3Gn for ; Wed, 7 Nov 2018 16:41:41 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42qZxd31DqzF3GP for ; Wed, 7 Nov 2018 16:40:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42qZxc70Gmz9s8T; Wed, 7 Nov 2018 16:40:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Wed, 7 Nov 2018 16:39:42 +1100 Message-Id: <20181107053943.4307-16-alistair@popple.id.au> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181107053943.4307-1-alistair@popple.id.au> References: <20181107053943.4307-1-alistair@popple.id.au> Subject: [Pdbg] [PATCH v2 15/16] libpdbg: Make dt_root private X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amitay@ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/device.c | 13 +++++++++---- libpdbg/device.h | 2 -- libpdbg/target.c | 9 ++------- src/main.c | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index acc6da2..8e58135 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -36,7 +36,7 @@ /* Used to give unique handles. */ static u32 last_phandle = 0; -struct pdbg_target *dt_root; +static struct pdbg_target *pdbg_dt_root; /* * An in-memory representation of a node in the device tree. @@ -590,7 +590,7 @@ static void dt_expand(const void *fdt) { PR_DEBUG("FDT: Parsing fdt @%p\n", fdt); - if (dt_expand_node(dt_root, fdt, 0) < 0) + if (dt_expand_node(pdbg_dt_root, fdt, 0) < 0) abort(); } @@ -636,7 +636,7 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *out_size) void pdbg_targets_init(void *fdt) { - dt_root = dt_new_node("", NULL, 0); + pdbg_dt_root = dt_new_node("", NULL, 0); dt_expand(fdt); } @@ -648,7 +648,12 @@ char *pdbg_target_path(const struct pdbg_target *target) struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path) { if (!target) - target = dt_root; + target = pdbg_dt_root; return dt_find_by_path(target, path); } + +struct pdbg_target *pdbg_target_root(void) +{ + return pdbg_dt_root; +} diff --git a/libpdbg/device.h b/libpdbg/device.h index 92d7da3..4a4a06f 100644 --- a/libpdbg/device.h +++ b/libpdbg/device.h @@ -23,6 +23,4 @@ /* Any property or node with this prefix will not be passed to the kernel. */ #define DT_PRIVATE "skiboot," -extern struct pdbg_target *dt_root; - #endif /* __DEVICE_H */ diff --git a/libpdbg/target.c b/libpdbg/target.c index 5599d78..5ebe71d 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -31,7 +31,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con /* The root node doesn't have an address space so it's * an error in the device tree if we hit this. */ - assert(target != dt_root); + assert(target != pdbg_target_root()); } return target; @@ -365,7 +365,7 @@ void pdbg_target_probe_all(struct pdbg_target *parent) struct pdbg_target *child; if (!parent) - parent = dt_root; + parent = pdbg_target_root(); pdbg_for_each_child_target(parent, child) { pdbg_target_probe_all(child); @@ -389,8 +389,3 @@ void pdbg_target_priv_set(struct pdbg_target *target, void *priv) { target->priv = priv; } - -struct pdbg_target *pdbg_target_root(void) -{ - return dt_root; -} diff --git a/src/main.c b/src/main.c index 40fa48b..5d0c0e3 100644 --- a/src/main.c +++ b/src/main.c @@ -791,7 +791,7 @@ OPTCMD_DEFINE_CMD(probe, probe); */ static void atexit_release(void) { - pdbg_target_release(dt_root); + pdbg_target_release(pdbg_target_root()); } int main(int argc, char *argv[])