diff mbox series

[1/1] mfd: mfd-core: Ensure disabled devices are ignored without error

Message ID 20200819105406.3249846-1-lee.jones@linaro.org (mailing list archive)
State Mainlined
Commit 22380b65dc70f5b132c5afdf6b4011e2a84ec34a
Headers show
Series [1/1] mfd: mfd-core: Ensure disabled devices are ignored without error | expand

Commit Message

Lee Jones Aug. 19, 2020, 10:54 a.m. UTC
Commit e49aa9a9bd22 ("mfd: core: Make a best effort attempt to match
devices with the correct of_nodes") changed the semantics for disabled
devices in mfd_add_device().  Instead of silently ignoring a disabled
child device, an error was returned.  On receipt of the error
mfd_add_devices() the precedes to remove *all* child devices and
returns an all-failed error to the caller, which will inevitably fail
the parent device as well.

This patch reverts back to the old semantics and ignores child devices
which are disabled in Device Tree.

Fixes: e49aa9a9bd22 ("mfd: core: Make a best effort attempt to match devices with the correct of_nodes")
Reported-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/mfd-core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Icenowy Zheng Aug. 19, 2020, 1 p.m. UTC | #1
在 2020-08-19星期三的 11:54 +0100,Lee Jones写道:
> Commit e49aa9a9bd22 ("mfd: core: Make a best effort attempt to match
> devices with the correct of_nodes") changed the semantics for
> disabled
> devices in mfd_add_device().  Instead of silently ignoring a disabled
> child device, an error was returned.  On receipt of the error
> mfd_add_devices() the precedes to remove *all* child devices and
> returns an all-failed error to the caller, which will inevitably fail
> the parent device as well.
> 
> This patch reverts back to the old semantics and ignores child
> devices
> which are disabled in Device Tree.
> 
> Fixes: e49aa9a9bd22 ("mfd: core: Make a best effort attempt to match
> devices with the correct of_nodes")
> Reported-by: Icenowy Zheng <icenowy@aosc.io>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>

Tested-by: Icenowy Zheng <icenowy@aosc.io>

> ---
>  drivers/mfd/mfd-core.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index c3651f06684fa..30f90a15ceaab 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -126,10 +126,6 @@ static int mfd_match_of_node_to_dev(struct
> platform_device *pdev,
>  	const __be32 *reg;
>  	u64 of_node_addr;
>  
> -	/* Skip devices 'disabled' by Device Tree */
> -	if (!of_device_is_available(np))
> -		return -ENODEV;
> -
>  	/* Skip if OF node has previously been allocated to a device */
>  	list_for_each_entry(of_entry, &mfd_of_node_list, list)
>  		if (of_entry->np == np)
> @@ -212,6 +208,12 @@ static int mfd_add_device(struct device *parent,
> int id,
>  	if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell-
> >of_compatible) {
>  		for_each_child_of_node(parent->of_node, np) {
>  			if (of_device_is_compatible(np, cell-
> >of_compatible)) {
> +				/* Ignore 'disabled' devices error free
> */
> +				if (!of_device_is_available(np)) {
> +					ret = 0;
> +					goto fail_alias;
> +				}
> +
>  				ret = mfd_match_of_node_to_dev(pdev,
> np, cell);
>  				if (ret == -EAGAIN)
>  					continue;
diff mbox series

Patch

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index c3651f06684fa..30f90a15ceaab 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -126,10 +126,6 @@  static int mfd_match_of_node_to_dev(struct platform_device *pdev,
 	const __be32 *reg;
 	u64 of_node_addr;
 
-	/* Skip devices 'disabled' by Device Tree */
-	if (!of_device_is_available(np))
-		return -ENODEV;
-
 	/* Skip if OF node has previously been allocated to a device */
 	list_for_each_entry(of_entry, &mfd_of_node_list, list)
 		if (of_entry->np == np)
@@ -212,6 +208,12 @@  static int mfd_add_device(struct device *parent, int id,
 	if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) {
 		for_each_child_of_node(parent->of_node, np) {
 			if (of_device_is_compatible(np, cell->of_compatible)) {
+				/* Ignore 'disabled' devices error free */
+				if (!of_device_is_available(np)) {
+					ret = 0;
+					goto fail_alias;
+				}
+
 				ret = mfd_match_of_node_to_dev(pdev, np, cell);
 				if (ret == -EAGAIN)
 					continue;