2019-11-07 11:21:06

by Lee Jones

[permalink] [raw]
Subject: [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.

Link: https://www.spinics.net/lists/arm-kernel/msg366309.html
Link: https://lkml.org/lkml/2019/8/22/1350

Reported-by: Barry Song <[email protected]>
Reported-by: Stephan Gerhold <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
---
drivers/mfd/mfd-core.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index cb3e0a14bbdd..f5a73af60dd4 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -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;
--
2.24.0


2019-11-07 11:59:38

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 1/1] mfd: mfd-core: Honour Device Tree's request to disable a child-device

On Thu, Nov 07, 2019 at 11:19:50AM +0000, Lee Jones wrote:
> 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.
>
> Link: https://www.spinics.net/lists/arm-kernel/msg366309.html
> Link: https://lkml.org/lkml/2019/8/22/1350
>
> Reported-by: Barry Song <[email protected]>
> Reported-by: Stephan Gerhold <[email protected]>
> Signed-off-by: Lee Jones <[email protected]>

Reviewed-by: Daniel Thompson <[email protected]>

> ---
> drivers/mfd/mfd-core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index cb3e0a14bbdd..f5a73af60dd4 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -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;
> --
> 2.24.0
>

2019-11-07 13:09:11

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/1] mfd: mfd-core: Honour Device Tree's request to disable a child-device

On Thu, Nov 07, 2019 at 11:19:50AM +0000, Lee Jones wrote:
> 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.

Reviewed-by: Mark Brown <[email protected]>


Attachments:
(No filename) (335.00 B)
signature.asc (495.00 B)
Download all attachments

2019-11-07 18:27:59

by Stephan Gerhold

[permalink] [raw]
Subject: Re: [PATCH 1/1] mfd: mfd-core: Honour Device Tree's request to disable a child-device

On Thu, Nov 07, 2019 at 11:19:50AM +0000, Lee Jones wrote:
> 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.
>
> Link: https://www.spinics.net/lists/arm-kernel/msg366309.html
> Link: https://lkml.org/lkml/2019/8/22/1350
>
> Reported-by: Barry Song <[email protected]>
> Reported-by: Stephan Gerhold <[email protected]>
> Signed-off-by: Lee Jones <[email protected]>

Thanks for all your work on this issue!

FWIW:
Tested-by: Stephan Gerhold <[email protected]>

> ---
> drivers/mfd/mfd-core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index cb3e0a14bbdd..f5a73af60dd4 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -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;
> --
> 2.24.0
>