All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] add alias support to fdt_path_offset
@ 2008-08-04 22:25 Kumar Gala
       [not found] ` <Pine.LNX.4.64.0808041722001.328-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Kumar Gala @ 2008-08-04 22:25 UTC (permalink / raw)
  To: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A
  Cc: gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w

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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC] add alias support to fdt_path_offset
       [not found] ` <Pine.LNX.4.64.0808041722001.328-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>
@ 2008-08-05  3:58   ` David Gibson
       [not found]     ` <20080805035844.GB16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: David Gibson @ 2008-08-05  3:58 UTC (permalink / raw)
  To: Kumar Gala
  Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w

On Mon, Aug 04, 2008 at 05:25:17PM -0500, Kumar Gala wrote:
> 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.

That's because you haven't thought hard enough, we can do better than
this.  Patches coming..

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] add alias support to fdt_path_offset
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: M. Warner Losh @ 2008-08-05  4:02 UTC (permalink / raw)
  To: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+
  Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w

In message: <20080805035844.GB16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
            David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> writes:
: On Mon, Aug 04, 2008 at 05:25:17PM -0500, Kumar Gala wrote:
: > 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.
: 
: That's because you haven't thought hard enough, we can do better than
: this.  Patches coming..

Hmmm, PATH_MAX...

Warner

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] add alias support to fdt_path_offset
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: David Gibson @ 2008-08-05  4:13 UTC (permalink / raw)
  To: M. Warner Losh
  Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w

On Mon, Aug 04, 2008 at 10:02:26PM -0600, M. Warner Losh wrote:
> In message: <20080805035844.GB16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
>             David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> writes:
> : On Mon, Aug 04, 2008 at 05:25:17PM -0500, Kumar Gala wrote:
> : > 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.
> : 
> : That's because you haven't thought hard enough, we can do better than
> : this.  Patches coming..
> 
> Hmmm, PATH_MAX...

No.  We can do better than that, too.  Though admittedly it will be
slightly more work than I first thought.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] add alias support to fdt_path_offset
       [not found]             ` <20080805041306.GC16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
@ 2008-08-05  6:26               ` Kumar Gala
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2008-08-05  6:26 UTC (permalink / raw)
  To: David Gibson
  Cc: devicetree-discuss-mnsaURCQ41sdnm+yROfE0A,
	gvb.uboot-Re5JQEeQqe8AvxtiuMwx3w


On Aug 4, 2008, at 11:13 PM, David Gibson wrote:

> On Mon, Aug 04, 2008 at 10:02:26PM -0600, M. Warner Losh wrote:
>> In message: <20080805035844.GB16526-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
>>            David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> writes:
>> : On Mon, Aug 04, 2008 at 05:25:17PM -0500, Kumar Gala wrote:
>> : > 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.
>> :
>> : That's because you haven't thought hard enough, we can do better  
>> than
>> : this.  Patches coming..
>>
>> Hmmm, PATH_MAX...
>
> No.  We can do better than that, too.  Though admittedly it will be
> slightly more work than I first thought.

I was going with brute force to get something out there for us to play  
with :)

- k

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-05  6:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 22:25 [RFC] add alias support to fdt_path_offset Kumar Gala
     [not found] ` <Pine.LNX.4.64.0808041722001.328-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>
2008-08-05  3:58   ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.