mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: find also nodes by mixture of alias and path
@ 2013-12-19  8:39 Jan Weitzel
  2013-12-20 13:24 ` [PATCH v2] " Jan Weitzel
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Weitzel @ 2013-12-19  8:39 UTC (permalink / raw)
  To: barebox

Let of_find_node_by_path_or_alias also find a node starting with an alias
followed by a path like "i2c0/tps@24"

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
 drivers/of/base.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea2d879..dc3d459 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
 struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
 		const char *str)
 {
+	struct device_node *ret;
+	char *slash, *alias;
+	size_t len = 0;
+
 	if (*str ==  '/')
 		return of_find_node_by_path_from(root, str);
-	else
+
+	slash = _strchr(str, '/');
+
+	if (!slash)
 		return of_find_node_by_alias(root, str);
 
+	len = slash - str + 1;
+	alias = xmalloc(len);
+	strlcpy(alias, str, len);
+
+	ret = of_find_node_by_alias(root, alias);
+
+	if (!ret)
+		goto out;
+
+	ret = of_find_node_by_path_from(ret, slash);
+out:
+	free(alias);
+	return ret;
 }
 EXPORT_SYMBOL(of_find_node_by_path_or_alias);
 
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2] of: find also nodes by mixture of alias and path
  2013-12-19  8:39 [PATCH] of: find also nodes by mixture of alias and path Jan Weitzel
@ 2013-12-20 13:24 ` Jan Weitzel
  2014-01-06  9:32   ` Sascha Hauer
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Weitzel @ 2013-12-20 13:24 UTC (permalink / raw)
  To: barebox

Let of_find_node_by_path_or_alias also find a node starting with an alias
followed by a path like "i2c0/tps@24"

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
v2: rename ret to node

 drivers/of/base.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea2d879..5b5272d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
 struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
 		const char *str)
 {
+	struct device_node *node;
+	char *slash, *alias;
+	size_t len = 0;
+
 	if (*str ==  '/')
 		return of_find_node_by_path_from(root, str);
-	else
+
+	slash = _strchr(str, '/');
+
+	if (!slash)
 		return of_find_node_by_alias(root, str);
 
+	len = slash - str + 1;
+	alias = xmalloc(len);
+	strlcpy(alias, str, len);
+
+	node = of_find_node_by_alias(root, alias);
+
+	if (!node)
+		goto out;
+
+	node = of_find_node_by_path_from(node, slash);
+out:
+	free(alias);
+	return node;
 }
 EXPORT_SYMBOL(of_find_node_by_path_or_alias);
 
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] of: find also nodes by mixture of alias and path
  2013-12-20 13:24 ` [PATCH v2] " Jan Weitzel
@ 2014-01-06  9:32   ` Sascha Hauer
  2014-01-06 10:26     ` Jan Weitzel
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2014-01-06  9:32 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

Hi Jan,

On Fri, Dec 20, 2013 at 02:24:48PM +0100, Jan Weitzel wrote:
> Let of_find_node_by_path_or_alias also find a node starting with an alias
> followed by a path like "i2c0/tps@24"
> 
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> ---
> v2: rename ret to node
> 
>  drivers/of/base.c |   22 +++++++++++++++++++++-
>  1 files changed, 21 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index ea2d879..5b5272d 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
>  struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
>  		const char *str)
>  {
> +	struct device_node *node;
> +	char *slash, *alias;
> +	size_t len = 0;
> +
>  	if (*str ==  '/')
>  		return of_find_node_by_path_from(root, str);
> -	else
> +
> +	slash = _strchr(str, '/');

You should use regular strchr, not _strchr. Or is there any reason to do
it differently here?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] of: find also nodes by mixture of alias and path
  2014-01-06  9:32   ` Sascha Hauer
@ 2014-01-06 10:26     ` Jan Weitzel
  2014-01-06 10:50       ` Sascha Hauer
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Weitzel @ 2014-01-06 10:26 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Am Montag, den 06.01.2014, 10:32 +0100 schrieb Sascha Hauer:
> Hi Jan,
> 
> On Fri, Dec 20, 2013 at 02:24:48PM +0100, Jan Weitzel wrote:
> > Let of_find_node_by_path_or_alias also find a node starting with an alias
> > followed by a path like "i2c0/tps@24"
> > 
> > Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> > ---
> > v2: rename ret to node
> > 
> >  drivers/of/base.c |   22 +++++++++++++++++++++-
> >  1 files changed, 21 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/of/base.c b/drivers/of/base.c
> > index ea2d879..5b5272d 100644
> > --- a/drivers/of/base.c
> > +++ b/drivers/of/base.c
> > @@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
> >  struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
> >  		const char *str)
> >  {
> > +	struct device_node *node;
> > +	char *slash, *alias;
> > +	size_t len = 0;
> > +
> >  	if (*str ==  '/')
> >  		return of_find_node_by_path_from(root, str);
> > -	else
> > +
> > +	slash = _strchr(str, '/');
> 
> You should use regular strchr, not _strchr. Or is there any reason to do
> it differently here?
I got this from the strchr wrapper:

drivers/of/base.c: In function 'of_find_node_by_path_or_alias':
drivers/of/base.c:1388:8: warning: assignment discards 'const' qualifier
from pointer target type [enabled by default]

Is there a cleaner way?

Jan
> 
> Sascha
> 



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] of: find also nodes by mixture of alias and path
  2014-01-06 10:26     ` Jan Weitzel
@ 2014-01-06 10:50       ` Sascha Hauer
  2014-01-06 12:45         ` [PATCH v3] " Jan Weitzel
  2014-01-06 12:46         ` [PATCH v2] " Jan Weitzel
  0 siblings, 2 replies; 8+ messages in thread
From: Sascha Hauer @ 2014-01-06 10:50 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

On Mon, Jan 06, 2014 at 11:26:59AM +0100, Jan Weitzel wrote:
> Am Montag, den 06.01.2014, 10:32 +0100 schrieb Sascha Hauer:
> > Hi Jan,
> > 
> > On Fri, Dec 20, 2013 at 02:24:48PM +0100, Jan Weitzel wrote:
> > > Let of_find_node_by_path_or_alias also find a node starting with an alias
> > > followed by a path like "i2c0/tps@24"
> > > 
> > > Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> > > ---
> > > v2: rename ret to node
> > > 
> > >  drivers/of/base.c |   22 +++++++++++++++++++++-
> > >  1 files changed, 21 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/drivers/of/base.c b/drivers/of/base.c
> > > index ea2d879..5b5272d 100644
> > > --- a/drivers/of/base.c
> > > +++ b/drivers/of/base.c
> > > @@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
> > >  struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
> > >  		const char *str)
> > >  {
> > > +	struct device_node *node;
> > > +	char *slash, *alias;
> > > +	size_t len = 0;
> > > +
> > >  	if (*str ==  '/')
> > >  		return of_find_node_by_path_from(root, str);
> > > -	else
> > > +
> > > +	slash = _strchr(str, '/');
> > 
> > You should use regular strchr, not _strchr. Or is there any reason to do
> > it differently here?
> I got this from the strchr wrapper:
> 
> drivers/of/base.c: In function 'of_find_node_by_path_or_alias':
> drivers/of/base.c:1388:8: warning: assignment discards 'const' qualifier
> from pointer target type [enabled by default]
> 
> Is there a cleaner way?

Try making 'slash' const.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v3] of: find also nodes by mixture of alias and path
  2014-01-06 10:50       ` Sascha Hauer
@ 2014-01-06 12:45         ` Jan Weitzel
  2014-01-10  9:40           ` Sascha Hauer
  2014-01-06 12:46         ` [PATCH v2] " Jan Weitzel
  1 sibling, 1 reply; 8+ messages in thread
From: Jan Weitzel @ 2014-01-06 12:45 UTC (permalink / raw)
  To: barebox

Let of_find_node_by_path_or_alias also find a node starting with an alias
followed by a path like "i2c0/tps@24"

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
v2: rename ret to node
v3: use strchr
 drivers/of/base.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea2d879..6e5e7d6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path);
 struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
 		const char *str)
 {
+	struct device_node *node;
+	const char *slash;
+	char *alias;
+	size_t len = 0;
+
 	if (*str ==  '/')
 		return of_find_node_by_path_from(root, str);
-	else
+
+	slash = strchr(str, '/');
+
+	if (!slash)
 		return of_find_node_by_alias(root, str);
 
+	len = slash - str + 1;
+	alias = xmalloc(len);
+	strlcpy(alias, str, len);
+
+	node = of_find_node_by_alias(root, alias);
+
+	if (!node)
+		goto out;
+
+	node = of_find_node_by_path_from(node, slash);
+out:
+	free(alias);
+	return node;
 }
 EXPORT_SYMBOL(of_find_node_by_path_or_alias);
 
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] of: find also nodes by mixture of alias and path
  2014-01-06 10:50       ` Sascha Hauer
  2014-01-06 12:45         ` [PATCH v3] " Jan Weitzel
@ 2014-01-06 12:46         ` Jan Weitzel
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Weitzel @ 2014-01-06 12:46 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Am Montag, den 06.01.2014, 11:50 +0100 schrieb Sascha Hauer:
> On Mon, Jan 06, 2014 at 11:26:59AM +0100, Jan Weitzel wrote:
> > Am Montag, den 06.01.2014, 10:32 +0100 schrieb Sascha Hauer:
> > > Hi Jan,
> > > 
> > > On Fri, Dec 20, 2013 at 02:24:48PM +0100, Jan Weitzel wrote:
> > > > Let of_find_node_by_path_or_alias also find a node starting with an alias
> > > > followed by a path like "i2c0/tps@24"
> > > > 
> > > > Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
> > > > ---
> > > > v2: rename ret to node
> > > > 
> > > >  drivers/of/base.c |   22 +++++++++++++++++++++-
> > > >  1 files changed, 21 insertions(+), 1 deletions(-)
> > > > 
> > > > diff --git a/drivers/of/base.c b/drivers/of/base.c
> > > > index ea2d879..5b5272d 100644
> > > > --- a/drivers/of/base.c
> > > > +++ b/drivers/of/base.c
> > > > @@ -1378,11 +1378,31 @@ EXPORT_SYMBOL(of_find_node_by_path);
> > > >  struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
> > > >  		const char *str)
> > > >  {
> > > > +	struct device_node *node;
> > > > +	char *slash, *alias;
> > > > +	size_t len = 0;
> > > > +
> > > >  	if (*str ==  '/')
> > > >  		return of_find_node_by_path_from(root, str);
> > > > -	else
> > > > +
> > > > +	slash = _strchr(str, '/');
> > > 
> > > You should use regular strchr, not _strchr. Or is there any reason to do
> > > it differently here?
> > I got this from the strchr wrapper:
> > 
> > drivers/of/base.c: In function 'of_find_node_by_path_or_alias':
> > drivers/of/base.c:1388:8: warning: assignment discards 'const' qualifier
> > from pointer target type [enabled by default]
> > 
> > Is there a cleaner way?
> 
> Try making 'slash' const.
Arghh not *str ...
Thanks Jan

> 
> Sascha
> 



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v3] of: find also nodes by mixture of alias and path
  2014-01-06 12:45         ` [PATCH v3] " Jan Weitzel
@ 2014-01-10  9:40           ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2014-01-10  9:40 UTC (permalink / raw)
  To: Jan Weitzel; +Cc: barebox

On Mon, Jan 06, 2014 at 01:45:43PM +0100, Jan Weitzel wrote:
> Let of_find_node_by_path_or_alias also find a node starting with an alias
> followed by a path like "i2c0/tps@24"
> 
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>

Applied, thanks

Sascha

> ---
> v2: rename ret to node
> v3: use strchr
>  drivers/of/base.c |   23 ++++++++++++++++++++++-
>  1 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index ea2d879..6e5e7d6 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path);
>  struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
>  		const char *str)
>  {
> +	struct device_node *node;
> +	const char *slash;
> +	char *alias;
> +	size_t len = 0;
> +
>  	if (*str ==  '/')
>  		return of_find_node_by_path_from(root, str);
> -	else
> +
> +	slash = strchr(str, '/');
> +
> +	if (!slash)
>  		return of_find_node_by_alias(root, str);
>  
> +	len = slash - str + 1;
> +	alias = xmalloc(len);
> +	strlcpy(alias, str, len);
> +
> +	node = of_find_node_by_alias(root, alias);
> +
> +	if (!node)
> +		goto out;
> +
> +	node = of_find_node_by_path_from(node, slash);
> +out:
> +	free(alias);
> +	return node;
>  }
>  EXPORT_SYMBOL(of_find_node_by_path_or_alias);
>  
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-01-10  9:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-19  8:39 [PATCH] of: find also nodes by mixture of alias and path Jan Weitzel
2013-12-20 13:24 ` [PATCH v2] " Jan Weitzel
2014-01-06  9:32   ` Sascha Hauer
2014-01-06 10:26     ` Jan Weitzel
2014-01-06 10:50       ` Sascha Hauer
2014-01-06 12:45         ` [PATCH v3] " Jan Weitzel
2014-01-10  9:40           ` Sascha Hauer
2014-01-06 12:46         ` [PATCH v2] " Jan Weitzel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox