Skip to contentSkip to conversation

of: property: Add fw_devlink support for more props

PATCH Superseded Saravana Kannan 4 participants 10 messages Jan 20, 2021 – Jan 21, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover of: property: Add fw_devlink support for more props

This series combines two patches [1] [2] that'd conflict.

Rob/Greg,

I think this should go into driver-core-next since Patch 1/2 fixes issues caused by a patch in driver-core-next.

Patch 2/2 also touches the same locations. So, combining both into a series.

Marc,

I'll add support for interrupt-map separately. It'll probably need to be its own series because it'll need some refactor. I don't want to block Patch 2/2 on that.

-Saravana

[1] - https://lore.kernel.org/lkml/[email protected]/
[2] - https://lore.kernel.org/lkml/[email protected]/

Individual -> Series:
Patch 1/2: Addressed Geert's gpio-hog problem with gpio[s] property Patch 2/2: Switched to using of_irq_find_parent()

Saravana Kannan (2):
of: property: Add fw_devlink support for "gpio" and "gpios" binding
of: property: Add fw_devlink support for interrupts

 drivers/of/property.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#1 lore raw

PATCH 1/2 of: property: Add fw_devlink support for "gpio" and "gpios" binding

To provide backward compatibility for boards that use deprecated DT bindings, we need to add fw_devlink support for "gpio" and "gpios".

Cc linux-tegra <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Fixes e590474768f1 ("driver core: Set fw_devlink=on by default")
---
 drivers/of/property.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/of/property.c +19 -0
index 5f9eed79a8aa..0b256ce9d7d5 100644
@@ -1271,6 +1271,24 @@ static struct device_node *parse_iommu_maps(struct device_node *np,
 	return of_parse_phandle(np, prop_name, (index * 4) + 1);
 }
 
+static struct device_node *parse_gpio_compat(struct device_node *np,
+					     const char *prop_name, int index)
+{
+	struct of_phandle_args sup_args;
+
+	if (strcmp(prop_name, "gpio") && strcmp(prop_name, "gpios"))
+		return NULL;
+
+	if (of_find_property(np, "gpio-hog", NULL))
+		return NULL;
+
+	if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index,
+				       &sup_args))
+		return NULL;
+
+	return sup_args.np;
+}
+
 static const struct supplier_bindings of_supplier_bindings[] = {
 	{ .parse_prop = parse_clocks, },
 	{ .parse_prop = parse_interconnects, },
@@ -1296,6 +1314,7 @@ static const struct supplier_bindings of_supplier_bindings[] = {
 	{ .parse_prop = parse_pinctrl6, },
 	{ .parse_prop = parse_pinctrl7, },
 	{ .parse_prop = parse_pinctrl8, },
+	{ .parse_prop = parse_gpio_compat, },
 	{ .parse_prop = parse_regulators, },
 	{ .parse_prop = parse_gpio, },
 	{ .parse_prop = parse_gpios, },
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] of: property: Add fw_devlink support for "gpio" and "gpios" binding

Quoted 12 lines · Saravana Kannan

To provide backward compatibility for boards that use deprecated DT bindings, we need to add fw_devlink support for "gpio" and "gpios".

Cc linux-tegra <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Fixes e590474768f1 ("driver core: Set fw_devlink=on by default")
Quoted 3 lines
---
 drivers/of/property.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH v1 1/2] of: property: Add fw_devlink support for "gpio" and "gpios" binding

In reply to Saravana Kannan
Quoted 11 lines · Saravana Kannan

To provide backward compatibility for boards that use deprecated DT bindings, we need to add fw_devlink support for "gpio" and "gpios".

Cc linux-tegra <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Fixes e590474768f1 ("driver core: Set fw_devlink=on by default")
Quoted 3 lines
---
 drivers/of/property.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
#4 lore raw

Re: [PATCH v1 1/2] of: property: Add fw_devlink support for "gpio" and "gpios" binding

In reply to Saravana Kannan
Quoted 2 lines · Saravana Kannan

To provide backward compatibility for boards that use deprecated DT bindings, we need to add fw_devlink support for "gpio" and "gpios".

You do some more stuff in the patch so describe that too. Especially the check for hogs and #gpio-cells. Describe why you do that. Maybe even with a comment in the code because I don't think everyone will understand.

Review

Quoted 2 lines
(quoted diff) +2 -0
+       if (strcmp(prop_name, "gpio") && strcmp(prop_name, "gpios"))
+               return NULL;

This part is easy to understand.

drivers/of/property.c static struct device_node *parse_iommu_maps(struct device_node *np, · line 1287

Quoted 6 lines
drivers/of/property.c +6 -0
+       if (of_find_property(np, "gpio-hog", NULL))
+               return NULL;
+
+       if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index,
+                                      &sup_args))
+               return NULL;

This part is hard to understand. Insert comments and tell the reader of the code what is going on and why.

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH v1 1/2] of: property: Add fw_devlink support for "gpio" and "gpios" binding

Quoted 10 lines · Linus Walleij
Quoted 2 lines · Saravana Kannan

To provide backward compatibility for boards that use deprecated DT bindings, we need to add fw_devlink support for "gpio" and "gpios".

You do some more stuff in the patch so describe that too. Especially the check for hogs and #gpio-cells. Describe why you do that. Maybe even with a comment in the code because I don't think everyone will understand.

Ack

Quoted 13 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+       if (strcmp(prop_name, "gpio") && strcmp(prop_name, "gpios"))
+               return NULL;

This part is easy to understand.

drivers/of/property.c static struct device_node *parse_iommu_maps(struct device_node *np, · line 1287

Quoted 6 lines
drivers/of/property.c +6 -0
+       if (of_find_property(np, "gpio-hog", NULL))
+               return NULL;
+
+       if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index,
+                                      &sup_args))
+               return NULL;
Quoted 2 lines

This part is hard to understand. Insert comments and tell the reader of the code what is going on and why.

I assume the "hard to understand" part is the gpio-hog part? Because the last line is pretty straightforward -- it's returning the index-th phandle. Also, it's a copy-paste from the DEFINE_SIMPLE_PROP macro.

-Saravana

#6 lore raw

PATCH 2/2 of: property: Add fw_devlink support for interrupts

In reply to Saravana Kannan

This allows fw_devlink to create device links between consumers of an interrupt and the supplier of the interrupt.

Cc Marc Zyngier <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/of/property.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/of/property.c +11 -0
index 0b256ce9d7d5..9dd9cc50e65a 100644
@@ -24,6 +24,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_graph.h>
+#include <linux/of_irq.h>
 #include <linux/string.h>
 #include <linux/moduleparam.h>
 
@@ -1289,6 +1290,15 @@ static struct device_node *parse_gpio_compat(struct device_node *np,
 	return sup_args.np;
 }
 
+static struct device_node *parse_interrupts(struct device_node *np,
+					    const char *prop_name, int index)
+{
+	if (strcmp(prop_name, "interrupts") || index)
+		return NULL;
+
+	return of_irq_find_parent(np);
+}
+
 static const struct supplier_bindings of_supplier_bindings[] = {
 	{ .parse_prop = parse_clocks, },
 	{ .parse_prop = parse_interconnects, },
@@ -1315,6 +1325,7 @@ static const struct supplier_bindings of_supplier_bindings[] = {
 	{ .parse_prop = parse_pinctrl7, },
 	{ .parse_prop = parse_pinctrl8, },
 	{ .parse_prop = parse_gpio_compat, },
+	{ .parse_prop = parse_interrupts, },
 	{ .parse_prop = parse_regulators, },
 	{ .parse_prop = parse_gpio, },
 	{ .parse_prop = parse_gpios, },
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH v1 2/2] of: property: Add fw_devlink support for interrupts

Quoted 11 lines · Saravana Kannan

This allows fw_devlink to create device links between consumers of an interrupt and the supplier of the interrupt.

Cc Marc Zyngier <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/of/property.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH v1 2/2] of: property: Add fw_devlink support for interrupts

In reply to Saravana Kannan
Quoted 10 lines · Saravana Kannan

This allows fw_devlink to create device links between consumers of an interrupt and the supplier of the interrupt.

Cc Marc Zyngier <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/of/property.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Reviewed-by on v1 2/2
#9 lore raw

Re: [PATCH v1 2/2] of: property: Add fw_devlink support for interrupts

In reply to Saravana Kannan
Quoted 7 lines · Saravana Kannan

This allows fw_devlink to create device links between consumers of an interrupt and the supplier of the interrupt.

Cc Marc Zyngier <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

Yours,
Linus Walleij