summaryrefslogtreecommitdiff
path: root/modules/devices/devicetree
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-19 21:46:44 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-07-21 05:14:20 -0700
commit9729be79a1941a38d0e57faebd688f66fb2faf30 (patch)
treec6f060610d125ad349d25f1531e001bcd6fbf6e9 /modules/devices/devicetree
parentcb445b8b1458cc2e2e09bfe6b4f999f3ed8b684d (diff)
device tree: add seperate prefix and unprefixed name in dtr_obj
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices/devicetree')
-rw-r--r--modules/devices/devicetree/dt_util.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/devices/devicetree/dt_util.c b/modules/devices/devicetree/dt_util.c
index f5b791e6..2a567eac 100644
--- a/modules/devices/devicetree/dt_util.c
+++ b/modules/devices/devicetree/dt_util.c
@@ -70,7 +70,9 @@ struct _dtr_obj {
char *name;
uint32_t length;
int type;
- const char *alias; /* null until first dtr_obj_alias(). do not free */
+ char *prefix; /* if the name has a manufacturer's prefix or null */
+ char *np_name; /* the name without any prefix. points into .prefix or .name, do not free */
+ const char *alias; /* null until first dtr_obj_alias(). do not free */
const char *symbol; /* null until first dtr_obj_symbol(). do not free */
dtr *dt;
};
@@ -253,7 +255,7 @@ const char *dtr_base_path(dtr *s) {
/*glib, but _dt_obj *prop uses malloc() and std types */
dtr_obj *dtr_obj_read(dtr *s, const char *dtp) {
char *full_path;
- char *slash;
+ char *slash, *coma;
dtr_obj *obj;
if (dtp == NULL)
@@ -283,6 +285,19 @@ dtr_obj *dtr_obj_read(dtr *s, const char *dtp) {
else
obj->name = strdup(obj->path);
+ /* find manufacturer prefix */
+ obj->prefix = strdup(obj->name);
+ coma = strchr(obj->prefix, ',');
+ if (coma != NULL) {
+ /* coma -> null; .np_name starts after */
+ *coma = 0;
+ obj->np_name = coma + 1;
+ } else {
+ obj->np_name = obj->name;
+ free(obj->prefix);
+ obj->prefix = NULL;
+ }
+
/* read data */
full_path = g_strdup_printf("%s%s", s->base_path, obj->path);
if ( g_file_test(full_path, G_FILE_TEST_IS_DIR) ) {
@@ -306,6 +321,7 @@ void dtr_obj_free(dtr_obj *s) {
if (s != NULL) {
free(s->path);
free(s->name);
+ free(s->prefix);
free(s->data);
free(s);
}