diff mbox series

[v3,02/36] mmc: atmel: Use devm_mmc_alloc_host() helper

Message ID 0688b77b93d27bd2f2e155fca6f53a1766fc3a80.1748933789.git.zhoubinbin@loongson.cn
State New
Headers show
Series mmc: Cleanup mmc_alloc_host() usage | expand

Commit Message

Binbin Zhou June 3, 2025, 12:25 p.m. UTC
Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Aubin Constans <aubin.constans@microchip.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/atmel-mci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Aubin Constans June 10, 2025, 9:21 a.m. UTC | #1
On 03/06/2025 14:25, Binbin Zhou wrote:
> Use new function devm_mmc_alloc_host() to simplify the code.
> 
> Cc: Aubin Constans <aubin.constans@microchip.com>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>

Acked-by: Aubin Constans <aubin.constans@microchip.com>

> ---
>   drivers/mmc/host/atmel-mci.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 14e981b834b6..f72fe4b805f6 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2247,7 +2247,7 @@ static int atmci_init_slot(struct atmel_mci *host,
>          struct atmel_mci_slot           *slot;
>          int ret;
> 
> -       mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), dev);
> +       mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
>          if (!mmc)
>                  return -ENOMEM;
> 
> @@ -2320,10 +2320,8 @@ static int atmci_init_slot(struct atmel_mci *host,
>          host->slot[id] = slot;
>          mmc_regulator_get_supply(mmc);
>          ret = mmc_add_host(mmc);
> -       if (ret) {
> -               mmc_free_host(mmc);
> +       if (ret)
>                  return ret;
> -       }
> 
>          if (slot->detect_pin) {
>                  timer_setup(&slot->detect_timer, atmci_detect_change, 0);
> @@ -2361,7 +2359,6 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>          }
> 
>          slot->host->slot[id] = NULL;
> -       mmc_free_host(slot->mmc);
>   }
> 
>   static int atmci_configure_dma(struct atmel_mci *host)
> --
> 2.47.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 14e981b834b6..f72fe4b805f6 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2247,7 +2247,7 @@  static int atmci_init_slot(struct atmel_mci *host,
 	struct atmel_mci_slot		*slot;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -2320,10 +2320,8 @@  static int atmci_init_slot(struct atmel_mci *host,
 	host->slot[id] = slot;
 	mmc_regulator_get_supply(mmc);
 	ret = mmc_add_host(mmc);
-	if (ret) {
-		mmc_free_host(mmc);
+	if (ret)
 		return ret;
-	}
 
 	if (slot->detect_pin) {
 		timer_setup(&slot->detect_timer, atmci_detect_change, 0);
@@ -2361,7 +2359,6 @@  static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 	}
 
 	slot->host->slot[id] = NULL;
-	mmc_free_host(slot->mmc);
 }
 
 static int atmci_configure_dma(struct atmel_mci *host)