diff mbox

[RFC,RESEND,1/2] mmc: sdio: Factor out retry init card helper function

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

Commit Message

Shawn Lin Dec. 14, 2016, 4:17 a.m. UTC
Add new helper function, mmc_sdio_retry_init_card, to be
reused when trying to retry the init sequence.

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

 drivers/mmc/core/sdio.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Ulf Hansson Dec. 29, 2016, 3:08 p.m. UTC | #1
On 14 December 2016 at 05:17, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> Add new helper function, mmc_sdio_retry_init_card, to be
> reused when trying to retry the init sequence.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
>  drivers/mmc/core/sdio.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
> index ecbc529..47f824b 100644
> --- a/drivers/mmc/core/sdio.c
> +++ b/drivers/mmc/core/sdio.c
> @@ -541,6 +541,18 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card)
>         return err;
>  }
>
> +static void mmc_sdio_retry_init_card(struct mmc_host *host,

I suggest renaming this function to mmc_sdio_resend_if_cond() and...

> +                                    struct mmc_card *card,
> +                                    int *retries)

... remove retries, as I think retries is better handled outside of
this function. Looking at patch 2 also confirms this is a good idea.

> +{
> +       sdio_reset(host);
> +       mmc_go_idle(host);
> +       mmc_send_if_cond(host, host->ocr_avail);
> +       mmc_remove_card(card);
> +       (*retries)--;
> +
> +}
> +
>  /*
>   * Handle the detection and initialisation of a card.
>   *
> @@ -630,11 +642,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
>                 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180,
>                                         ocr_card);
>                 if (err == -EAGAIN) {
> -                       sdio_reset(host);
> -                       mmc_go_idle(host);
> -                       mmc_send_if_cond(host, host->ocr_avail);
> -                       mmc_remove_card(card);
> -                       retries--;
> +                       mmc_sdio_retry_init_card(host, card, &retries);
>                         goto try_again;
>                 } else if (err) {
>                         ocr &= ~R4_18V_PRESENT;
> --
> 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index ecbc529..47f824b 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -541,6 +541,18 @@  static int mmc_sdio_init_uhs_card(struct mmc_card *card)
 	return err;
 }
 
+static void mmc_sdio_retry_init_card(struct mmc_host *host,
+				     struct mmc_card *card,
+				     int *retries)
+{
+	sdio_reset(host);
+	mmc_go_idle(host);
+	mmc_send_if_cond(host, host->ocr_avail);
+	mmc_remove_card(card);
+	(*retries)--;
+
+}
+
 /*
  * Handle the detection and initialisation of a card.
  *
@@ -630,11 +642,7 @@  static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
 		err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180,
 					ocr_card);
 		if (err == -EAGAIN) {
-			sdio_reset(host);
-			mmc_go_idle(host);
-			mmc_send_if_cond(host, host->ocr_avail);
-			mmc_remove_card(card);
-			retries--;
+			mmc_sdio_retry_init_card(host, card, &retries);
 			goto try_again;
 		} else if (err) {
 			ocr &= ~R4_18V_PRESENT;