[Pdbg] [PATCH v2 15/16] libpdbg: Make dt_root private
Amitay Isaacs
amitay at ozlabs.org
Wed Nov 7 18:12:28 AEDT 2018
Reviewed-by: Amitay Isaacs <amitay at ozlabs.org>
On Wed, 2018-11-07 at 16:39 +1100, Alistair Popple wrote:
> Signed-off-by: Alistair Popple <alistair at popple.id.au>
> ---
> 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[])
> --
> 2.11.0
>
Amitay.
--
Send someone a telegram that reads "Congratulations." Regardless of who he
is, he'll think he's done something the past week to deserve it.
More information about the Pdbg
mailing list