mmc: slot-gpio: Refactor mmc_gpio_alloc()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 29 Sep 2021 11:17:56 +0000 (14:17 +0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 12 Oct 2021 08:21:20 +0000 (10:21 +0200)
Refactor mmc_gpio_alloc() to drop unneeded indentation level
and double condition. This increases readability of the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210929111757.52625-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/slot-gpio.c

index 05e9074..e365d32 100644 (file)
@@ -39,24 +39,24 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
 
 int mmc_gpio_alloc(struct mmc_host *host)
 {
-       struct mmc_gpio *ctx = devm_kzalloc(host->parent,
-                                           sizeof(*ctx), GFP_KERNEL);
-
-       if (ctx) {
-               ctx->cd_debounce_delay_ms = 200;
-               ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL,
-                               "%s cd", dev_name(host->parent));
-               if (!ctx->cd_label)
-                       return -ENOMEM;
-               ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL,
-                               "%s ro", dev_name(host->parent));
-               if (!ctx->ro_label)
-                       return -ENOMEM;
-               host->slot.handler_priv = ctx;
-               host->slot.cd_irq = -EINVAL;
-       }
+       const char *devname = dev_name(host->parent);
+       struct mmc_gpio *ctx;
+
+       ctx = devm_kzalloc(host->parent, sizeof(*ctx), GFP_KERNEL);
+       if (!ctx)
+               return -ENOMEM;
+
+       ctx->cd_debounce_delay_ms = 200;
+       ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s cd", devname);
+       if (!ctx->cd_label)
+               return -ENOMEM;
+       ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s ro", devname);
+       if (!ctx->ro_label)
+               return -ENOMEM;
+       host->slot.handler_priv = ctx;
+       host->slot.cd_irq = -EINVAL;
 
-       return ctx ? 0 : -ENOMEM;
+       return 0;
 }
 
 int mmc_gpio_get_ro(struct mmc_host *host)