linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection
Date: Tue, 12 Jan 2016 16:07:12 +0100	[thread overview]
Message-ID: <CAPDyKFqFN5EYFJCJ9AcNBBfAhuuTCkxHjLwrbGH9etucM3kmCA@mail.gmail.com> (raw)
In-Reply-To: <5682E3F9.4040006@users.sourceforge.net>

On 29 December 2015 at 20:50, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 29 Dec 2015 20:28:46 +0100
>
> This issue was detected by using the Coccinelle software.
>
> Move the jump label directly before the desired log statement
> so that the variable "err" will not be checked once more
> after it was determined that a call of the function
> "__mmc_set_signal_voltage" or "__mmc_switch" failed.
> Use the identifier "report_failure" instead of the label "err".

I understand the report, but this unfortunate not the proper solution.

Instead, the "if (err)" check should be entirely removed from the err label.

To do that, mmc_select_hs200() should pre validate whether 4 or 8 -bit
bus is supported which then prevents starting to switch to hs200
unless really supported. Moreover it means mmc_select_bus_width()
shall return 0 to indicate success instead of as now, returning a
positive value or 0.

Kind regards
Uffe

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mmc/core/mmc.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 549c56e..866f72b 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1256,7 +1256,7 @@ static int mmc_select_hs200(struct mmc_card *card)
>
>         /* If fails try again during next card power cycle */
>         if (err)
> -               goto err;
> +               goto report_failure;
>
>         mmc_select_driver_type(card);
>
> @@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)
>                                    card->ext_csd.generic_cmd6_time,
>                                    true, send_status, true);
>                 if (err)
> -                       goto err;
> +                       goto report_failure;
>                 old_timing = host->ios.timing;
>                 mmc_set_timing(host, MMC_TIMING_MMC_HS200);
>                 if (!send_status) {
> @@ -1289,10 +1289,11 @@ static int mmc_select_hs200(struct mmc_card *card)
>                                 mmc_set_timing(host, old_timing);
>                 }
>         }
> -err:
> -       if (err)
> +       if (err) {
> +report_failure:
>                 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
>                        __func__, err);
> +       }
>         return err;
>  }
>
> --
> 2.6.3
>

  reply	other threads:[~2016-01-12 15:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-29 19:50 ` [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection SF Markus Elfring
2016-01-12 15:07   ` Ulf Hansson [this message]
2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
2016-02-21  9:11     ` Sascha Sommer
2015-12-29 21:02   ` [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection SF Markus Elfring
2016-02-21  9:15     ` Sascha Sommer
2016-01-27 14:15   ` [PATCH 0/2] mmc-host: Fine-tuning for one function Ulf Hansson
2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
2016-08-19 21:10   ` [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20  9:25     ` walter harms
2016-08-19 21:12   ` [PATCH 2/2] mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user() SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPDyKFqFN5EYFJCJ9AcNBBfAhuuTCkxHjLwrbGH9etucM3kmCA@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=elfring@users.sourceforge.net \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).