sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sparc: Convert to platform remove callback returning void
@ 2024-04-10 13:35 Uwe Kleine-König
  2024-04-10 13:35 ` [PATCH 1/2] sparc: parport: " Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 13:35 UTC (permalink / raw)
  To: David S. Miller, Andreas Larsson, Sam Ravnborg, Rob Herring,
	Ahelenia Ziemiańska, Andrew Morton
  Cc: sparclinux, kernel

Hello,

this series converts the two platform drivers that have a remove callback below
arch/sparc to implement remove_new instead. 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 already.

There are no interdependencies between the two patches, so they could be picked
up individually if need be. This is merge window material.

Best regards
Uwe

Uwe Kleine-König (2):
  sparc: parport: Convert to platform remove callback returning void
  sparc: chmc: Convert to platform remove callback returning void

 arch/sparc/include/asm/parport_64.h | 6 ++----
 arch/sparc/kernel/chmc.c            | 5 ++---
 2 files changed, 4 insertions(+), 7 deletions(-)

base-commit: 6ebf211bb11dfc004a2ff73a9de5386fa309c430
-- 
2.43.0


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

* [PATCH 1/2] sparc: parport: Convert to platform remove callback returning void
  2024-04-10 13:35 [PATCH 0/2] sparc: Convert to platform remove callback returning void Uwe Kleine-König
@ 2024-04-10 13:35 ` Uwe Kleine-König
  2024-04-10 13:35 ` [PATCH 2/2] sparc: chmc: " Uwe Kleine-König
  2024-04-22 14:50 ` [PATCH 0/2] sparc: " Andreas Larsson
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 13:35 UTC (permalink / raw)
  To: David S. Miller, Andreas Larsson, Sam Ravnborg, Rob Herring
  Cc: sparclinux, 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/sparc/include/asm/parport_64.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/include/asm/parport_64.h b/arch/sparc/include/asm/parport_64.h
index 0a7ffcfd59cd..4f530a270760 100644
--- a/arch/sparc/include/asm/parport_64.h
+++ b/arch/sparc/include/asm/parport_64.h
@@ -196,7 +196,7 @@ static int ecpp_probe(struct platform_device *op)
 	return err;
 }
 
-static int ecpp_remove(struct platform_device *op)
+static void ecpp_remove(struct platform_device *op)
 {
 	struct parport *p = dev_get_drvdata(&op->dev);
 	int slot = p->dma;
@@ -216,8 +216,6 @@ static int ecpp_remove(struct platform_device *op)
 			   d_len);
 		clear_bit(slot, dma_slot_map);
 	}
-
-	return 0;
 }
 
 static const struct of_device_id ecpp_match[] = {
@@ -245,7 +243,7 @@ static struct platform_driver ecpp_driver = {
 		.of_match_table = ecpp_match,
 	},
 	.probe			= ecpp_probe,
-	.remove			= ecpp_remove,
+	.remove_new		= ecpp_remove,
 };
 
 static int parport_pc_find_nonpci_ports(int autoirq, int autodma)
-- 
2.43.0


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

* [PATCH 2/2] sparc: chmc: Convert to platform remove callback returning void
  2024-04-10 13:35 [PATCH 0/2] sparc: Convert to platform remove callback returning void Uwe Kleine-König
  2024-04-10 13:35 ` [PATCH 1/2] sparc: parport: " Uwe Kleine-König
@ 2024-04-10 13:35 ` Uwe Kleine-König
  2024-04-22 14:50 ` [PATCH 0/2] sparc: " Andreas Larsson
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2024-04-10 13:35 UTC (permalink / raw)
  To: David S. Miller, Andreas Larsson, Sam Ravnborg,
	Ahelenia Ziemiańska, Andrew Morton, Rob Herring
  Cc: sparclinux, 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/sparc/kernel/chmc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c
index 00e571c30bb5..e02074062001 100644
--- a/arch/sparc/kernel/chmc.c
+++ b/arch/sparc/kernel/chmc.c
@@ -788,7 +788,7 @@ static void jbusmc_destroy(struct platform_device *op, struct jbusmc *p)
 	kfree(p);
 }
 
-static int us3mc_remove(struct platform_device *op)
+static void us3mc_remove(struct platform_device *op)
 {
 	void *p = dev_get_drvdata(&op->dev);
 
@@ -798,7 +798,6 @@ static int us3mc_remove(struct platform_device *op)
 		else if (mc_type == MC_TYPE_JBUS)
 			jbusmc_destroy(op, p);
 	}
-	return 0;
 }
 
 static const struct of_device_id us3mc_match[] = {
@@ -815,7 +814,7 @@ static struct platform_driver us3mc_driver = {
 		.of_match_table = us3mc_match,
 	},
 	.probe		= us3mc_probe,
-	.remove		= us3mc_remove,
+	.remove_new	= us3mc_remove,
 };
 
 static inline bool us3mc_platform(void)
-- 
2.43.0


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

* Re: [PATCH 0/2] sparc: Convert to platform remove callback returning void
  2024-04-10 13:35 [PATCH 0/2] sparc: Convert to platform remove callback returning void Uwe Kleine-König
  2024-04-10 13:35 ` [PATCH 1/2] sparc: parport: " Uwe Kleine-König
  2024-04-10 13:35 ` [PATCH 2/2] sparc: chmc: " Uwe Kleine-König
@ 2024-04-22 14:50 ` Andreas Larsson
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Larsson @ 2024-04-22 14:50 UTC (permalink / raw)
  To: Uwe Kleine-König, David S. Miller, Sam Ravnborg,
	Rob Herring, Ahelenia Ziemiańska, Andrew Morton
  Cc: sparclinux, kernel

On 2024-04-10 15:35, Uwe Kleine-König wrote:
> Hello,
> 
> this series converts the two platform drivers that have a remove callback below
> arch/sparc to implement remove_new instead. 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 already.
> 
> There are no interdependencies between the two patches, so they could be picked
> up individually if need be. This is merge window material.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (2):
>   sparc: parport: Convert to platform remove callback returning void
>   sparc: chmc: Convert to platform remove callback returning void
> 
>  arch/sparc/include/asm/parport_64.h | 6 ++----
>  arch/sparc/kernel/chmc.c            | 5 ++---
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 
> base-commit: 6ebf211bb11dfc004a2ff73a9de5386fa309c430

Reviewed-by: Andreas Larsson <andreas@gaisler.com>

Picking the series up to my for-next

Thanks,
Andreas

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 13:35 [PATCH 0/2] sparc: Convert to platform remove callback returning void Uwe Kleine-König
2024-04-10 13:35 ` [PATCH 1/2] sparc: parport: " Uwe Kleine-König
2024-04-10 13:35 ` [PATCH 2/2] sparc: chmc: " Uwe Kleine-König
2024-04-22 14:50 ` [PATCH 0/2] sparc: " Andreas Larsson

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