summaryrefslogtreecommitdiffstats
path: root/libpdbg
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2017-06-22 17:00:46 +1000
committerAlistair Popple <alistair@popple.id.au>2017-06-28 16:07:28 +1000
commit602f056021f67960b1f76f2984aea9d21eeaefbd (patch)
tree3be34d888c693af3e27b223cb8166f51582eb2c4 /libpdbg
parentd4f73e9be6356279fc02be62b42b6bd35bff4717 (diff)
downloadpdbg-602f056021f67960b1f76f2984aea9d21eeaefbd.tar.gz
pdbg-602f056021f67960b1f76f2984aea9d21eeaefbd.zip
libpdbg: Add target index cache
The target index is needed multiple times by code using the library. Rather than requiring parsing the device-tree each time it makes sense to cache the parsed value in the struct target. Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'libpdbg')
-rw-r--r--libpdbg/target.c3
-rw-r--r--libpdbg/target.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/libpdbg/target.c b/libpdbg/target.c
index a4e54d2..c733dad 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -173,6 +173,7 @@ void targets_init(void *fdt)
struct hw_unit_info *hw_unit_info;
void *new_hw_unit;
struct target *new_target;
+ uint32_t index;
dt_root = dt_new_root("");
dt_expand(fdt);
@@ -191,6 +192,8 @@ void targets_init(void *fdt)
new_target = new_hw_unit + hw_unit_info->struct_target_offset;
new_target->dn = dn;
dn->target = new_target;
+ index = dt_prop_get_u32_def(dn, "index", -1);
+ dn->target->index = index;
target_class = get_target_class(new_target->class);
list_add(&target_class->targets, &new_target->class_link);
PR_DEBUG("Found target %s for %s\n", new_target->name, dn->name);
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 76982e8..651ab3c 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -42,6 +42,7 @@ struct target {
char *compatible;
char *class;
int (*probe)(struct target *target);
+ int index;
struct dt_node *dn;
struct list_node class_link;
};
OpenPOWER on IntegriCloud