Re: [U-Boot] [PATCH] dm: check OF_LIVE is enabled

2019-03-18 Thread Simon Glass
Hi Ibai,

On Tue, 12 Mar 2019 at 15:19, Ibai Erkiaga Elorza  wrote:
>
> Hi Simon,
>
> > -Original Message-
> > From: Simon Glass 
> > Sent: 10 March 2019 21:51
> > To: Ibai Erkiaga Elorza 
> > Cc: U-Boot Mailing List ; Patrick Delaunay
> > ; Andy Shevchenko
> > ; Bin Meng ;
> > Patrice Chotard 
> > Subject: Re: [U-Boot][PATCH] dm: check OF_LIVE is enabled
> >
> > Hi Ibai,
> >
> > On Tue, 26 Feb 2019 at 02:26, Ibai Erkiaga 
> > wrote:
> > >
> > > Livetree implemented functions does not have conditional compilation
> > > so check if CONFIG_IS_ENABLED prior using those functions.
> > >
> > > The issue does not report any error in a normal build as the toolchain
> > > optimize the code. Using -O0 triggers the error so the patch is
> > > intended to fix issues on a ongoing effor to build U-Boot with -O0.
> > >
> > > Signed-off-by: Ibai Erkiaga 
> > > ---
> > >
> > >  drivers/core/ofnode.c  | 60 
> > > +-
> > >  drivers/serial/serial-uclass.c |  2 +-
> > >  2 files changed, 31 insertions(+), 31 deletions(-)
> > >
> >
> > This is supposed to work by using of_live_active(), which is called from
> > ofnode_is_np(). Instead of changing all this code, is it possible to update
> > of_live_active() somehow?
> >
>
> I've been trying to figure out it but I think there is no way just changing 
> of_live_active as the compiler does not discard branch statements with nested 
> fixed return values. I was able to make it work just changing ofnode_is_np 
> using pre-processor macro to set as false when OF_LIVE is not enabled, but 
> not sure if it the right approach. I will take a deeper look to the entire OF 
> code and maybe suggest a code refactoring.

Just returning false when OF_LIVE is not enabled seems fine to me. You
can never have an ofnode if livetree is not enabled.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] dm: check OF_LIVE is enabled

2019-03-12 Thread Ibai Erkiaga Elorza
Hi Simon,

> -Original Message-
> From: Simon Glass 
> Sent: 10 March 2019 21:51
> To: Ibai Erkiaga Elorza 
> Cc: U-Boot Mailing List ; Patrick Delaunay
> ; Andy Shevchenko
> ; Bin Meng ;
> Patrice Chotard 
> Subject: Re: [U-Boot][PATCH] dm: check OF_LIVE is enabled
> 
> Hi Ibai,
> 
> On Tue, 26 Feb 2019 at 02:26, Ibai Erkiaga 
> wrote:
> >
> > Livetree implemented functions does not have conditional compilation
> > so check if CONFIG_IS_ENABLED prior using those functions.
> >
> > The issue does not report any error in a normal build as the toolchain
> > optimize the code. Using -O0 triggers the error so the patch is
> > intended to fix issues on a ongoing effor to build U-Boot with -O0.
> >
> > Signed-off-by: Ibai Erkiaga 
> > ---
> >
> >  drivers/core/ofnode.c  | 60 
> > +-
> >  drivers/serial/serial-uclass.c |  2 +-
> >  2 files changed, 31 insertions(+), 31 deletions(-)
> >
> 
> This is supposed to work by using of_live_active(), which is called from
> ofnode_is_np(). Instead of changing all this code, is it possible to update
> of_live_active() somehow?
> 

I've been trying to figure out it but I think there is no way just changing 
of_live_active as the compiler does not discard branch statements with nested 
fixed return values. I was able to make it work just changing ofnode_is_np 
using pre-processor macro to set as false when OF_LIVE is not enabled, but not 
sure if it the right approach. I will take a deeper look to the entire OF code 
and maybe suggest a code refactoring. 

> Regards,
> Simon

Regards
Ibai
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] dm: check OF_LIVE is enabled

2019-03-10 Thread Simon Glass
Hi Ibai,

On Tue, 26 Feb 2019 at 02:26, Ibai Erkiaga
 wrote:
>
> Livetree implemented functions does not have conditional compilation so
> check if CONFIG_IS_ENABLED prior using those functions.
>
> The issue does not report any error in a normal build as the toolchain
> optimize the code. Using -O0 triggers the error so the patch is intended
> to fix issues on a ongoing effor to build U-Boot with -O0.
>
> Signed-off-by: Ibai Erkiaga 
> ---
>
>  drivers/core/ofnode.c  | 60 
> +-
>  drivers/serial/serial-uclass.c |  2 +-
>  2 files changed, 31 insertions(+), 31 deletions(-)
>

This is supposed to work by using of_live_active(), which is called
from ofnode_is_np(). Instead of changing all this code, is it possible
to update of_live_active() somehow?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] dm: check OF_LIVE is enabled

2019-02-26 Thread Ibai Erkiaga
Livetree implemented functions does not have conditional compilation so
check if CONFIG_IS_ENABLED prior using those functions.

The issue does not report any error in a normal build as the toolchain
optimize the code. Using -O0 triggers the error so the patch is intended
to fix issues on a ongoing effor to build U-Boot with -O0.

Signed-off-by: Ibai Erkiaga 
---

 drivers/core/ofnode.c  | 60 +-
 drivers/serial/serial-uclass.c |  2 +-
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 0e584c1..caa7fa5 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -20,7 +20,7 @@ int ofnode_read_u32(ofnode node, const char *propname, u32 
*outp)
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {
return of_read_u32(ofnode_to_np(node), propname, outp);
} else {
const fdt32_t *cell;
@@ -63,7 +63,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 
*outp)
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
 
-   if (ofnode_is_np(node))
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE))
return of_read_u64(ofnode_to_np(node), propname, outp);
 
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
@@ -109,7 +109,7 @@ const char *ofnode_read_string(ofnode node, const char 
*propname)
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {
struct property *prop = of_find_property(
ofnode_to_np(node), propname, NULL);
 
@@ -141,7 +141,7 @@ ofnode ofnode_find_subnode(ofnode node, const char 
*subnode_name)
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, subnode_name);
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {
const struct device_node *np = ofnode_to_np(node);
 
for (np = np->child; np; np = np->sibling) {
@@ -166,7 +166,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {
return of_read_u32_array(ofnode_to_np(node), propname,
 out_values, sz);
} else {
@@ -179,7 +179,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
 ofnode ofnode_first_subnode(ofnode node)
 {
assert(ofnode_valid(node));
-   if (ofnode_is_np(node))
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE))
return np_to_ofnode(node.np->child);
 
return offset_to_ofnode(
@@ -189,7 +189,7 @@ ofnode ofnode_first_subnode(ofnode node)
 ofnode ofnode_next_subnode(ofnode node)
 {
assert(ofnode_valid(node));
-   if (ofnode_is_np(node))
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE))
return np_to_ofnode(node.np->sibling);
 
return offset_to_ofnode(
@@ -201,7 +201,7 @@ ofnode ofnode_get_parent(ofnode node)
ofnode parent;
 
assert(ofnode_valid(node));
-   if (ofnode_is_np(node))
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE))
parent = np_to_ofnode(of_get_parent(ofnode_to_np(node)));
else
parent.of_offset = fdt_parent_offset(gd->fdt_blob,
@@ -213,7 +213,7 @@ ofnode ofnode_get_parent(ofnode node)
 const char *ofnode_get_name(ofnode node)
 {
assert(ofnode_valid(node));
-   if (ofnode_is_np(node))
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE))
return strrchr(node.np->full_name, '/') + 1;
 
return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
@@ -223,7 +223,7 @@ ofnode ofnode_get_by_phandle(uint phandle)
 {
ofnode node;
 
-   if (of_live_active())
+   if (of_live_active() && CONFIG_IS_ENABLED(OF_LIVE))
node = np_to_ofnode(of_find_node_by_phandle(phandle));
else
node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
@@ -236,7 +236,7 @@ int ofnode_read_size(ofnode node, const char *propname)
 {
int len;
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {
struct property *prop = of_find_property(
ofnode_to_np(node), propname, NULL);
 
@@ -256,7 +256,7 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
int na, ns;
fdt_size_t size;
 
-   if (ofnode_is_np(node)) {
+   if (ofnode_is_np(node) && CONFIG_IS_ENABLED(OF_LIVE)) {