[Pdbg] [PATCH 04/10] libpdbg: Rename property functions

Alistair Popple alistair at popple.id.au
Thu Oct 25 17:21:25 AEDT 2018


Some of the functions dealing with target properties have somewhat
inconsistent naming. This patch renames them and adds #defines for
backwards compatibility for external projects. These will be removed
once older projects have moved over to the new names.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 libpdbg/device.c  |  6 +++---
 libpdbg/libpdbg.c |  4 ++--
 libpdbg/libpdbg.h | 13 ++++++++++---
 libpdbg/xbus.c    |  2 +-
 src/main.c        |  2 +-
 5 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 51ae028..2128fa7 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -375,7 +375,7 @@ static void dt_resize_property(struct dt_property **prop, size_t len)
 	(*prop)->list.prev->next = &(*prop)->list;
 }
 
-void pdbg_set_target_property(struct pdbg_target *target, const char *name, const void *val, size_t size)
+void pdbg_target_set_property(struct pdbg_target *target, const char *name, const void *val, size_t size)
 {
 	struct dt_property *p;
 
@@ -391,7 +391,7 @@ void pdbg_set_target_property(struct pdbg_target *target, const char *name, cons
 	}
 }
 
-void *pdbg_get_target_property(struct pdbg_target *target, const char *name, size_t *size)
+void *pdbg_target_property(struct pdbg_target *target, const char *name, size_t *size)
 {
 	struct dt_property *p;
 
@@ -634,7 +634,7 @@ static void dt_expand(const void *fdt)
 		abort();
 }
 
-u64 dt_get_number(const void *pdata, unsigned int cells)
+static u64 dt_get_number(const void *pdata, unsigned int cells)
 {
 	const u32 *p = pdata;
 	u64 ret = 0;
diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index 3c96d3a..edf303c 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -140,12 +140,12 @@ uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size)
 	return dt_get_address(target, 0, size);
 }
 
-int pdbg_get_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val)
+int pdbg_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val)
 {
         uint32_t *p;
         size_t size;
 
-        p = pdbg_get_target_property(target, name, &size);
+        p = pdbg_target_property(target, name, &size);
         if (!p)
                 return -1;
 
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index a86265a..78930e9 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -68,13 +68,20 @@ struct pdbg_target *pdbg_target_parent(const char *klass, struct pdbg_target *ta
 struct pdbg_target *pdbg_target_require_parent(const char *klass, struct pdbg_target *target);
 
 /* Set the given property. Will automatically add one if one doesn't exist */
-void pdbg_set_target_property(struct pdbg_target *target, const char *name, const void *val, size_t size);
+void pdbg_target_set_property(struct pdbg_target *target, const char *name, const void *val, size_t size);
 
 /* Get the given property and return the size */
-void *pdbg_get_target_property(struct pdbg_target *target, const char *name, size_t *size);
-int pdbg_get_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val);
+void *pdbg_target_property(struct pdbg_target *target, const char *name, size_t *size);
+int pdbg_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val);
 uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size);
 
+/* Old deprecated for names for the above. Do not use for new projects
+ * as these will be removed at some future point. */
+#define pdbg_set_target_property(target, name, val, size)	\
+	pdbg_target_set_property(target, name, val, size)
+#define pdbg_get_target_property(target, name, size) \
+	pdbg_target_property(target, name, size)
+
 /* Misc. */
 void pdbg_targets_init(void *fdt);
 void pdbg_target_probe_all(struct pdbg_target *parent);
diff --git a/libpdbg/xbus.c b/libpdbg/xbus.c
index 69489bb..661b9a3 100644
--- a/libpdbg/xbus.c
+++ b/libpdbg/xbus.c
@@ -41,7 +41,7 @@ static int xbus_probe(struct pdbg_target *target)
 {
 	struct xbus *xbus = target_to_xbus(target);
 
-	if (pdbg_get_target_u32_property(&xbus->target, "ring-id", &xbus->ring_id)) {
+	if (pdbg_target_u32_property(&xbus->target, "ring-id", &xbus->ring_id)) {
 		printf("Unknown ring-id on %s@%d\n", pdbg_target_name(&xbus->target),
 		       pdbg_target_index(&xbus->target));
 		return -1;
diff --git a/src/main.c b/src/main.c
index 4966d51..faa4868 100644
--- a/src/main.c
+++ b/src/main.c
@@ -675,7 +675,7 @@ static int target_selection(void)
 		int proc_index = pdbg_target_index(pib);
 
 		if (backend == I2C && device_node)
-			pdbg_set_target_property(pib, "bus", device_node, strlen(device_node) + 1);
+			pdbg_target_set_property(pib, "bus", device_node, strlen(device_node) + 1);
 
 		if (processorsel[proc_index]) {
 			target_select(pib);
-- 
2.11.0



More information about the Pdbg mailing list