diff mbox series

mmc: sdhci: use goto rather than return directly

Message ID 1539677982-13762-1-git-send-email-zhang.chunyan@linaro.org (mailing list archive)
State New, archived
Headers show
Series mmc: sdhci: use goto rather than return directly | expand

Commit Message

Chunyan Zhang Oct. 16, 2018, 8:19 a.m. UTC
The driver should clean resources requested in the function before
unnormal return.

CC: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Fixes: bd9b902798ab ("mmc: sdhci: Implement an SDHCI-specific bounce buffer")
---
 drivers/mmc/host/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Adrian Hunter Oct. 16, 2018, 8:28 a.m. UTC | #1
On 16/10/18 11:19 AM, Chunyan Zhang wrote:
> The driver should clean resources requested in the function before
> unnormal return.
> 
> CC: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> Fixes: bd9b902798ab ("mmc: sdhci: Implement an SDHCI-specific bounce buffer")
> ---
>  drivers/mmc/host/sdhci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 1b3fbd9..f6b57e1 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3991,7 +3991,7 @@ int sdhci_setup_host(struct sdhci_host *host)
>  		/* This may alter mmc->*_blk_* parameters */
>  		ret = sdhci_allocate_bounce_buffer(host);

Do we need the error return?  It seems to be zero always.

>  		if (ret)
> -			return ret;
> +			goto unreg;
>  	}
>  
>  	return 0;
>
Chunyan Zhang Oct. 17, 2018, 2:35 a.m. UTC | #2
On Tue, 16 Oct 2018 at 16:30, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 16/10/18 11:19 AM, Chunyan Zhang wrote:
> > The driver should clean resources requested in the function before
> > unnormal return.
> >
> > CC: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> > Fixes: bd9b902798ab ("mmc: sdhci: Implement an SDHCI-specific bounce buffer")
> > ---
> >  drivers/mmc/host/sdhci.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index 1b3fbd9..f6b57e1 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -3991,7 +3991,7 @@ int sdhci_setup_host(struct sdhci_host *host)
> >               /* This may alter mmc->*_blk_* parameters */
> >               ret = sdhci_allocate_bounce_buffer(host);
>
> Do we need the error return?  It seems to be zero always.

Or we don't need to check 'ret' for now, right?

>
> >               if (ret)
> > -                     return ret;
> > +                     goto unreg;
> >       }
> >
> >       return 0;
> >
>
Ulf Hansson Oct. 23, 2018, 1:01 p.m. UTC | #3
On 16 October 2018 at 10:19, Chunyan Zhang <zhang.chunyan@linaro.org> wrote:
> The driver should clean resources requested in the function before
> unnormal return.
>
> CC: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> Fixes: bd9b902798ab ("mmc: sdhci: Implement an SDHCI-specific bounce buffer")
> ---
>  drivers/mmc/host/sdhci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 1b3fbd9..f6b57e1 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3991,7 +3991,7 @@ int sdhci_setup_host(struct sdhci_host *host)
>                 /* This may alter mmc->*_blk_* parameters */
>                 ret = sdhci_allocate_bounce_buffer(host);
>                 if (ret)
> -                       return ret;
> +                       goto unreg;

Instead of making the error path a bit more complicated, I suggest to
convert sdhci_allocate_bounce_buffer() from returning an int to a
void. Simply because it always returns 0 and thus we can remove this
error path altogether.

>         }
>
>         return 0;
> --
> 2.7.4
>

Kind regards
Uffe
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 1b3fbd9..f6b57e1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3991,7 +3991,7 @@  int sdhci_setup_host(struct sdhci_host *host)
 		/* This may alter mmc->*_blk_* parameters */
 		ret = sdhci_allocate_bounce_buffer(host);
 		if (ret)
-			return ret;
+			goto unreg;
 	}
 
 	return 0;