-From 8eddceb280f5deb8046fcb660de9f9f683b408b9 Mon Sep 17 00:00:00 2001
+From c5d264d4b527c96ae8903376a4b195df47b05203 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:21 +0100
+Date: Mon, 6 Feb 2023 13:43:43 +0000
Subject: [PATCH] of: base: add of_parse_phandle_with_optional_args()
Add a new variant of the of_parse_phandle_with_args() which treats the
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-10-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/of.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
-From 4f4145c9fee8c7a445dbbbadceccce5391e6b287 Mon Sep 17 00:00:00 2001
+From ff24fed10ba414d19579e26e60b126fad2f2bb07 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:22 +0100
+Date: Mon, 6 Feb 2023 13:43:44 +0000
Subject: [PATCH] of: property: make #.*-cells optional for simple props
Sometimes, future bindings for phandles will get additional arguments.
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-11-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/of/property.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
-@@ -1267,8 +1267,8 @@ static struct device_node *parse_suffix_
- if (strcmp_suffix(prop_name, suffix))
+@@ -1213,8 +1213,8 @@ static struct device_node *parse_prop_ce
+ if (strcmp(prop_name, list_name))
return NULL;
-- if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
+- if (of_parse_phandle_with_args(np, list_name, cells_name, index,
- &sup_args))
-+ if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index,
++ if (__of_parse_phandle_with_args(np, list_name, cells_name, 0, index,
+ &sup_args))
return NULL;
-From 9cf9486a6a7e8a3d76154d0c506051ba3740e8b6 Mon Sep 17 00:00:00 2001
+From e2d8172043d2e50df19fcd59c11e5593de8188d7 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:23 +0100
+Date: Mon, 6 Feb 2023 13:43:45 +0000
Subject: [PATCH] of: property: add #nvmem-cell-cells property
Bindings describe the new '#nvmem-cell-cells' property. Now that the
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-12-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/of/property.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- /dev/null
+From 553bd29700145e1849698985e9800f14e967da49 Mon Sep 17 00:00:00 2001
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+Date: Tue, 7 Feb 2023 12:05:29 +0100
+Subject: [PATCH] of: device: Ignore modalias of reused nodes
+
+If of_node is reused, do not use that node's modalias. This will hide
+the name of the actual device. This is rather prominent in USB glue
+drivers creating a platform device for the host controller.
+
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Link: https://lore.kernel.org/r/20230207110531.1060252-2-alexander.stein@ew.tq-group.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/of/device.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/of/device.c
++++ b/drivers/of/device.c
+@@ -223,7 +223,7 @@ static ssize_t of_device_get_modalias(st
+ ssize_t csize;
+ ssize_t tsize;
+
+- if ((!dev) || (!dev->of_node))
++ if ((!dev) || (!dev->of_node) || dev->of_node_reused)
+ return -ENODEV;
+
+ /* Name & Type */
+@@ -338,7 +338,7 @@ int of_device_uevent_modalias(struct dev
+ {
+ int sl;
+
+- if ((!dev) || (!dev->of_node))
++ if ((!dev) || (!dev->of_node) || dev->of_node_reused)
+ return -ENODEV;
+
+ /* Devicetree modalias is tricky, we add it in 2 steps */
--- /dev/null
+From 2295bed9bebe8d1eef276194fed5b5fbe89c5363 Mon Sep 17 00:00:00 2001
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+Date: Tue, 7 Feb 2023 12:05:30 +0100
+Subject: [PATCH] of: device: Do not ignore error code in
+ of_device_uevent_modalias
+
+of_device_get_modalias might return an error code, propagate that one.
+Otherwise the negative, signed integer is propagated to unsigned integer
+for the comparison resulting in a huge 'sl' size.
+
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Link: https://lore.kernel.org/r/20230207110531.1060252-3-alexander.stein@ew.tq-group.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/of/device.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/of/device.c
++++ b/drivers/of/device.c
+@@ -347,6 +347,8 @@ int of_device_uevent_modalias(struct dev
+
+ sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
+ sizeof(env->buf) - env->buflen);
++ if (sl < 0)
++ return sl;
+ if (sl >= (sizeof(env->buf) - env->buflen))
+ return -ENOMEM;
+ env->buflen += sl;
+++ /dev/null
-From ef26c0349eb5a615dab2272d08d1d5de4ac9cd4c Mon Sep 17 00:00:00 2001
-From: Michael Walle <michael@walle.cc>
-Date: Wed, 11 Jan 2023 00:30:56 +0100
-Subject: [PATCH] of: property: fix #nvmem-cell-cells parsing
-
-Commit 67b8497f005f ("of: property: make #.*-cells optional for simple
-props") claims to make the cells-name property optional for simple
-properties, but changed the code for the wrong property, i.e. for
-DEFINE_SUFFIX_PROP(). Fix that.
-
-Fixes: 67b8497f005f ("of: property: make #.*-cells optional for simple props")
-Reported-by: Peng Fan <peng.fan@nxp.com>
-Signed-off-by: Michael Walle <michael@walle.cc>
-Acked-by: Rob Herring <robh@kernel.org>
-Tested-by: Robert Marko <robimarko@gmail.com>
-Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
----
- drivers/of/property.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/drivers/of/property.c
-+++ b/drivers/of/property.c
-@@ -1213,8 +1213,8 @@ static struct device_node *parse_prop_ce
- if (strcmp(prop_name, list_name))
- return NULL;
-
-- if (of_parse_phandle_with_args(np, list_name, cells_name, index,
-- &sup_args))
-+ if (__of_parse_phandle_with_args(np, list_name, cells_name, 0, index,
-+ &sup_args))
- return NULL;
-
- return sup_args.np;
-@@ -1267,8 +1267,8 @@ static struct device_node *parse_suffix_
- if (strcmp_suffix(prop_name, suffix))
- return NULL;
-
-- if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index,
-- &sup_args))
-+ if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
-+ &sup_args))
- return NULL;
-
- return sup_args.np;
-From 8eddceb280f5deb8046fcb660de9f9f683b408b9 Mon Sep 17 00:00:00 2001
+From c5d264d4b527c96ae8903376a4b195df47b05203 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:21 +0100
+Date: Mon, 6 Feb 2023 13:43:43 +0000
Subject: [PATCH] of: base: add of_parse_phandle_with_optional_args()
Add a new variant of the of_parse_phandle_with_args() which treats the
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-10-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/of.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
-From 4f4145c9fee8c7a445dbbbadceccce5391e6b287 Mon Sep 17 00:00:00 2001
+From ff24fed10ba414d19579e26e60b126fad2f2bb07 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:22 +0100
+Date: Mon, 6 Feb 2023 13:43:44 +0000
Subject: [PATCH] of: property: make #.*-cells optional for simple props
Sometimes, future bindings for phandles will get additional arguments.
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-11-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/of/property.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
-@@ -1227,8 +1227,8 @@ static struct device_node *parse_suffix_
- if (strcmp_suffix(prop_name, suffix))
+@@ -1173,8 +1173,8 @@ static struct device_node *parse_prop_ce
+ if (strcmp(prop_name, list_name))
return NULL;
-- if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
+- if (of_parse_phandle_with_args(np, list_name, cells_name, index,
- &sup_args))
-+ if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index,
++ if (__of_parse_phandle_with_args(np, list_name, cells_name, 0, index,
+ &sup_args))
return NULL;
-From 9cf9486a6a7e8a3d76154d0c506051ba3740e8b6 Mon Sep 17 00:00:00 2001
+From e2d8172043d2e50df19fcd59c11e5593de8188d7 Mon Sep 17 00:00:00 2001
From: Michael Walle <michael@walle.cc>
-Date: Tue, 6 Dec 2022 21:07:23 +0100
+Date: Mon, 6 Feb 2023 13:43:45 +0000
Subject: [PATCH] of: property: add #nvmem-cell-cells property
Bindings describe the new '#nvmem-cell-cells' property. Now that the
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+Link: https://lore.kernel.org/r/20230206134356.839737-12-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/of/property.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- /dev/null
+From 553bd29700145e1849698985e9800f14e967da49 Mon Sep 17 00:00:00 2001
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+Date: Tue, 7 Feb 2023 12:05:29 +0100
+Subject: [PATCH] of: device: Ignore modalias of reused nodes
+
+If of_node is reused, do not use that node's modalias. This will hide
+the name of the actual device. This is rather prominent in USB glue
+drivers creating a platform device for the host controller.
+
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Link: https://lore.kernel.org/r/20230207110531.1060252-2-alexander.stein@ew.tq-group.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/of/device.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/of/device.c
++++ b/drivers/of/device.c
+@@ -249,7 +249,7 @@ static ssize_t of_device_get_modalias(st
+ ssize_t csize;
+ ssize_t tsize;
+
+- if ((!dev) || (!dev->of_node))
++ if ((!dev) || (!dev->of_node) || dev->of_node_reused)
+ return -ENODEV;
+
+ /* Name & Type */
+@@ -369,7 +369,7 @@ int of_device_uevent_modalias(struct dev
+ {
+ int sl;
+
+- if ((!dev) || (!dev->of_node))
++ if ((!dev) || (!dev->of_node) || dev->of_node_reused)
+ return -ENODEV;
+
+ /* Devicetree modalias is tricky, we add it in 2 steps */
--- /dev/null
+From 2295bed9bebe8d1eef276194fed5b5fbe89c5363 Mon Sep 17 00:00:00 2001
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+Date: Tue, 7 Feb 2023 12:05:30 +0100
+Subject: [PATCH] of: device: Do not ignore error code in
+ of_device_uevent_modalias
+
+of_device_get_modalias might return an error code, propagate that one.
+Otherwise the negative, signed integer is propagated to unsigned integer
+for the comparison resulting in a huge 'sl' size.
+
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Link: https://lore.kernel.org/r/20230207110531.1060252-3-alexander.stein@ew.tq-group.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/of/device.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/of/device.c
++++ b/drivers/of/device.c
+@@ -378,6 +378,8 @@ int of_device_uevent_modalias(struct dev
+
+ sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
+ sizeof(env->buf) - env->buflen);
++ if (sl < 0)
++ return sl;
+ if (sl >= (sizeof(env->buf) - env->buflen))
+ return -ENOMEM;
+ env->buflen += sl;
+++ /dev/null
-From ef26c0349eb5a615dab2272d08d1d5de4ac9cd4c Mon Sep 17 00:00:00 2001
-From: Michael Walle <michael@walle.cc>
-Date: Wed, 11 Jan 2023 00:30:56 +0100
-Subject: [PATCH] of: property: fix #nvmem-cell-cells parsing
-
-Commit 67b8497f005f ("of: property: make #.*-cells optional for simple
-props") claims to make the cells-name property optional for simple
-properties, but changed the code for the wrong property, i.e. for
-DEFINE_SUFFIX_PROP(). Fix that.
-
-Fixes: 67b8497f005f ("of: property: make #.*-cells optional for simple props")
-Reported-by: Peng Fan <peng.fan@nxp.com>
-Signed-off-by: Michael Walle <michael@walle.cc>
-Acked-by: Rob Herring <robh@kernel.org>
-Tested-by: Robert Marko <robimarko@gmail.com>
-Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
----
- drivers/of/property.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/drivers/of/property.c
-+++ b/drivers/of/property.c
-@@ -1173,8 +1173,8 @@ static struct device_node *parse_prop_ce
- if (strcmp(prop_name, list_name))
- return NULL;
-
-- if (of_parse_phandle_with_args(np, list_name, cells_name, index,
-- &sup_args))
-+ if (__of_parse_phandle_with_args(np, list_name, cells_name, 0, index,
-+ &sup_args))
- return NULL;
-
- return sup_args.np;
-@@ -1227,8 +1227,8 @@ static struct device_node *parse_suffix_
- if (strcmp_suffix(prop_name, suffix))
- return NULL;
-
-- if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index,
-- &sup_args))
-+ if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
-+ &sup_args))
- return NULL;
-
- return sup_args.np;