linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] um: Convert to platform remove callback returning void
@ 2024-03-10  7:52 Uwe Kleine-König
  2024-03-10  7:52 ` [PATCH 1/2] um: rtc: " Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-10  7:52 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg; +Cc: linux-um, kernel

Hello,

this series converts all platform drivers below arch/um to stop using
struct platform_driver::remove(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended
explanation and the eventual goal.

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

There are no interdependencies between these patches, still I'd expect
them to be picked up together.

Uwe Kleine-König (2):
  um: rtc: Convert to platform remove callback returning void
  um: virtio_uml: Convert to platform remove callback returning void

 arch/um/drivers/rtc_kern.c   | 5 ++---
 arch/um/drivers/virtio_uml.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

base-commit: 8ffc8b1bbd505e27e2c8439d326b6059c906c9dd
-- 
2.43.0



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

* [PATCH 1/2] um: rtc: Convert to platform remove callback returning void
  2024-03-10  7:52 [PATCH 0/2] um: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-03-10  7:52 ` Uwe Kleine-König
  2024-03-11  8:22   ` Geert Uytterhoeven
  2024-03-10  7:52 ` [PATCH 2/2] um: virtio_uml: " Uwe Kleine-König
  2024-04-29  7:35 ` [PATCH 0/2] um: " Uwe Kleine-König
  2 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-10  7:52 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg; +Cc: linux-um, 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>
---
 arch/um/drivers/rtc_kern.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/rtc_kern.c b/arch/um/drivers/rtc_kern.c
index 97ceb205cfe6..3a1582219c4b 100644
--- a/arch/um/drivers/rtc_kern.c
+++ b/arch/um/drivers/rtc_kern.c
@@ -168,16 +168,15 @@ static int uml_rtc_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int uml_rtc_remove(struct platform_device *pdev)
+static void uml_rtc_remove(struct platform_device *pdev)
 {
 	device_init_wakeup(&pdev->dev, 0);
 	uml_rtc_cleanup();
-	return 0;
 }
 
 static struct platform_driver uml_rtc_driver = {
 	.probe = uml_rtc_probe,
-	.remove = uml_rtc_remove,
+	.remove_new = uml_rtc_remove,
 	.driver = {
 		.name = "uml-rtc",
 	},
-- 
2.43.0



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

* [PATCH 2/2] um: virtio_uml: Convert to platform remove callback returning void
  2024-03-10  7:52 [PATCH 0/2] um: Convert to platform remove callback returning void Uwe Kleine-König
  2024-03-10  7:52 ` [PATCH 1/2] um: rtc: " Uwe Kleine-König
@ 2024-03-10  7:52 ` Uwe Kleine-König
  2024-03-11  8:22   ` Geert Uytterhoeven
  2024-04-29  7:35 ` [PATCH 0/2] um: " Uwe Kleine-König
  2 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2024-03-10  7:52 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg; +Cc: linux-um, 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>
---
 arch/um/drivers/virtio_uml.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 8adca2000e51..77faa2cf3a13 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -1241,12 +1241,11 @@ static int virtio_uml_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static int virtio_uml_remove(struct platform_device *pdev)
+static void virtio_uml_remove(struct platform_device *pdev)
 {
 	struct virtio_uml_device *vu_dev = platform_get_drvdata(pdev);
 
 	unregister_virtio_device(&vu_dev->vdev);
-	return 0;
 }
 
 /* Command line device list */
@@ -1445,7 +1444,7 @@ static int virtio_uml_resume(struct platform_device *pdev)
 
 static struct platform_driver virtio_uml_driver = {
 	.probe = virtio_uml_probe,
-	.remove = virtio_uml_remove,
+	.remove_new = virtio_uml_remove,
 	.driver = {
 		.name = "virtio-uml",
 		.of_match_table = virtio_uml_match,
-- 
2.43.0



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

* Re: [PATCH 1/2] um: rtc: Convert to platform remove callback returning void
  2024-03-10  7:52 ` [PATCH 1/2] um: rtc: " Uwe Kleine-König
@ 2024-03-11  8:22   ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11  8:22 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um, kernel

On Sun, Mar 10, 2024 at 8:52 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> 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>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


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

* Re: [PATCH 2/2] um: virtio_uml: Convert to platform remove callback returning void
  2024-03-10  7:52 ` [PATCH 2/2] um: virtio_uml: " Uwe Kleine-König
@ 2024-03-11  8:22   ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11  8:22 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um, kernel

On Sun, Mar 10, 2024 at 8:52 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> 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>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


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

* Re: [PATCH 0/2] um: Convert to platform remove callback returning void
  2024-03-10  7:52 [PATCH 0/2] um: Convert to platform remove callback returning void Uwe Kleine-König
  2024-03-10  7:52 ` [PATCH 1/2] um: rtc: " Uwe Kleine-König
  2024-03-10  7:52 ` [PATCH 2/2] um: virtio_uml: " Uwe Kleine-König
@ 2024-04-29  7:35 ` Uwe Kleine-König
  2024-04-30 12:18   ` Richard Weinberger
  2 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2024-04-29  7:35 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg; +Cc: linux-um, kernel

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

Hello Richard,

On Sun, Mar 10, 2024 at 08:52:26AM +0100, Uwe Kleine-König wrote:
> this series converts all platform drivers below arch/um to stop using
> struct platform_driver::remove(). See commit 5c5a7680e67b ("platform:
> Provide a remove callback that returns no value") for an extended
> explanation and the eventual goal.
> 
> Both conversations are trivial, because the driver's .remove() callbacks
> returned zero unconditionally.
> 
> There are no interdependencies between these patches, still I'd expect
> them to be picked up together.

I intend to send the change to struct platform_driver::remove() to Greg
soon after the upcoming merge window closed. It would be great if these
patches made it in before. If not, I'll ask Greg to apply these patches
together with the change to platform_driver::remove(). If that's your
preferred resolution, feel free to send an Ack for that.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

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

* Re: [PATCH 0/2] um: Convert to platform remove callback returning void
  2024-04-29  7:35 ` [PATCH 0/2] um: " Uwe Kleine-König
@ 2024-04-30 12:18   ` Richard Weinberger
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Weinberger @ 2024-04-30 12:18 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: anton ivanov, Johannes Berg, linux-um, kernel

Uwe,

----- Ursprüngliche Mail -----
> Von: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> An: "richard" <richard@nod.at>, "anton ivanov" <anton.ivanov@cambridgegreys.com>, "Johannes Berg"
> <johannes@sipsolutions.net>
> CC: "linux-um" <linux-um@lists.infradead.org>, "kernel" <kernel@pengutronix.de>
> Gesendet: Montag, 29. April 2024 09:35:49
> Betreff: Re: [PATCH 0/2] um: Convert to platform remove callback returning void

> Hello Richard,
> 
> On Sun, Mar 10, 2024 at 08:52:26AM +0100, Uwe Kleine-König wrote:
>> this series converts all platform drivers below arch/um to stop using
>> struct platform_driver::remove(). See commit 5c5a7680e67b ("platform:
>> Provide a remove callback that returns no value") for an extended
>> explanation and the eventual goal.
>> 
>> Both conversations are trivial, because the driver's .remove() callbacks
>> returned zero unconditionally.
>> 
>> There are no interdependencies between these patches, still I'd expect
>> them to be picked up together.
> 
> I intend to send the change to struct platform_driver::remove() to Greg
> soon after the upcoming merge window closed. It would be great if these
> patches made it in before. If not, I'll ask Greg to apply these patches
> together with the change to platform_driver::remove(). If that's your
> preferred resolution, feel free to send an Ack for that.

I've applied them and will appear soon in -next.

Thanks,
//richard


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

end of thread, other threads:[~2024-04-30 12:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10  7:52 [PATCH 0/2] um: Convert to platform remove callback returning void Uwe Kleine-König
2024-03-10  7:52 ` [PATCH 1/2] um: rtc: " Uwe Kleine-König
2024-03-11  8:22   ` Geert Uytterhoeven
2024-03-10  7:52 ` [PATCH 2/2] um: virtio_uml: " Uwe Kleine-König
2024-03-11  8:22   ` Geert Uytterhoeven
2024-04-29  7:35 ` [PATCH 0/2] um: " Uwe Kleine-König
2024-04-30 12:18   ` Richard Weinberger

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