linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] tty: Convert to platform remove callback returning void
@ 2024-02-18  8:53 Uwe Kleine-König
  2024-02-18  8:53 ` [PATCH 3/3] serial: pmac_zilog: " Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2024-02-18  8:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: kernel, John Ogness, Aneesh Kumar K.V, Nicholas Piggin,
	linux-serial, Naveen N. Rao, Thomas Gleixner, linuxppc-dev

Hello,

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

Two conversations are trivial, because their .remove() callbacks
returned zero unconditionally. The pmac_zilog serial driver had an error
path in its remove callback that however was never taken and so could be
dropped.

There are no interdependencies between these patches, so they could be
picked up individually. However I'd expect them to go in all together
via Greg's tree.

Uwe Kleine-König (3):
  tty: amiserial: Convert to platform remove callback returning void
  tty: goldfish: Convert to platform remove callback returning void
  serial: pmac_zilog: Convert to platform remove callback returning void

 drivers/tty/amiserial.c         | 6 ++----
 drivers/tty/goldfish.c          | 5 ++---
 drivers/tty/serial/pmac_zilog.c | 9 ++-------
 3 files changed, 6 insertions(+), 14 deletions(-)

base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118
-- 
2.43.0


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

* [PATCH 3/3] serial: pmac_zilog: Convert to platform remove callback returning void
  2024-02-18  8:53 [PATCH 0/3] tty: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-02-18  8:53 ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2024-02-18  8:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, John Ogness, Aneesh Kumar K.V, Nicholas Piggin,
	kernel, Naveen N. Rao, Thomas Gleixner, linuxppc-dev

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

Note that pmz_detach() is only called once pmz_attach() was successfully
called. In that case platform_set_drvdata() was called and so
platform_get_drvdata() won't return NULL. This allows to drop the
respective check and so get rid of the only error path in pmz_detach().

After that the driver can be trivially converted 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/tty/serial/pmac_zilog.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index c8bf08c19c64..05b5b3b456ac 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1717,18 +1717,13 @@ static int __init pmz_attach(struct platform_device *pdev)
 	return uart_add_one_port(&pmz_uart_reg, &uap->port);
 }
 
-static int __exit pmz_detach(struct platform_device *pdev)
+static void __exit pmz_detach(struct platform_device *pdev)
 {
 	struct uart_pmac_port *uap = platform_get_drvdata(pdev);
 
-	if (!uap)
-		return -ENODEV;
-
 	uart_remove_one_port(&pmz_uart_reg, &uap->port);
 
 	uap->port.dev = NULL;
-
-	return 0;
 }
 
 #endif /* !CONFIG_PPC_PMAC */
@@ -1797,7 +1792,7 @@ static struct macio_driver pmz_driver = {
 #else
 
 static struct platform_driver pmz_driver = {
-	.remove		= __exit_p(pmz_detach),
+	.remove_new	= __exit_p(pmz_detach),
 	.driver		= {
 		.name		= "scc",
 	},
-- 
2.43.0


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

end of thread, other threads:[~2024-02-18  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18  8:53 [PATCH 0/3] tty: Convert to platform remove callback returning void Uwe Kleine-König
2024-02-18  8:53 ` [PATCH 3/3] serial: pmac_zilog: " Uwe Kleine-König

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