linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.
@ 2021-06-09  2:48 zpershuai
  2021-06-09  8:00 ` Nicolas Ferre
  0 siblings, 1 reply; 2+ messages in thread
From: zpershuai @ 2021-06-09  2:48 UTC (permalink / raw)
  To: Radu Pirea, Mark Brown, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, linux-spi, linux-arm-kernel, linux-kernel
  Cc: zpershuai

When spi_alloc_master() returns null pointer, it’s no need to use
spi_master_put() to release the memory, although spi_master_put()
function has null pointer checks.

Signed-off-by: zpershuai <zpershuai@gmail.com>
---
 drivers/spi/spi-at91-usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c
index 8c83526..e5c2d2c 100644
--- a/drivers/spi/spi-at91-usart.c
+++ b/drivers/spi/spi-at91-usart.c
@@ -531,10 +531,9 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	ret = -ENOMEM;
 	controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
 	if (!controller)
-		goto at91_usart_spi_probe_fail;
+		return -ENOMEM;
 
 	ret = at91_usart_gpio_setup(pdev);
 	if (ret)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.
  2021-06-09  2:48 [PATCH v2] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error zpershuai
@ 2021-06-09  8:00 ` Nicolas Ferre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Ferre @ 2021-06-09  8:00 UTC (permalink / raw)
  To: zpershuai, Radu Pirea, Mark Brown, Alexandre Belloni,
	Ludovic Desroches, linux-spi, linux-arm-kernel, linux-kernel

On 09/06/2021 at 04:48, zpershuai wrote:
> When spi_alloc_master() returns null pointer, it’s no need to use
> spi_master_put() to release the memory, although spi_master_put()
> function has null pointer checks.

So, I don't see the benefit in changing then.
at91_usart_spi_probe_fail label is nicely unified across the probe 
function and having it called once more or once less is no interest to me.

Sorry but NACK until someone persuades me it's needed or common pattern 
among spi drivers.

Regards,
   Nicolas

> Signed-off-by: zpershuai <zpershuai@gmail.com>
> ---
>   drivers/spi/spi-at91-usart.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c
> index 8c83526..e5c2d2c 100644
> --- a/drivers/spi/spi-at91-usart.c
> +++ b/drivers/spi/spi-at91-usart.c
> @@ -531,10 +531,9 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
>          if (IS_ERR(clk))
>                  return PTR_ERR(clk);
> 
> -       ret = -ENOMEM;
>          controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
>          if (!controller)
> -               goto at91_usart_spi_probe_fail;
> +               return -ENOMEM;
> 
>          ret = at91_usart_gpio_setup(pdev);
>          if (ret)
> --
> 2.7.4
> 


-- 
Nicolas Ferre

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-09  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  2:48 [PATCH v2] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error zpershuai
2021-06-09  8:00 ` Nicolas Ferre

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