Skip to contentSkip to conversation

mfd: mfd-core: Honour Device Tree's request to disable a child-device

PATCH In review Lee Jones 4 participants 4 messages Nov 7, 2019 Multifunction devices (MFD)

lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH 1/1 mfd: mfd-core: Honour Device Tree's request to disable a child-device

Until now, MFD has assumed all child devices passed to it (via mfd_cells) are to be registered. It does not take into account requests from Device Tree and the like to disable child devices on a per-platform basis.

Well now it does.

---
 drivers/mfd/mfd-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mfd/mfd-core.c +5 -0
index cb3e0a14bbdd..f5a73af60dd4 100644
@@ -152,6 +152,11 @@ static int mfd_add_device(struct device *parent, int id,
 	if (parent->of_node && cell->of_compatible) {
 		for_each_child_of_node(parent->of_node, np) {
 			if (of_device_is_compatible(np, cell->of_compatible)) {
+				if (!of_device_is_available(np)) {
+					/* Ignore disabled devices error free */
+					ret = 0;
+					goto fail_alias;
+				}
 				pdev->dev.of_node = np;
 				pdev->dev.fwnode = &np->fwnode;
 				break;
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Lee Jones

Until now, MFD has assumed all child devices passed to it (via mfd_cells) are to be registered. It does not take into account requests from Device Tree and the like to disable child devices on a per-platform basis.

Quoted 8 lines

Well now it does.

Quoted 23 lines
---
 drivers/mfd/mfd-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mfd/mfd-core.c +5 -0
index cb3e0a14bbdd..f5a73af60dd4 100644
@@ -152,6 +152,11 @@ static int mfd_add_device(struct device *parent, int id,
 	if (parent->of_node && cell->of_compatible) {
 		for_each_child_of_node(parent->of_node, np) {
 			if (of_device_is_compatible(np, cell->of_compatible)) {
+				if (!of_device_is_available(np)) {
+					/* Ignore disabled devices error free */
+					ret = 0;
+					goto fail_alias;
+				}
 				pdev->dev.of_node = np;
 				pdev->dev.fwnode = &np->fwnode;
 				break;
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Lee Jones
Quoted 4 lines · Lee Jones

Until now, MFD has assumed all child devices passed to it (via mfd_cells) are to be registered. It does not take into account requests from Device Tree and the like to disable child devices on a per-platform basis.

Tested-by on v1 1/1
#3 lore raw
In reply to Lee Jones
Quoted 5 lines · Lee Jones

Until now, MFD has assumed all child devices passed to it (via mfd_cells) are to be registered. It does not take into account requests from Device Tree and the like to disable child devices on a per-platform basis.

Quoted 8 lines

Well now it does.

Thanks for all your work on this issue!

FWIW:

Quoted 23 lines
---
 drivers/mfd/mfd-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mfd/mfd-core.c +5 -0
index cb3e0a14bbdd..f5a73af60dd4 100644
@@ -152,6 +152,11 @@ static int mfd_add_device(struct device *parent, int id,
 	if (parent->of_node && cell->of_compatible) {
 		for_each_child_of_node(parent->of_node, np) {
 			if (of_device_is_compatible(np, cell->of_compatible)) {
+				if (!of_device_is_available(np)) {
+					/* Ignore disabled devices error free */
+					ret = 0;
+					goto fail_alias;
+				}
 				pdev->dev.of_node = np;
 				pdev->dev.fwnode = &np->fwnode;
 				break;
Signature · 1 line
2.24.0