From: Kumar Gala <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
To: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org
Cc: gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: [RFC] add alias support to fdt_path_offset
Date: Mon, 4 Aug 2008 17:25:17 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0808041722001.328@blarg.am.freescale.net> (raw)
Here's my attempt at adding alias support to fdt_path_offset()
I don't care for the path_buf[256], but not sure how else to do that.
(this is based on discussion on the u-boot list).
- k
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 69af7bb..1cc5bc6 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -135,8 +135,37 @@ int fdt_path_offset(const void *fdt, const char *path)
CHECK_HEADER(fdt);
- if (*path != '/')
- return -FDT_ERR_BADPATH;
+ /* see if we have an alias */
+ if (*path != '/') {
+ int i = 0, aliasoffset = fdt_path_offset(fdt, "/aliases");
+ char path_buf[256];
+ const char *q;
+
+ if (aliasoffset < 0)
+ return -FDT_ERR_BADPATH;
+
+ q = strchr(path, '/');
+ if (!q)
+ q = end;
+
+ while (p != q)
+ path_buf[i++] = *p++;
+ path_buf[i] = '\0';
+
+ p = fdt_getprop(fdt, aliasoffset, path_buf, NULL);
+
+ if (!p)
+ return -FDT_ERR_BADPATH;
+
+ i = 0;
+ while (*p)
+ path_buf[i++] = *p++;
+ while (*q)
+ path_buf[i++] = *q++;
+ path_buf[i] = '\0';
+
+ return fdt_path_offset(fdt, path_buf);
+ }
while (*p) {
const char *q;
next reply other threads:[~2008-08-04 22:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-04 22:25 Kumar Gala [this message]
[not found] ` <Pine.LNX.4.64.0808041722001.328-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>
2008-08-05 3:58 ` [RFC] add alias support to fdt_path_offset David Gibson
[not found] ` <20080805035844.GB16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
2008-08-05 4:02 ` M. Warner Losh
[not found] ` <20080804.220226.-1219852411.imp-uzTCJ5RojNnQT0dZR+AlfA@public.gmane.org>
2008-08-05 4:13 ` David Gibson
[not found] ` <20080805041306.GC16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
2008-08-05 6:26 ` Kumar Gala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0808041722001.328@blarg.am.freescale.net \
--to=galak-xvmvhmargas8u2djnn8i7kb+6bgklq7r@public.gmane.org \
--cc=devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
--cc=gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox