diff mbox series

[v3,01/35] mmc: sdhci: Use devm_mmc_alloc_host() helper

Message ID dcfce3ddf980563c590f82c1b4e8840c29497887.1749127796.git.zhoubinbin@loongson.cn
State New
Headers show
Series mmc: Cleanup sdhci_pltfm_free()/sdhci_free_host() usage | expand

Commit Message

Binbin Zhou June 7, 2025, 7:33 a.m. UTC
Use new function devm_mmc_alloc_host() to simplify the code.

Although sdhci_free_host() is no longer needed, to avoid drivers that still
use this function from failing to compile, sdhci_free_host() is temporarily
set to empty. Finally, it will be removed when there are no more callers.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/sdhci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Thierry Reding June 10, 2025, 9:42 a.m. UTC | #1
On Sat, Jun 07, 2025 at 03:33:34PM +0800, Binbin Zhou wrote:
> Use new function devm_mmc_alloc_host() to simplify the code.
> 
> Although sdhci_free_host() is no longer needed, to avoid drivers that still
> use this function from failing to compile, sdhci_free_host() is temporarily
> set to empty. Finally, it will be removed when there are no more callers.
> 
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
>  drivers/mmc/host/sdhci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 32fa0b2bb912..ee5a5ae4db31 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -4076,7 +4076,7 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
>  
>  	WARN_ON(dev == NULL);
>  
> -	mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
> +	mmc = devm_mmc_alloc_host(dev, sizeof(struct sdhci_host) + priv_size);
>  	if (!mmc)
>  		return ERR_PTR(-ENOMEM);
>  
> @@ -5002,7 +5002,6 @@ EXPORT_SYMBOL_GPL(sdhci_remove_host);
>  
>  void sdhci_free_host(struct sdhci_host *host)
>  {
> -	mmc_free_host(host->mmc);
>  }

Is there any point in keeping the sdhci_free_host() function around now?
I only see patches 1 and 31, so not sure if anything happens in between.

Thierry
Binbin Zhou June 10, 2025, 10:21 a.m. UTC | #2
Hi Thierry:

On 2025/6/10 17:42, Thierry Reding wrote:
> On Sat, Jun 07, 2025 at 03:33:34PM +0800, Binbin Zhou wrote:
>> Use new function devm_mmc_alloc_host() to simplify the code.
>>
>> Although sdhci_free_host() is no longer needed, to avoid drivers that still
>> use this function from failing to compile, sdhci_free_host() is temporarily
>> set to empty. Finally, it will be removed when there are no more callers.
>>
>> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
>> ---
>>   drivers/mmc/host/sdhci.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 32fa0b2bb912..ee5a5ae4db31 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -4076,7 +4076,7 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
>>   
>>   	WARN_ON(dev == NULL);
>>   
>> -	mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
>> +	mmc = devm_mmc_alloc_host(dev, sizeof(struct sdhci_host) + priv_size);
>>   	if (!mmc)
>>   		return ERR_PTR(-ENOMEM);
>>   
>> @@ -5002,7 +5002,6 @@ EXPORT_SYMBOL_GPL(sdhci_remove_host);
>>   
>>   void sdhci_free_host(struct sdhci_host *host)
>>   {
>> -	mmc_free_host(host->mmc);
>>   }
> Is there any point in keeping the sdhci_free_host() function around now?
> I only see patches 1 and 31, so not sure if anything happens in between.

To minimize email delivery failures, I handle each driver patch by 
sending it to the relevant person, while sending patches 0 and 1 to 
everyone.

Keeping sdhci_free_host() as suggested by Adrian[1] is to minimize 
disruption to the compilation process. We first set sdhci_free_host() to 
empty, and once all callers have been cleaned up, we will remove it[2].

Of course, perhaps I should also CC the final patch[2] to everyone, 
which would make the entire process clearer.

[1]: 
https://lore.kernel.org/all/78ffbae6-1c75-46ac-a5d7-bbc07bca1fd0@intel.com/

[2]: 
https://lore.kernel.org/all/8adcfef00fd4bc40f33f5fd42d2e5e73d72e68e4.1749127796.git.zhoubinbin@loongson.cn/


Thanks.
Binbin

>
> Thierry
Thierry Reding June 10, 2025, 11:15 a.m. UTC | #3
On Tue, Jun 10, 2025 at 06:21:27PM +0800, Binbin Zhou wrote:
> Hi Thierry:
> 
> On 2025/6/10 17:42, Thierry Reding wrote:
> > On Sat, Jun 07, 2025 at 03:33:34PM +0800, Binbin Zhou wrote:
> > > Use new function devm_mmc_alloc_host() to simplify the code.
> > > 
> > > Although sdhci_free_host() is no longer needed, to avoid drivers that still
> > > use this function from failing to compile, sdhci_free_host() is temporarily
> > > set to empty. Finally, it will be removed when there are no more callers.
> > > 
> > > Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> > > ---
> > >   drivers/mmc/host/sdhci.c | 3 +--
> > >   1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > > index 32fa0b2bb912..ee5a5ae4db31 100644
> > > --- a/drivers/mmc/host/sdhci.c
> > > +++ b/drivers/mmc/host/sdhci.c
> > > @@ -4076,7 +4076,7 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
> > >   	WARN_ON(dev == NULL);
> > > -	mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
> > > +	mmc = devm_mmc_alloc_host(dev, sizeof(struct sdhci_host) + priv_size);
> > >   	if (!mmc)
> > >   		return ERR_PTR(-ENOMEM);
> > > @@ -5002,7 +5002,6 @@ EXPORT_SYMBOL_GPL(sdhci_remove_host);
> > >   void sdhci_free_host(struct sdhci_host *host)
> > >   {
> > > -	mmc_free_host(host->mmc);
> > >   }
> > Is there any point in keeping the sdhci_free_host() function around now?
> > I only see patches 1 and 31, so not sure if anything happens in between.
> 
> To minimize email delivery failures, I handle each driver patch by sending
> it to the relevant person, while sending patches 0 and 1 to everyone.
> 
> Keeping sdhci_free_host() as suggested by Adrian[1] is to minimize
> disruption to the compilation process. We first set sdhci_free_host() to
> empty, and once all callers have been cleaned up, we will remove it[2].
> 
> Of course, perhaps I should also CC the final patch[2] to everyone, which
> would make the entire process clearer.

Makes sense, and no worries. There's no great solution to this. Either
you send to everyone and you get complaints, or you send to too few
people and you get complaints.

Thanks for clarifying.

Thierry
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 32fa0b2bb912..ee5a5ae4db31 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -4076,7 +4076,7 @@  struct sdhci_host *sdhci_alloc_host(struct device *dev,
 
 	WARN_ON(dev == NULL);
 
-	mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(struct sdhci_host) + priv_size);
 	if (!mmc)
 		return ERR_PTR(-ENOMEM);
 
@@ -5002,7 +5002,6 @@  EXPORT_SYMBOL_GPL(sdhci_remove_host);
 
 void sdhci_free_host(struct sdhci_host *host)
 {
-	mmc_free_host(host->mmc);
 }
 
 EXPORT_SYMBOL_GPL(sdhci_free_host);