linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: use goto rather than return directly
@ 2018-10-16  8:19 Chunyan Zhang
  2018-10-16  8:28 ` Adrian Hunter
  2018-10-23 13:01 ` Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Chunyan Zhang @ 2018-10-16  8:19 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: linux-mmc, linux-kernel, Linus Walleij, Chunyan Zhang

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;
 	}
 
 	return 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: sdhci: use goto rather than return directly
  2018-10-16  8:19 [PATCH] mmc: sdhci: use goto rather than return directly Chunyan Zhang
@ 2018-10-16  8:28 ` Adrian Hunter
  2018-10-17  2:35   ` Chunyan Zhang
  2018-10-23 13:01 ` Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Adrian Hunter @ 2018-10-16  8:28 UTC (permalink / raw)
  To: Chunyan Zhang, Ulf Hansson
  Cc: linux-mmc, linux-kernel, Linus Walleij, Chunyan Zhang

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;
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: sdhci: use goto rather than return directly
  2018-10-16  8:28 ` Adrian Hunter
@ 2018-10-17  2:35   ` Chunyan Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Chunyan Zhang @ 2018-10-17  2:35 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Chunyan Zhang, Ulf Hansson, linux-mmc, Linux Kernel Mailing List,
	linus.walleij

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;
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: sdhci: use goto rather than return directly
  2018-10-16  8:19 [PATCH] mmc: sdhci: use goto rather than return directly Chunyan Zhang
  2018-10-16  8:28 ` Adrian Hunter
@ 2018-10-23 13:01 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2018-10-23 13:01 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List,
	Linus Walleij, Chunyan Zhang

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-23 13:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16  8:19 [PATCH] mmc: sdhci: use goto rather than return directly Chunyan Zhang
2018-10-16  8:28 ` Adrian Hunter
2018-10-17  2:35   ` Chunyan Zhang
2018-10-23 13:01 ` Ulf Hansson

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).