linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
@ 2022-12-10 11:52 Christophe JAILLET
  2022-12-10 14:48 ` Max Filippov
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2022-12-10 11:52 UTC (permalink / raw)
  To: Max Filippov, Mark Brown, Yang Yingliang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-xtensa,
	linux-spi

'master' is allocated with devm_spi_alloc_master(), there is no need to
put it explicitly in the remove function.

Fixes: 478cc2fc3dd7 ("spi: xtensa-xtfpga: Switch to use devm_spi_alloc_master()")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/spi/spi-xtensa-xtfpga.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c
index 2fa7608f94cd..271ae98f441c 100644
--- a/drivers/spi/spi-xtensa-xtfpga.c
+++ b/drivers/spi/spi-xtensa-xtfpga.c
@@ -123,7 +123,6 @@ static int xtfpga_spi_remove(struct platform_device *pdev)
 	struct xtfpga_spi *xspi = spi_master_get_devdata(master);
 
 	spi_bitbang_stop(&xspi->bitbang);
-	spi_master_put(master);
 
 	return 0;
 }
-- 
2.34.1


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

* Re: [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
  2022-12-10 11:52 [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove() Christophe JAILLET
@ 2022-12-10 14:48 ` Max Filippov
  2022-12-12 15:36   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Max Filippov @ 2022-12-10 14:48 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mark Brown, Yang Yingliang, linux-kernel, kernel-janitors,
	linux-xtensa, linux-spi

Hi Christophe,

On Sat, Dec 10, 2022 at 3:52 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> 'master' is allocated with devm_spi_alloc_master(), there is no need to
> put it explicitly in the remove function.
>
> Fixes: 478cc2fc3dd7 ("spi: xtensa-xtfpga: Switch to use devm_spi_alloc_master()")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/spi/spi-xtensa-xtfpga.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c
> index 2fa7608f94cd..271ae98f441c 100644
> --- a/drivers/spi/spi-xtensa-xtfpga.c
> +++ b/drivers/spi/spi-xtensa-xtfpga.c
> @@ -123,7 +123,6 @@ static int xtfpga_spi_remove(struct platform_device *pdev)
>         struct xtfpga_spi *xspi = spi_master_get_devdata(master);
>
>         spi_bitbang_stop(&xspi->bitbang);
> -       spi_master_put(master);

This put is matching the get in the spi_bitbang_start.
It was discussed here:
https://lore.kernel.org/linux-spi/CAMo8BfJaD7pG_iutY8jordysjChyzhTpVSqpxXh3QoZsj2QmaQ@mail.gmail.com/

-- 
Thanks.
-- Max

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

* Re: [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
  2022-12-10 14:48 ` Max Filippov
@ 2022-12-12 15:36   ` Mark Brown
  2022-12-13  1:30     ` Yang Yingliang
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2022-12-12 15:36 UTC (permalink / raw)
  To: Max Filippov
  Cc: Christophe JAILLET, Yang Yingliang, linux-kernel, kernel-janitors,
	linux-xtensa, linux-spi

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

On Sat, Dec 10, 2022 at 06:48:02AM -0800, Max Filippov wrote:
> Hi Christophe,
> 
> On Sat, Dec 10, 2022 at 3:52 AM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:

> > 'master' is allocated with devm_spi_alloc_master(), there is no need to
> > put it explicitly in the remove function.

> >         spi_bitbang_stop(&xspi->bitbang);
> > -       spi_master_put(master);

> This put is matching the get in the spi_bitbang_start.
> It was discussed here:
> https://lore.kernel.org/linux-spi/CAMo8BfJaD7pG_iutY8jordysjChyzhTpVSqpxXh3QoZsj2QmaQ@mail.gmail.com/

Probably worth a comment though since it is a bit of a gotcha.  Ideally
we'd improve this in the bitbang code but that's harder.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
  2022-12-12 15:36   ` Mark Brown
@ 2022-12-13  1:30     ` Yang Yingliang
  2022-12-13 11:40       ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-12-13  1:30 UTC (permalink / raw)
  To: Mark Brown, Max Filippov
  Cc: Christophe JAILLET, linux-kernel, kernel-janitors, linux-xtensa,
	linux-spi, yangyingliang


On 2022/12/12 23:36, Mark Brown wrote:
> On Sat, Dec 10, 2022 at 06:48:02AM -0800, Max Filippov wrote:
>> Hi Christophe,
>>
>> On Sat, Dec 10, 2022 at 3:52 AM Christophe JAILLET
>> <christophe.jaillet@wanadoo.fr> wrote:
>>> 'master' is allocated with devm_spi_alloc_master(), there is no need to
>>> put it explicitly in the remove function.
>>>          spi_bitbang_stop(&xspi->bitbang);
>>> -       spi_master_put(master);
>> This put is matching the get in the spi_bitbang_start.
>> It was discussed here:
>> https://lore.kernel.org/linux-spi/CAMo8BfJaD7pG_iutY8jordysjChyzhTpVSqpxXh3QoZsj2QmaQ@mail.gmail.com/
> Probably worth a comment though since it is a bit of a gotcha.  Ideally
> we'd improve this in the bitbang code but that's harder.
Ideally, spi_bitbang_stop() should undo spi_bitbang_start(). shall we 
move spi_master_put() in spi_bitbang_stop() instead of
calling it separately in drivers?

Thanks,
Yang

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

* Re: [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
  2022-12-13  1:30     ` Yang Yingliang
@ 2022-12-13 11:40       ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-12-13 11:40 UTC (permalink / raw)
  To: Yang Yingliang
  Cc: Max Filippov, Christophe JAILLET, linux-kernel, kernel-janitors,
	linux-xtensa, linux-spi

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

On Tue, Dec 13, 2022 at 09:30:32AM +0800, Yang Yingliang wrote:
> On 2022/12/12 23:36, Mark Brown wrote:
> > On Sat, Dec 10, 2022 at 06:48:02AM -0800, Max Filippov wrote:

> > Probably worth a comment though since it is a bit of a gotcha.  Ideally
> > we'd improve this in the bitbang code but that's harder.

> Ideally, spi_bitbang_stop() should undo spi_bitbang_start(). shall we move
> spi_master_put() in spi_bitbang_stop() instead of
> calling it separately in drivers?

Ideally like I say, there's issues with devm IIRC which make it more
complicated than just adding a put() there.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2022-12-13 11:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-10 11:52 [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove() Christophe JAILLET
2022-12-10 14:48 ` Max Filippov
2022-12-12 15:36   ` Mark Brown
2022-12-13  1:30     ` Yang Yingliang
2022-12-13 11:40       ` Mark Brown

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