]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mmc: mmci: Break out a helper function
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 16 Jun 2023 20:42:27 +0000 (22:42 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 19 Jun 2023 11:14:26 +0000 (13:14 +0200)
These four lines clearing, masking and resetting the state
of the busy detect state machine is repeated five times in
the code so break this out to a small helper so things are
easier to read.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230405-pl180-busydetect-fix-v7-9-69a7164f2a61@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/mmci.c

index 6bd8b367bb8feefc6222b419e5ebc20596114e5f..8a661ea1a2d1dbc20873d1b7d81dd5d563f8657f 100644 (file)
@@ -654,6 +654,17 @@ static u32 ux500v2_get_dctrl_cfg(struct mmci_host *host)
        return MCI_DPSM_ENABLE | (host->data->blksz << 16);
 }
 
+static void ux500_busy_clear_mask_done(struct mmci_host *host)
+{
+       void __iomem *base = host->base;
+
+       writel(host->variant->busy_detect_mask, base + MMCICLEAR);
+       writel(readl(base + MMCIMASK0) &
+              ~host->variant->busy_detect_mask, base + MMCIMASK0);
+       host->busy_state = MMCI_BUSY_DONE;
+       host->busy_status = 0;
+}
+
 /*
  * ux500_busy_complete() - this will wait until the busy status
  * goes off, saving any status that occur in the meantime into
@@ -678,11 +689,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
 
        if (status & err_msk) {
                /* Stop any ongoing busy detection if an error occurs */
-               writel(host->variant->busy_detect_mask, base + MMCICLEAR);
-               writel(readl(base + MMCIMASK0) &
-                      ~host->variant->busy_detect_mask, base + MMCIMASK0);
-               host->busy_state = MMCI_BUSY_DONE;
-               host->busy_status = 0;
+               ux500_busy_clear_mask_done(host);
                goto out_ret_state;
        }
 
@@ -724,10 +731,7 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
                        retries--;
                }
                dev_dbg(mmc_dev(host->mmc), "no busy signalling in time\n");
-               writel(host->variant->busy_detect_mask, base + MMCICLEAR);
-               writel(readl(base + MMCIMASK0) &
-                      ~host->variant->busy_detect_mask, base + MMCIMASK0);
-               host->busy_state = MMCI_BUSY_DONE;
+               ux500_busy_clear_mask_done(host);
                break;
 
        /*
@@ -749,18 +753,15 @@ static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
                } else {
                        dev_dbg(mmc_dev(host->mmc),
                                "lost busy status when waiting for busy start IRQ\n");
-                       writel(host->variant->busy_detect_mask, base + MMCICLEAR);
-                       writel(readl(base + MMCIMASK0) &
-                              ~host->variant->busy_detect_mask, base + MMCIMASK0);
-                       host->busy_state = MMCI_BUSY_DONE;
-                       host->busy_status = 0;
+                       ux500_busy_clear_mask_done(host);
                }
                break;
 
        case MMCI_BUSY_WAITING_FOR_END_IRQ:
                if (!(status & host->variant->busy_detect_flag)) {
                        host->busy_status |= status & (MCI_CMDSENT | MCI_CMDRESPEND);
-                       host->busy_state = MMCI_BUSY_DONE;
+                       writel(host->variant->busy_detect_mask, base + MMCICLEAR);
+                       ux500_busy_clear_mask_done(host);
                } else {
                        dev_dbg(mmc_dev(host->mmc),
                                "busy status still asserted when handling busy end IRQ - will keep waiting\n");