diff mbox

[01/11] mmc: core: Move the sanity check of busy detection into mmc_poll_for_busy()

Message ID 1527228991-216284-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin May 25, 2018, 6:16 a.m. UTC
In preparation for reusing mmc_poll_for_busy() to avoid duplication
of code for polling busy.

No functional change intended.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/core/mmc_ops.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Ulf Hansson May 25, 2018, 8:36 a.m. UTC | #1
On 25 May 2018 at 08:16, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> In preparation for reusing mmc_poll_for_busy() to avoid duplication
> of code for polling busy.
>
> No functional change intended.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
>  drivers/mmc/core/mmc_ops.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> index 42d6aa8..88f34fd 100644
> --- a/drivers/mmc/core/mmc_ops.c
> +++ b/drivers/mmc/core/mmc_ops.c
> @@ -447,7 +447,7 @@ int mmc_switch_status(struct mmc_card *card)
>  }
>
>  static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
> -                       bool send_status, bool retry_crc_err)
> +                       bool send_status, bool retry_crc_err, bool use_r1b_resp)
>  {
>         struct mmc_host *host = card->host;
>         int err;
> @@ -456,6 +456,11 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
>         bool expired = false;
>         bool busy = false;
>
> +       /* If SPI or using HW busy detection, then we don't need to poll. */
> +       if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
> +               mmc_host_is_spi(host))
> +               goto out;

Change from "goto out", to "return 0";

> +
>         /* We have an unspecified cmd timeout, use the fallback value. */
>         if (!timeout_ms)
>                 timeout_ms = MMC_OPS_TIMEOUT_MS;
> @@ -502,6 +507,7 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
>                 }
>         } while (busy);
>
> +out:

Drop the "out" label.

>         return 0;
>  }
>
> @@ -570,17 +576,12 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
>         if (!use_busy_signal)
>                 goto out;
>
> -       /*If SPI or used HW busy detection above, then we don't need to poll. */
> -       if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
> -               mmc_host_is_spi(host))
> -               goto out_tim;
> -
>         /* Let's try to poll to find out when the command is completed. */
> -       err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err);
> +       err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err,
> +                               use_r1b_resp);
>         if (err)
>                 goto out;
>
> -out_tim:
>         /* Switch to new timing before check switch status. */
>         if (timing)
>                 mmc_set_timing(host, timing);
> --
> 1.9.1
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 42d6aa8..88f34fd 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -447,7 +447,7 @@  int mmc_switch_status(struct mmc_card *card)
 }
 
 static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
-			bool send_status, bool retry_crc_err)
+			bool send_status, bool retry_crc_err, bool use_r1b_resp)
 {
 	struct mmc_host *host = card->host;
 	int err;
@@ -456,6 +456,11 @@  static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
 	bool expired = false;
 	bool busy = false;
 
+	/* If SPI or using HW busy detection, then we don't need to poll. */
+	if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
+		mmc_host_is_spi(host))
+		goto out;
+
 	/* We have an unspecified cmd timeout, use the fallback value. */
 	if (!timeout_ms)
 		timeout_ms = MMC_OPS_TIMEOUT_MS;
@@ -502,6 +507,7 @@  static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
 		}
 	} while (busy);
 
+out:
 	return 0;
 }
 
@@ -570,17 +576,12 @@  int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
 	if (!use_busy_signal)
 		goto out;
 
-	/*If SPI or used HW busy detection above, then we don't need to poll. */
-	if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) ||
-		mmc_host_is_spi(host))
-		goto out_tim;
-
 	/* Let's try to poll to find out when the command is completed. */
-	err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err);
+	err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err,
+				use_r1b_resp);
 	if (err)
 		goto out;
 
-out_tim:
 	/* Switch to new timing before check switch status. */
 	if (timing)
 		mmc_set_timing(host, timing);