diff mbox

[2/2,RFC] mmc: block: Replace "goto retry" by a proper do / while loop

Message ID 1482156225-32517-2-git-send-email-geert@linux-m68k.org (mailing list archive)
State New, archived
Headers show

Commit Message

Geert Uytterhoeven Dec. 19, 2016, 2:03 p.m. UTC
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.

The extra assignment of 0 to err could be avoided:

	do {
		if (!(card->quirks & MMC_QUIRK_INAND_CMD38) ||
		    !(err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
				       INAND_CMD38_ARG_EXT_CSD,
				       arg == MMC_TRIM_ARG ?
				       INAND_CMD38_ARG_TRIM :
				       INAND_CMD38_ARG_ERASE,
				       0)))
			err = mmc_erase(card, from, nr, arg);
	} while (err == -EIO && !mmc_blk_reset(md, card->host, type));

but that looks uglier to me, and makes the quirk handling less obvious.
---
 drivers/mmc/core/block.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

Comments

Ulf Hansson Dec. 29, 2016, 7:03 p.m. UTC | #1
On 19 December 2016 at 15:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks, applied for next!

Kind regards
Uffe

> ---
> Compile-tested only.
>
> The extra assignment of 0 to err could be avoided:
>
>         do {
>                 if (!(card->quirks & MMC_QUIRK_INAND_CMD38) ||
>                     !(err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>                                        INAND_CMD38_ARG_EXT_CSD,
>                                        arg == MMC_TRIM_ARG ?
>                                        INAND_CMD38_ARG_TRIM :
>                                        INAND_CMD38_ARG_ERASE,
>                                        0)))
>                         err = mmc_erase(card, from, nr, arg);
>         } while (err == -EIO && !mmc_blk_reset(md, card->host, type));
>
> but that looks uglier to me, and makes the quirk handling less obvious.
> ---
>  drivers/mmc/core/block.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 8c0e0833d481cf94..4159508df9eea277 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -1164,21 +1164,19 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
>                 arg = MMC_TRIM_ARG;
>         else
>                 arg = MMC_ERASE_ARG;
> -retry:
> -       if (card->quirks & MMC_QUIRK_INAND_CMD38) {
> -               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> -                                INAND_CMD38_ARG_EXT_CSD,
> -                                arg == MMC_TRIM_ARG ?
> -                                INAND_CMD38_ARG_TRIM :
> -                                INAND_CMD38_ARG_ERASE,
> -                                0);
> -               if (err)
> -                       goto out;
> -       }
> -       err = mmc_erase(card, from, nr, arg);
> -out:
> -       if (err == -EIO && !mmc_blk_reset(md, card->host, type))
> -               goto retry;
> +       do {
> +               err = 0;
> +               if (card->quirks & MMC_QUIRK_INAND_CMD38) {
> +                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> +                                        INAND_CMD38_ARG_EXT_CSD,
> +                                        arg == MMC_TRIM_ARG ?
> +                                        INAND_CMD38_ARG_TRIM :
> +                                        INAND_CMD38_ARG_ERASE,
> +                                        0);
> +               }
> +               if (!err)
> +                       err = mmc_erase(card, from, nr, arg);
> +       } while (err == -EIO && !mmc_blk_reset(md, card->host, type));
>         if (!err)
>                 mmc_blk_reset_success(md, type);
>  fail:
> --
> 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
diff mbox

Patch

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 8c0e0833d481cf94..4159508df9eea277 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1164,21 +1164,19 @@  static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
 		arg = MMC_TRIM_ARG;
 	else
 		arg = MMC_ERASE_ARG;
-retry:
-	if (card->quirks & MMC_QUIRK_INAND_CMD38) {
-		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-				 INAND_CMD38_ARG_EXT_CSD,
-				 arg == MMC_TRIM_ARG ?
-				 INAND_CMD38_ARG_TRIM :
-				 INAND_CMD38_ARG_ERASE,
-				 0);
-		if (err)
-			goto out;
-	}
-	err = mmc_erase(card, from, nr, arg);
-out:
-	if (err == -EIO && !mmc_blk_reset(md, card->host, type))
-		goto retry;
+	do {
+		err = 0;
+		if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+					 INAND_CMD38_ARG_EXT_CSD,
+					 arg == MMC_TRIM_ARG ?
+					 INAND_CMD38_ARG_TRIM :
+					 INAND_CMD38_ARG_ERASE,
+					 0);
+		}
+		if (!err)
+			err = mmc_erase(card, from, nr, arg);
+	} while (err == -EIO && !mmc_blk_reset(md, card->host, type));
 	if (!err)
 		mmc_blk_reset_success(md, type);
 fail: