Re: [PATCH v3 1/9] mmc: core: Move the sanity check of busy detection into mmc_poll_for_busy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30 May 2018 at 04:11, Shawn Lin <shawn.lin@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>
>
> ---
>
> Changes in v3: None
> Changes in v2:
> - remove goto label
>
>  drivers/mmc/core/mmc_ops.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> index 42d6aa8..126fa65 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)

To me this make the code code in mmc_poll_for_busy() more difficult to
understand. Can we instead remain having mmc_poll_for_busy() just
being responsible for the actual the polling.

I understand that checking MMC_CAP_WAIT_WHILE_BUSY needs to be done at
several places before one calls mmc_poll_for_busy(). If you want to
avoid open coding, then I suggest to add helper function instead.

>  {
>         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))
> +               return 0;
> +
>         /* We have an unspecified cmd timeout, use the fallback value. */
>         if (!timeout_ms)
>                 timeout_ms = MMC_OPS_TIMEOUT_MS;
> @@ -570,17 +575,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
>
>

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



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux