mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] dt:overlay: fix operation with multiple overlays
@ 2021-02-10 14:27 Enrico Scholz
  2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Enrico Scholz @ 2021-02-10 14:27 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Scholz

When applying multiple devicetree overlays the 'phandle' attribute
must be updated too.  Else, every overlay will be adjusted to start
with the same base which causes duplicate phandles.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 drivers/of/base.c    | 1 +
 drivers/of/overlay.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index edb0a8e71a0f..c88803d8ab4b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2385,6 +2385,7 @@ struct device_node *of_copy_node(struct device_node *parent, const struct device
 	struct property *pp;
 
 	np = of_new_node(parent, other->name);
+	np->phandle = other->phandle;
 
 	list_for_each_entry(pp, &other->properties, list)
 		of_new_property(np, pp->name, pp->value, pp->length);
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 92d20b9a247e..79f8b6dfdbcf 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -66,8 +66,10 @@ static int of_overlay_apply(struct device_node *target,
 
 	for_each_child_of_node(overlay, child) {
 		target_child = of_get_child_by_name(target, child->name);
-		if (!target_child)
+		if (!target_child) {
 			target_child = of_new_node(target, child->name);
+			target_child->phandle = child->phandle;
+		}
 		if (!target_child)
 			return -ENOMEM;
 
-- 
2.29.2


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

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

* [PATCH] imx8:pinfunc: fix definition
  2021-02-10 14:27 [PATCH] dt:overlay: fix operation with multiple overlays Enrico Scholz
@ 2021-02-10 14:27 ` Enrico Scholz
  2021-02-12 10:17   ` Sascha Hauer
  2021-02-10 14:27 ` [PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it Enrico Scholz
  2021-02-12 10:16 ` [PATCH] dt:overlay: fix operation with multiple overlays Sascha Hauer
  2 siblings, 1 reply; 5+ messages in thread
From: Enrico Scholz @ 2021-02-10 14:27 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Scholz

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 dts/src/arm64/freescale/imx8mm-pinfunc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dts/src/arm64/freescale/imx8mm-pinfunc.h b/dts/src/arm64/freescale/imx8mm-pinfunc.h
index 5ccc4cc91959..a003e6af3353 100644
--- a/dts/src/arm64/freescale/imx8mm-pinfunc.h
+++ b/dts/src/arm64/freescale/imx8mm-pinfunc.h
@@ -124,7 +124,7 @@
 #define MX8MM_IOMUXC_SD1_CMD_USDHC1_CMD                                     0x0A4 0x30C 0x000 0x0 0x0
 #define MX8MM_IOMUXC_SD1_CMD_GPIO2_IO1                                      0x0A4 0x30C 0x000 0x5 0x0
 #define MX8MM_IOMUXC_SD1_DATA0_USDHC1_DATA0                                 0x0A8 0x310 0x000 0x0 0x0
-#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2                                    0x0A8 0x31  0x000 0x5 0x0
+#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2                                    0x0A8 0x310 0x000 0x5 0x0
 #define MX8MM_IOMUXC_SD1_DATA1_USDHC1_DATA1                                 0x0AC 0x314 0x000 0x0 0x0
 #define MX8MM_IOMUXC_SD1_DATA1_GPIO2_IO3                                    0x0AC 0x314 0x000 0x5 0x0
 #define MX8MM_IOMUXC_SD1_DATA2_USDHC1_DATA2                                 0x0B0 0x318 0x000 0x0 0x0
-- 
2.29.2


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

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

* [PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it
  2021-02-10 14:27 [PATCH] dt:overlay: fix operation with multiple overlays Enrico Scholz
  2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
@ 2021-02-10 14:27 ` Enrico Scholz
  2021-02-12 10:16 ` [PATCH] dt:overlay: fix operation with multiple overlays Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Enrico Scholz @ 2021-02-10 14:27 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Scholz

of_nvmem_find() compared only the node names which can return the
wrong device in setups like

|  &i2c1 {
|      eeprom@50 {
|      };
|  };
|  &i2c2 {
|      eeprom@50 {
|      };
|  };

Instead of checking the complete path ('full_name' attribute), the
patch compares the device_node pointers directly.

This is done in other places (e.g. of_find_i2c_adapter_by_node()) and
in the linux kernel too.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 06e1414769aa..02d0af6e1de0 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -129,7 +129,7 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np)
 		return NULL;
 
 	list_for_each_entry(dev, &nvmem_devs, node)
-		if (dev->dev.device_node->name && !strcmp(dev->dev.device_node->name, nvmem_np->name))
+		if (dev->dev.device_node == nvmem_np)
 			return dev;
 
 	return NULL;
-- 
2.29.2


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

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

* Re: [PATCH] dt:overlay: fix operation with multiple overlays
  2021-02-10 14:27 [PATCH] dt:overlay: fix operation with multiple overlays Enrico Scholz
  2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
  2021-02-10 14:27 ` [PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it Enrico Scholz
@ 2021-02-12 10:16 ` Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-02-12 10:16 UTC (permalink / raw)
  To: Enrico Scholz; +Cc: barebox


Hi Enrico,

On Wed, Feb 10, 2021 at 03:27:02PM +0100, Enrico Scholz wrote:
> When applying multiple devicetree overlays the 'phandle' attribute
> must be updated too.  Else, every overlay will be adjusted to start
> with the same base which causes duplicate phandles.
> 
> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> ---
>  drivers/of/base.c    | 1 +
>  drivers/of/overlay.c | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index edb0a8e71a0f..c88803d8ab4b 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2385,6 +2385,7 @@ struct device_node *of_copy_node(struct device_node *parent, const struct device
>  	struct property *pp;
>  
>  	np = of_new_node(parent, other->name);
> +	np->phandle = other->phandle;

I can see why we have to do this for overlays. Without this all phandle
values from the overlay are lost.
I think however, that just copying the phandle values is wrong at least
in some cases of_copy_node() is used. When of_copy_node() is called with
a non NULL parent argument it duplicates the tree given in 'other' and
puts it below 'parent'. In that case we can't just copy the phandle
values as we would risk having duplicate phandle values in the parent
tree.

Maybe we can split of_copy_node() into two functions. One

struct device_node *of_duplicate(struct device_node *np);

this function can copy the phandle values without risk. The other
function

int of_attach(struct device_node *np, struct device_node *to);

would just make np a child node of 'to' and makes sure that phandle
values do not overlap.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 5+ messages in thread

* Re: [PATCH] imx8:pinfunc: fix definition
  2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
@ 2021-02-12 10:17   ` Sascha Hauer
  0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-02-12 10:17 UTC (permalink / raw)
  To: Enrico Scholz; +Cc: barebox

On Wed, Feb 10, 2021 at 03:27:03PM +0100, Enrico Scholz wrote:
> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> ---
>  dts/src/arm64/freescale/imx8mm-pinfunc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied this one and 3/3, thanks

Sascha

> diff --git a/dts/src/arm64/freescale/imx8mm-pinfunc.h b/dts/src/arm64/freescale/imx8mm-pinfunc.h
> index 5ccc4cc91959..a003e6af3353 100644
> --- a/dts/src/arm64/freescale/imx8mm-pinfunc.h
> +++ b/dts/src/arm64/freescale/imx8mm-pinfunc.h
> @@ -124,7 +124,7 @@
>  #define MX8MM_IOMUXC_SD1_CMD_USDHC1_CMD                                     0x0A4 0x30C 0x000 0x0 0x0
>  #define MX8MM_IOMUXC_SD1_CMD_GPIO2_IO1                                      0x0A4 0x30C 0x000 0x5 0x0
>  #define MX8MM_IOMUXC_SD1_DATA0_USDHC1_DATA0                                 0x0A8 0x310 0x000 0x0 0x0
> -#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2                                    0x0A8 0x31  0x000 0x5 0x0
> +#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2                                    0x0A8 0x310 0x000 0x5 0x0
>  #define MX8MM_IOMUXC_SD1_DATA1_USDHC1_DATA1                                 0x0AC 0x314 0x000 0x0 0x0
>  #define MX8MM_IOMUXC_SD1_DATA1_GPIO2_IO3                                    0x0AC 0x314 0x000 0x5 0x0
>  #define MX8MM_IOMUXC_SD1_DATA2_USDHC1_DATA2                                 0x0B0 0x318 0x000 0x0 0x0
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 5+ messages in thread

end of thread, other threads:[~2021-02-12 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 14:27 [PATCH] dt:overlay: fix operation with multiple overlays Enrico Scholz
2021-02-10 14:27 ` [PATCH] imx8:pinfunc: fix definition Enrico Scholz
2021-02-12 10:17   ` Sascha Hauer
2021-02-10 14:27 ` [PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it Enrico Scholz
2021-02-12 10:16 ` [PATCH] dt:overlay: fix operation with multiple overlays Sascha Hauer

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