linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] powerpc: Convert to platform remove callback returning void
@ 2024-02-21 15:40 Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 1/6] powerpc: sgy_cts1000: " Uwe Kleine-König
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Aneesh Kumar K.V, Haoran Liu, Rob Herring, Mahesh Salgaonkar,
	Scott Wood, Nicholas Piggin, kernel, Naveen N. Rao, linuxppc-dev

Hello,

this series converts all platform drivers below drivers/powerpc 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.

All conversations are trivial, because their .remove() callbacks
returned zero unconditionally.

There are no interdependencies between these patches, so they could be
picked up individually. But I'd hope that Michael picks them up all
together.

Best regards
Uwe

Uwe Kleine-König (6):
  powerpc: sgy_cts1000: Convert to platform remove callback returning void
  powerpc: gpio_mdio: Convert to platform remove callback returning void
  powerpc: opal-prd: Convert to platform remove callback returning void
  powerpc: papr_scm: Convert to platform remove callback returning void
  powerpc: fsl_msi: Convert to platform remove callback returning void
  powerpc: pmi: Convert to platform remove callback returning void

 arch/powerpc/platforms/85xx/sgy_cts1000.c | 6 ++----
 arch/powerpc/platforms/pasemi/gpio_mdio.c | 6 ++----
 arch/powerpc/platforms/powernv/opal-prd.c | 5 ++---
 arch/powerpc/platforms/pseries/papr_scm.c | 6 ++----
 arch/powerpc/sysdev/fsl_msi.c             | 6 ++----
 arch/powerpc/sysdev/pmi.c                 | 6 ++----
 6 files changed, 12 insertions(+), 23 deletions(-)

base-commit: 4893c639cc3659cefaa675bf1e59f4e7571afb5c
-- 
2.43.0


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

* [PATCH 1/6] powerpc: sgy_cts1000: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 2/6] powerpc: gpio_mdio: " Uwe Kleine-König
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Aneesh Kumar K.V, Scott Wood, Nicholas Piggin, kernel,
	Naveen N. Rao, 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().

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/powerpc/platforms/85xx/sgy_cts1000.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/sgy_cts1000.c b/arch/powerpc/platforms/85xx/sgy_cts1000.c
index 751395cbf022..34ce21f42623 100644
--- a/arch/powerpc/platforms/85xx/sgy_cts1000.c
+++ b/arch/powerpc/platforms/85xx/sgy_cts1000.c
@@ -114,7 +114,7 @@ static int gpio_halt_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int gpio_halt_remove(struct platform_device *pdev)
+static void gpio_halt_remove(struct platform_device *pdev)
 {
 	free_irq(halt_irq, pdev);
 	cancel_work_sync(&gpio_halt_wq);
@@ -124,8 +124,6 @@ static int gpio_halt_remove(struct platform_device *pdev)
 
 	gpiod_put(halt_gpio);
 	halt_gpio = NULL;
-
-	return 0;
 }
 
 static const struct of_device_id gpio_halt_match[] = {
@@ -145,7 +143,7 @@ static struct platform_driver gpio_halt_driver = {
 		.of_match_table = gpio_halt_match,
 	},
 	.probe		= gpio_halt_probe,
-	.remove		= gpio_halt_remove,
+	.remove_new	= gpio_halt_remove,
 };
 
 module_platform_driver(gpio_halt_driver);
-- 
2.43.0


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

* [PATCH 2/6] powerpc: gpio_mdio: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 1/6] powerpc: sgy_cts1000: " Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 3/6] powerpc: opal-prd: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Rob Herring, Aneesh Kumar K.V, Nicholas Piggin, kernel,
	Naveen N. Rao, 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().

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/powerpc/platforms/pasemi/gpio_mdio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
index fd130fe7a65a..4e983af32949 100644
--- a/arch/powerpc/platforms/pasemi/gpio_mdio.c
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -260,7 +260,7 @@ static int gpio_mdio_probe(struct platform_device *ofdev)
 }
 
 
-static int gpio_mdio_remove(struct platform_device *dev)
+static void gpio_mdio_remove(struct platform_device *dev)
 {
 	struct mii_bus *bus = dev_get_drvdata(&dev->dev);
 
@@ -271,8 +271,6 @@ static int gpio_mdio_remove(struct platform_device *dev)
 	kfree(bus->priv);
 	bus->priv = NULL;
 	mdiobus_free(bus);
-
-	return 0;
 }
 
 static const struct of_device_id gpio_mdio_match[] =
@@ -287,7 +285,7 @@ MODULE_DEVICE_TABLE(of, gpio_mdio_match);
 static struct platform_driver gpio_mdio_driver =
 {
 	.probe		= gpio_mdio_probe,
-	.remove		= gpio_mdio_remove,
+	.remove_new	= gpio_mdio_remove,
 	.driver = {
 		.name = "gpio-mdio-bitbang",
 		.of_match_table = gpio_mdio_match,
-- 
2.43.0


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

* [PATCH 3/6] powerpc: opal-prd: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 1/6] powerpc: sgy_cts1000: " Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 2/6] powerpc: gpio_mdio: " Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 4/6] powerpc: papr_scm: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Haoran Liu, Mahesh Salgaonkar, Aneesh Kumar K.V, Nicholas Piggin,
	kernel, Naveen N. Rao, 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().

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/powerpc/platforms/powernv/opal-prd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-prd.c b/arch/powerpc/platforms/powernv/opal-prd.c
index b66b06efcef1..24f04f20d3e8 100644
--- a/arch/powerpc/platforms/powernv/opal-prd.c
+++ b/arch/powerpc/platforms/powernv/opal-prd.c
@@ -425,12 +425,11 @@ static int opal_prd_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int opal_prd_remove(struct platform_device *pdev)
+static void opal_prd_remove(struct platform_device *pdev)
 {
 	misc_deregister(&opal_prd_dev);
 	opal_message_notifier_unregister(OPAL_MSG_PRD, &opal_prd_event_nb);
 	opal_message_notifier_unregister(OPAL_MSG_PRD2, &opal_prd_event_nb2);
-	return 0;
 }
 
 static const struct of_device_id opal_prd_match[] = {
@@ -444,7 +443,7 @@ static struct platform_driver opal_prd_driver = {
 		.of_match_table	= opal_prd_match,
 	},
 	.probe	= opal_prd_probe,
-	.remove	= opal_prd_remove,
+	.remove_new = opal_prd_remove,
 };
 
 module_platform_driver(opal_prd_driver);
-- 
2.43.0


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

* [PATCH 4/6] powerpc: papr_scm: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2024-02-21 15:40 ` [PATCH 3/6] powerpc: opal-prd: " Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 5/6] powerpc: fsl_msi: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Aneesh Kumar K.V, Nicholas Piggin, kernel, Naveen N. Rao,
	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().

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/powerpc/platforms/pseries/papr_scm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
index 1a53e048ceb7..c233f9db039b 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -1521,7 +1521,7 @@ err:	kfree(p);
 	return rc;
 }
 
-static int papr_scm_remove(struct platform_device *pdev)
+static void papr_scm_remove(struct platform_device *pdev)
 {
 	struct papr_scm_priv *p = platform_get_drvdata(pdev);
 
@@ -1538,8 +1538,6 @@ static int papr_scm_remove(struct platform_device *pdev)
 	pdev->archdata.priv = NULL;
 	kfree(p->bus_desc.provider_name);
 	kfree(p);
-
-	return 0;
 }
 
 static const struct of_device_id papr_scm_match[] = {
@@ -1550,7 +1548,7 @@ static const struct of_device_id papr_scm_match[] = {
 
 static struct platform_driver papr_scm_driver = {
 	.probe = papr_scm_probe,
-	.remove = papr_scm_remove,
+	.remove_new = papr_scm_remove,
 	.driver = {
 		.name = "papr_scm",
 		.of_match_table = papr_scm_match,
-- 
2.43.0


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

* [PATCH 5/6] powerpc: fsl_msi: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2024-02-21 15:40 ` [PATCH 4/6] powerpc: papr_scm: " Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-21 15:40 ` [PATCH 6/6] powerpc: pmi: " Uwe Kleine-König
  2024-02-26  5:56 ` [PATCH 0/6] powerpc: " Michael Ellerman
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Rob Herring, Aneesh Kumar K.V, Nicholas Piggin, kernel,
	Naveen N. Rao, 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().

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/powerpc/sysdev/fsl_msi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 558ec68d768e..8e6c84df4ca1 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -320,7 +320,7 @@ static irqreturn_t fsl_msi_cascade(int irq, void *data)
 	return ret;
 }
 
-static int fsl_of_msi_remove(struct platform_device *ofdev)
+static void fsl_of_msi_remove(struct platform_device *ofdev)
 {
 	struct fsl_msi *msi = platform_get_drvdata(ofdev);
 	int virq, i;
@@ -343,8 +343,6 @@ static int fsl_of_msi_remove(struct platform_device *ofdev)
 	if ((msi->feature & FSL_PIC_IP_MASK) != FSL_PIC_IP_VMPIC)
 		iounmap(msi->msi_regs);
 	kfree(msi);
-
-	return 0;
 }
 
 static struct lock_class_key fsl_msi_irq_class;
@@ -603,7 +601,7 @@ static struct platform_driver fsl_of_msi_driver = {
 		.of_match_table = fsl_of_msi_ids,
 	},
 	.probe = fsl_of_msi_probe,
-	.remove = fsl_of_msi_remove,
+	.remove_new = fsl_of_msi_remove,
 };
 
 static __init int fsl_of_msi_init(void)
-- 
2.43.0


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

* [PATCH 6/6] powerpc: pmi: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2024-02-21 15:40 ` [PATCH 5/6] powerpc: fsl_msi: " Uwe Kleine-König
@ 2024-02-21 15:40 ` Uwe Kleine-König
  2024-02-26  5:56 ` [PATCH 0/6] powerpc: " Michael Ellerman
  6 siblings, 0 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2024-02-21 15:40 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Rob Herring, Aneesh Kumar K.V, Nicholas Piggin, kernel,
	Naveen N. Rao, 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().

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/powerpc/sysdev/pmi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c
index fcf8d1516210..737f97fd67d7 100644
--- a/arch/powerpc/sysdev/pmi.c
+++ b/arch/powerpc/sysdev/pmi.c
@@ -173,7 +173,7 @@ static int pmi_of_probe(struct platform_device *dev)
 	return rc;
 }
 
-static int pmi_of_remove(struct platform_device *dev)
+static void pmi_of_remove(struct platform_device *dev)
 {
 	struct pmi_handler *handler, *tmp;
 
@@ -189,13 +189,11 @@ static int pmi_of_remove(struct platform_device *dev)
 
 	kfree(data);
 	data = NULL;
-
-	return 0;
 }
 
 static struct platform_driver pmi_of_platform_driver = {
 	.probe		= pmi_of_probe,
-	.remove		= pmi_of_remove,
+	.remove_new	= pmi_of_remove,
 	.driver = {
 		.name = "pmi",
 		.of_match_table = pmi_match,
-- 
2.43.0


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

* Re: [PATCH 0/6] powerpc: Convert to platform remove callback returning void
  2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2024-02-21 15:40 ` [PATCH 6/6] powerpc: pmi: " Uwe Kleine-König
@ 2024-02-26  5:56 ` Michael Ellerman
  6 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2024-02-26  5:56 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Rob Herring, Haoran Liu, Scott Wood, Mahesh Salgaonkar,
	Nicholas Piggin, Aneesh Kumar K.V, kernel, Naveen N. Rao,
	linuxppc-dev

On Wed, 21 Feb 2024 16:40:14 +0100, Uwe Kleine-König wrote:
> this series converts all platform drivers below drivers/powerpc 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.
> 
> All conversations are trivial, because their .remove() callbacks
> returned zero unconditionally.
> 
> [...]

Applied to powerpc/next.

[1/6] powerpc: sgy_cts1000: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/9d16a8591a52d614507ed76f0b105c7de7b8dbe7
[2/6] powerpc: gpio_mdio: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/b1cd248f427607e595c2799044f8166dac1e953b
[3/6] powerpc: opal-prd: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/ca899c1221b6beee80ac91977309c08b78c74ad2
[4/6] powerpc: papr_scm: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/18a4a2612ba1e54526bbc11980f1fbb31b7aa440
[5/6] powerpc: fsl_msi: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/e2064de2f3c89976a4a03f265edb5bc3795fc8ff
[6/6] powerpc: pmi: Convert to platform remove callback returning void
      https://git.kernel.org/powerpc/c/a3e1820186b5ed3703e690eb064ad7c6c7477cfb

cheers

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

end of thread, other threads:[~2024-02-26  6:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21 15:40 [PATCH 0/6] powerpc: Convert to platform remove callback returning void Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 1/6] powerpc: sgy_cts1000: " Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 2/6] powerpc: gpio_mdio: " Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 3/6] powerpc: opal-prd: " Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 4/6] powerpc: papr_scm: " Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 5/6] powerpc: fsl_msi: " Uwe Kleine-König
2024-02-21 15:40 ` [PATCH 6/6] powerpc: pmi: " Uwe Kleine-König
2024-02-26  5:56 ` [PATCH 0/6] powerpc: " Michael Ellerman

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