linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] memstick: Convert to platform remove callback returning void
@ 2024-04-10 14:05 Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 1/3] memstick: rtsx_pci_ms: Drop if block with always false condition Uwe Kleine-König
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 14:05 UTC (permalink / raw)
  To: Maxim Levitsky, Alex Dubov, Ulf Hansson; +Cc: linux-mmc, kernel

Hello,

this series converts all platform drivers below drivers/memstick/ to not
use struct platform_device::remove() any more. See commit 5c5a7680e67b
("platform: Provide a remove callback that returns no value") for an
extended explanation and the eventual goal.

All conversations are trivial, because the driver's .remove() callbacks
returned zero unconditionally.

There are no interdependencies between these patches, so they can be
applied independently if needed. This is merge window material.

Best regards
Uwe

Uwe Kleine-König (3):
  memstick: rtsx_pci_ms: Drop if block with always false condition
  memstick: rtsx_pci_ms: Convert to platform remove callback returning
    void
  memstick: rtsx_usb_ms: Convert to platform remove callback returning
    void

 drivers/memstick/host/rtsx_pci_ms.c | 9 ++-------
 drivers/memstick/host/rtsx_usb_ms.c | 6 ++----
 2 files changed, 4 insertions(+), 11 deletions(-)

base-commit: 6ebf211bb11dfc004a2ff73a9de5386fa309c430
-- 
2.43.0


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

* [PATCH 1/3] memstick: rtsx_pci_ms: Drop if block with always false condition
  2024-04-10 14:05 [PATCH 0/3] memstick: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-04-10 14:05 ` Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 2/3] memstick: rtsx_pci_ms: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 14:05 UTC (permalink / raw)
  To: Maxim Levitsky, Alex Dubov, Ulf Hansson; +Cc: linux-mmc, kernel

rtsx_pci_ms_drv_remove() is only called after rtsx_pci_ms_drv_probe()
completed successfully. In this case platform_set_drvdata() was called
with a non-NULL argument and so platform_get_drvdata() won't return
NULL.

Simplify by removing the if block with the always false condition.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/memstick/host/rtsx_pci_ms.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index 15720a4afac2..7c6dba6de230 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -581,9 +581,6 @@ static int rtsx_pci_ms_drv_remove(struct platform_device *pdev)
 	struct memstick_host *msh;
 	int rc;
 
-	if (!host)
-		return 0;
-
 	pcr = host->pcr;
 	pcr->slots[RTSX_MS_CARD].p_dev = NULL;
 	pcr->slots[RTSX_MS_CARD].card_event = NULL;
-- 
2.43.0


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

* [PATCH 2/3] memstick: rtsx_pci_ms: Convert to platform remove callback returning void
  2024-04-10 14:05 [PATCH 0/3] memstick: Convert to platform remove callback returning void Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 1/3] memstick: rtsx_pci_ms: Drop if block with always false condition Uwe Kleine-König
@ 2024-04-10 14:05 ` Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 3/3] memstick: rtsx_usb_ms: " Uwe Kleine-König
  2024-04-25 16:21 ` [PATCH 0/3] memstick: " Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 14:05 UTC (permalink / raw)
  To: Maxim Levitsky, Alex Dubov, Ulf Hansson; +Cc: linux-mmc, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/memstick/host/rtsx_pci_ms.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c
index 7c6dba6de230..980a54513e6c 100644
--- a/drivers/memstick/host/rtsx_pci_ms.c
+++ b/drivers/memstick/host/rtsx_pci_ms.c
@@ -574,7 +574,7 @@ static int rtsx_pci_ms_drv_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int rtsx_pci_ms_drv_remove(struct platform_device *pdev)
+static void rtsx_pci_ms_drv_remove(struct platform_device *pdev)
 {
 	struct realtek_pci_ms *host = platform_get_drvdata(pdev);
 	struct rtsx_pcr *pcr;
@@ -610,8 +610,6 @@ static int rtsx_pci_ms_drv_remove(struct platform_device *pdev)
 
 	dev_dbg(&(pdev->dev),
 		": Realtek PCI-E Memstick controller has been removed\n");
-
-	return 0;
 }
 
 static struct platform_device_id rtsx_pci_ms_ids[] = {
@@ -625,7 +623,7 @@ MODULE_DEVICE_TABLE(platform, rtsx_pci_ms_ids);
 
 static struct platform_driver rtsx_pci_ms_driver = {
 	.probe		= rtsx_pci_ms_drv_probe,
-	.remove		= rtsx_pci_ms_drv_remove,
+	.remove_new	= rtsx_pci_ms_drv_remove,
 	.id_table       = rtsx_pci_ms_ids,
 	.suspend	= rtsx_pci_ms_suspend,
 	.resume		= rtsx_pci_ms_resume,
-- 
2.43.0


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

* [PATCH 3/3] memstick: rtsx_usb_ms: Convert to platform remove callback returning void
  2024-04-10 14:05 [PATCH 0/3] memstick: Convert to platform remove callback returning void Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 1/3] memstick: rtsx_pci_ms: Drop if block with always false condition Uwe Kleine-König
  2024-04-10 14:05 ` [PATCH 2/3] memstick: rtsx_pci_ms: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-04-10 14:05 ` Uwe Kleine-König
  2024-04-25 16:21 ` [PATCH 0/3] memstick: " Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 14:05 UTC (permalink / raw)
  To: Maxim Levitsky, Alex Dubov, Ulf Hansson; +Cc: linux-mmc, kernel

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/memstick/host/rtsx_usb_ms.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index 29271ad4728a..246876ac713c 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -805,7 +805,7 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
+static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
 {
 	struct rtsx_usb_ms *host = platform_get_drvdata(pdev);
 	struct memstick_host *msh = host->msh;
@@ -840,8 +840,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
 		": Realtek USB Memstick controller has been removed\n");
 	memstick_free_host(msh);
 	platform_set_drvdata(pdev, NULL);
-
-	return 0;
 }
 
 static struct platform_device_id rtsx_usb_ms_ids[] = {
@@ -855,7 +853,7 @@ MODULE_DEVICE_TABLE(platform, rtsx_usb_ms_ids);
 
 static struct platform_driver rtsx_usb_ms_driver = {
 	.probe		= rtsx_usb_ms_drv_probe,
-	.remove		= rtsx_usb_ms_drv_remove,
+	.remove_new	= rtsx_usb_ms_drv_remove,
 	.id_table       = rtsx_usb_ms_ids,
 	.driver		= {
 		.name	= "rtsx_usb_ms",
-- 
2.43.0


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

* Re: [PATCH 0/3] memstick: Convert to platform remove callback returning void
  2024-04-10 14:05 [PATCH 0/3] memstick: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2024-04-10 14:05 ` [PATCH 3/3] memstick: rtsx_usb_ms: " Uwe Kleine-König
@ 2024-04-25 16:21 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2024-04-25 16:21 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Maxim Levitsky, Alex Dubov, linux-mmc, kernel

On Wed, 10 Apr 2024 at 16:05, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello,
>
> this series converts all platform drivers below drivers/memstick/ to not
> use struct platform_device::remove() any more. See commit 5c5a7680e67b
> ("platform: Provide a remove callback that returns no value") for an
> extended explanation and the eventual goal.
>
> All conversations are trivial, because the driver's .remove() callbacks
> returned zero unconditionally.
>
> There are no interdependencies between these patches, so they can be
> applied independently if needed. This is merge window material.
>
> Best regards
> Uwe
>
> Uwe Kleine-König (3):
>   memstick: rtsx_pci_ms: Drop if block with always false condition
>   memstick: rtsx_pci_ms: Convert to platform remove callback returning
>     void
>   memstick: rtsx_usb_ms: Convert to platform remove callback returning
>     void
>
>  drivers/memstick/host/rtsx_pci_ms.c | 9 ++-------
>  drivers/memstick/host/rtsx_usb_ms.c | 6 ++----
>  2 files changed, 4 insertions(+), 11 deletions(-)

The series applied for next, thanks!

Kind regards
Uffe

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

end of thread, other threads:[~2024-04-25 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 14:05 [PATCH 0/3] memstick: Convert to platform remove callback returning void Uwe Kleine-König
2024-04-10 14:05 ` [PATCH 1/3] memstick: rtsx_pci_ms: Drop if block with always false condition Uwe Kleine-König
2024-04-10 14:05 ` [PATCH 2/3] memstick: rtsx_pci_ms: Convert to platform remove callback returning void Uwe Kleine-König
2024-04-10 14:05 ` [PATCH 3/3] memstick: rtsx_usb_ms: " Uwe Kleine-König
2024-04-25 16:21 ` [PATCH 0/3] memstick: " 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).