diff mbox series

[01/34] mmc: sdhci: Use devm_mmc_alloc_host() helper

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

Commit Message

Binbin Zhou May 26, 2025, 6:05 a.m. UTC
Use new function devm_mmc_alloc_host() to simplify the code.

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

Comments

Binbin Zhou May 26, 2025, 6:46 a.m. UTC | #1
Hi Adrian:

Thanks for your reply.

On Mon, May 26, 2025 at 2:27 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 26/05/2025 09:05, Binbin Zhou wrote:
> > Use new function devm_mmc_alloc_host() to simplify the code.
> >
> > Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> > ---
> >  drivers/mmc/host/sdhci.c | 9 +--------
> >  drivers/mmc/host/sdhci.h | 1 -
> >  2 files changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index 32fa0b2bb912..c40caa3f003f 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);
> >
> > @@ -5000,13 +5000,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
> >
> >  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);
>
> Doesn't that break the compile for everything still using sdhci_free_host()?
>
> You probably need to make it like this:
>
>         void sdhci_free_host(struct sdhci_host *host)
>         {
>         }
>         EXPORT_SYMBOL_GPL(sdhci_free_host);
>
> and then remove sdhci_free_host() at the end when there are no callers
> left.
>
Yes, I didn't think it through and I will change it in the next
version the way you said.
Patch-07 has the same problem, I'll fix it all together.

>
> > -
> >  /*****************************************************************************\
> >   *                                                                           *
> >   * Driver init/exit                                                          *
> > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> > index f9d65dd0f2b2..58291a6f093d 100644
> > --- a/drivers/mmc/host/sdhci.h
> > +++ b/drivers/mmc/host/sdhci.h
> > @@ -811,7 +811,6 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
> >  #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
> >
> >  struct sdhci_host *sdhci_alloc_host(struct device *dev, size_t priv_size);
> > -void sdhci_free_host(struct sdhci_host *host);
> >
> >  static inline void *sdhci_priv(struct sdhci_host *host)
> >  {
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 32fa0b2bb912..c40caa3f003f 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);
 
@@ -5000,13 +5000,6 @@  void sdhci_remove_host(struct sdhci_host *host, int dead)
 
 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);
-
 /*****************************************************************************\
  *                                                                           *
  * Driver init/exit                                                          *
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index f9d65dd0f2b2..58291a6f093d 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -811,7 +811,6 @@  static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
 #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
 
 struct sdhci_host *sdhci_alloc_host(struct device *dev, size_t priv_size);
-void sdhci_free_host(struct sdhci_host *host);
 
 static inline void *sdhci_priv(struct sdhci_host *host)
 {