summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril Bur <cyrilbur@gmail.com>2018-02-14 15:27:40 +1100
committerAlistair Popple <alistair@popple.id.au>2018-02-16 16:22:23 +1100
commit7407afd8b49f4ce178b6b5acd5b95044838b1482 (patch)
treed0ae9f461b06e581e79a767ab58e645aad703b22
parentc4ebabd885ab47b75f32a3ff7f22a7919b334764 (diff)
downloadpdbg-7407afd8b49f4ce178b6b5acd5b95044838b1482.tar.gz
pdbg-7407afd8b49f4ce178b6b5acd5b95044838b1482.zip
libpdbg/htm: Both `chtm` and `nhtm` classes are valid
Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
-rw-r--r--libpdbg/htm.c6
-rw-r--r--libpdbg/target.c8
-rw-r--r--libpdbg/target.h1
3 files changed, 13 insertions, 2 deletions
diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index 33fe64c..692b4e0 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -168,8 +168,10 @@ struct htm_status {
static struct htm *check_and_convert(struct pdbg_target *target)
{
- if (strcmp(target->class, "nhtm"))
- return NULL;
+
+ if (!pdbg_target_is_class(target, "nhtm") &&
+ !pdbg_target_is_class(target, "chtm"))
+ return NULL;
return target_to_htm(target);
}
diff --git a/libpdbg/target.c b/libpdbg/target.c
index c34271b..1eb85bb 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -347,3 +347,11 @@ void pdbg_target_probe(void)
dt_for_each_node(dt_root, dn)
_target_probe(dn);
}
+
+bool pdbg_target_is_class(struct pdbg_target *target, const char *class)
+{
+ if (!target || !target->class || !class)
+ return false;
+ return strcmp(target->class, class) == 0;
+}
+
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 2ae0106..0a618e2 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -51,6 +51,7 @@ struct pdbg_target {
struct pdbg_target *require_target_parent(struct pdbg_target *target);
struct pdbg_target_class *find_target_class(const char *name);
struct pdbg_target_class *require_target_class(const char *name);
+bool pdbg_target_is_class(struct pdbg_target *target, const char *class);
extern struct list_head empty_list;
#define for_each_class_target(class_name, target) \
OpenPOWER on IntegriCloud