2023-09-22 05:59:02

by Drew Fustini

[permalink] [raw]
Subject: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header

Expose __sdhci_execute_tuning() so that it can be called from the
mmc host controller drivers.

In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets
platform_execute_tuning to th1520_execute_tuning(). That function has
to manipulate phy registers before tuning can be performed. To avoid
copying the code verbatim from __sdhci_execute_tuning() into
th1520_execute_tuning(), make it possible for __sdhci_execute_tuning()
to be called from sdhci-of-dwcmshc.

Signed-off-by: Drew Fustini <[email protected]>
---
drivers/mmc/host/sdhci.c | 2 +-
drivers/mmc/host/sdhci.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ff41aa56564e..fd607058d176 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
}
EXPORT_SYMBOL_GPL(sdhci_send_tuning);

-static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
+int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
{
int i;

diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index f219bdea8f28..a20864fc0641 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -793,6 +793,7 @@ void sdhci_set_bus_width(struct sdhci_host *host, int width);
void sdhci_reset(struct sdhci_host *host, u8 mask);
void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
+int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode);
void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
struct mmc_ios *ios);

--
2.34.1


2023-09-25 16:15:16

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header

On 22/09/23 04:49, Drew Fustini wrote:
> Expose __sdhci_execute_tuning() so that it can be called from the
> mmc host controller drivers.
>
> In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets
> platform_execute_tuning to th1520_execute_tuning(). That function has
> to manipulate phy registers before tuning can be performed. To avoid
> copying the code verbatim from __sdhci_execute_tuning() into
> th1520_execute_tuning(), make it possible for __sdhci_execute_tuning()
> to be called from sdhci-of-dwcmshc.
>
> Signed-off-by: Drew Fustini <[email protected]>
> ---
> drivers/mmc/host/sdhci.c | 2 +-
> drivers/mmc/host/sdhci.h | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index ff41aa56564e..fd607058d176 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
> }
> EXPORT_SYMBOL_GPL(sdhci_send_tuning);
>
> -static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
> +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)

Also need
EXPORT_SYMBOL_GPL(__sdhci_execute_tuning);

> {
> int i;
>
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index f219bdea8f28..a20864fc0641 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -793,6 +793,7 @@ void sdhci_set_bus_width(struct sdhci_host *host, int width);
> void sdhci_reset(struct sdhci_host *host, u8 mask);
> void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
> int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
> +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode);
> void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
> int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
> struct mmc_ios *ios);
>

2023-09-25 18:01:42

by Xi Ruoyao

[permalink] [raw]
Subject: Re: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header

On Mon, 2023-09-25 at 13:21 +0300, Adrian Hunter wrote:
> On 22/09/23 04:49, Drew Fustini wrote:
> > Expose __sdhci_execute_tuning() so that it can be called from the
> > mmc host controller drivers.
> >
> > In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets
> > platform_execute_tuning to th1520_execute_tuning(). That function has
> > to manipulate phy registers before tuning can be performed. To avoid
> > copying the code verbatim from __sdhci_execute_tuning() into
> > th1520_execute_tuning(), make it possible for __sdhci_execute_tuning()
> > to be called from sdhci-of-dwcmshc.
> >
> > Signed-off-by: Drew Fustini <[email protected]>
> > ---
> >  drivers/mmc/host/sdhci.c | 2 +-
> >  drivers/mmc/host/sdhci.h | 1 +
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index ff41aa56564e..fd607058d176 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
> >  }
> >  EXPORT_SYMBOL_GPL(sdhci_send_tuning);
> >  
> > -static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
> > +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
>
> Also need
> EXPORT_SYMBOL_GPL(__sdhci_execute_tuning);
>
> >  {
> >   int i;

By the way should we rename this function? I think
"__sdhci_execute_tuning" vs "sdhci_execute_tuning" might be confusing
when we export both.

--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University

2023-09-26 01:51:28

by Drew Fustini

[permalink] [raw]
Subject: Re: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header

On Mon, Sep 25, 2023 at 01:21:05PM +0300, Adrian Hunter wrote:
> On 22/09/23 04:49, Drew Fustini wrote:
> > Expose __sdhci_execute_tuning() so that it can be called from the
> > mmc host controller drivers.
> >
> > In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets
> > platform_execute_tuning to th1520_execute_tuning(). That function has
> > to manipulate phy registers before tuning can be performed. To avoid
> > copying the code verbatim from __sdhci_execute_tuning() into
> > th1520_execute_tuning(), make it possible for __sdhci_execute_tuning()
> > to be called from sdhci-of-dwcmshc.
> >
> > Signed-off-by: Drew Fustini <[email protected]>
> > ---
> > drivers/mmc/host/sdhci.c | 2 +-
> > drivers/mmc/host/sdhci.h | 1 +
> > 2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index ff41aa56564e..fd607058d176 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
> > }
> > EXPORT_SYMBOL_GPL(sdhci_send_tuning);
> >
> > -static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
> > +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
>
> Also need
> EXPORT_SYMBOL_GPL(__sdhci_execute_tuning);

Thank, I will add that.

I wasn't sure if making __sdhci_execute_tuning() available outside of
sdhci.c was going to be seen as an acceptable solution.

Do you think my apporach is acceptable (once I add EXPORT_SYMBOL_GPL)?

Thanks,
Drew

2023-09-28 11:53:15

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH 2/6] mmc: sdhci: add __sdhci_execute_tuning() to header

On 25/09/23 13:23, Xi Ruoyao wrote:
> On Mon, 2023-09-25 at 13:21 +0300, Adrian Hunter wrote:
>> On 22/09/23 04:49, Drew Fustini wrote:
>>> Expose __sdhci_execute_tuning() so that it can be called from the
>>> mmc host controller drivers.
>>>
>>> In the sdhci-of-dwcmshc driver, sdhci_dwcmshc_th1520_ops sets
>>> platform_execute_tuning to th1520_execute_tuning(). That function has
>>> to manipulate phy registers before tuning can be performed. To avoid
>>> copying the code verbatim from __sdhci_execute_tuning() into
>>> th1520_execute_tuning(), make it possible for __sdhci_execute_tuning()
>>> to be called from sdhci-of-dwcmshc.
>>>
>>> Signed-off-by: Drew Fustini <[email protected]>
>>> ---
>>>  drivers/mmc/host/sdhci.c | 2 +-
>>>  drivers/mmc/host/sdhci.h | 1 +
>>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>>> index ff41aa56564e..fd607058d176 100644
>>> --- a/drivers/mmc/host/sdhci.c
>>> +++ b/drivers/mmc/host/sdhci.c
>>> @@ -2841,7 +2841,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
>>>  }
>>>  EXPORT_SYMBOL_GPL(sdhci_send_tuning);
>>>  
>>> -static int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
>>> +int __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
>>
>> Also need
>> EXPORT_SYMBOL_GPL(__sdhci_execute_tuning);
>>
>>>  {
>>>   int i;
>
> By the way should we rename this function? I think
> "__sdhci_execute_tuning" vs "sdhci_execute_tuning" might be confusing
> when we export both.
>

'name()' and '__name()' is not a particularly rare paradigm in the kernel,
so it seems ok.