2024-03-05 20:26:54

by Daniel Golle

[permalink] [raw]
Subject: [RFC PATCH v2 6/8] mmc: core: set card fwnode_handle

Set fwnode in case it isn't set yet and of_node is present.

Signed-off-by: Daniel Golle <[email protected]>
---
drivers/mmc/core/bus.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 0ddaee0eae54f..e1c5fc1b3ce4b 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -364,6 +364,8 @@ int mmc_add_card(struct mmc_card *card)

mmc_add_card_debugfs(card);
card->dev.of_node = mmc_of_find_child_device(card->host, 0);
+ if (card->dev.of_node && !card->dev.fwnode)
+ card->dev.fwnode = &card->dev.of_node->fwnode;

device_enable_async_suspend(&card->dev);

--
2.44.0


2024-03-08 08:07:04

by Avri Altman

[permalink] [raw]
Subject: RE: [RFC PATCH v2 6/8] mmc: core: set card fwnode_handle


> Set fwnode in case it isn't set yet and of_node is present.
>
> Signed-off-by: Daniel Golle <[email protected]>
> ---
> drivers/mmc/core/bus.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index
> 0ddaee0eae54f..e1c5fc1b3ce4b 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -364,6 +364,8 @@ int mmc_add_card(struct mmc_card *card)
>
> mmc_add_card_debugfs(card);
> card->dev.of_node = mmc_of_find_child_device(card->host, 0);
> + if (card->dev.of_node && !card->dev.fwnode)
> + card->dev.fwnode = &card->dev.of_node->fwnode;
Should this be restricted to eMMC only, or is it fine to be called for SD as well?

Thanks,
Avri

>
> device_enable_async_suspend(&card->dev);
>
> --
> 2.44.0

2024-03-08 14:57:13

by Daniel Golle

[permalink] [raw]
Subject: Re: [RFC PATCH v2 6/8] mmc: core: set card fwnode_handle

On Fri, Mar 08, 2024 at 08:04:54AM +0000, Avri Altman wrote:
>
> > Set fwnode in case it isn't set yet and of_node is present.
> >
> > Signed-off-by: Daniel Golle <[email protected]>
> > ---
> > drivers/mmc/core/bus.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index
> > 0ddaee0eae54f..e1c5fc1b3ce4b 100644
> > --- a/drivers/mmc/core/bus.c
> > +++ b/drivers/mmc/core/bus.c
> > @@ -364,6 +364,8 @@ int mmc_add_card(struct mmc_card *card)
> >
> > mmc_add_card_debugfs(card);
> > card->dev.of_node = mmc_of_find_child_device(card->host, 0);
> > + if (card->dev.of_node && !card->dev.fwnode)
> > + card->dev.fwnode = &card->dev.of_node->fwnode;
> Should this be restricted to eMMC only, or is it fine to be called for SD as well?

It's always odd to have of_node set and fwnode unset. And also SD
cards can be referenced in device tree, resulting in of_node being set
but fwnode being unpopulated, which is no more or less weird than for
an eMMC.

So imho it should always be called and shouldn't hurt.