linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] rtc: various improvements
@ 2023-10-02  8:05 Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 01/12] rtc: imxdi: Soften dependencies for improved compile coverage Uwe Kleine-König
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: linux-rtc, kernel, Nicolas Ferre, Claudiu Beznea,
	linux-arm-kernel, Shawn Guo, Sascha Hauer, Fabio Estevam,
	NXP Linux Team

Hello,

the section mismatch check will get more strict soon. See
https://lore.kernel.org/linux-kbuild/20230930165204.2478282-1-u.kleine-koenig@pengutronix.de
for the details.

Several rtc drivers that use module_platform_driver_probe() trigger a
warning with the above patch applied. Here they are marked with
__refdata to prevent this warning from triggering.

While touching these drivers I noticed that my coccinelle patch that
converts platform drivers to .remove_new failed to match for drivers
using

	.remove = __exit_p(...),

So I added these preparing patches on top. A separate series would have
been justified, too, but as the patches conflict with each other I kept
them in a single series.

Best regards
Uwe

Uwe Kleine-König (12):
  rtc: imxdi: Soften dependencies for improved compile coverage
  rtc: at91rm9200: Mark driver struct with __refdata to prevent section
    mismatch warning
  rtc: imxdi: Mark driver struct with __refdata to prevent section
    mismatch warning
  rtc: mv: Mark driver struct with __refdata to prevent section mismatch
    warning
  rtc: pxa: Mark driver struct with __refdata to prevent section
    mismatch warning
  rtc: sh: Mark driver struct with __refdata to prevent section mismatch
    warning
  rtc: pcap: Drop no-op remove function
  rtc: at91rm9200: Convert to platform remove callback returning void
  rtc: imxdi: Convert to platform remove callback returning void
  rtc: mv: Convert to platform remove callback returning void
  rtc: pxa: Convert to platform remove callback returning void
  rtc: sh: Convert to platform remove callback returning void

 drivers/rtc/Kconfig          |  2 +-
 drivers/rtc/rtc-at91rm9200.c | 14 +++++++++-----
 drivers/rtc/rtc-imxdi.c      | 14 +++++++++-----
 drivers/rtc/rtc-mv.c         | 14 +++++++++-----
 drivers/rtc/rtc-pcap.c       |  6 ------
 drivers/rtc/rtc-pxa.c        | 13 +++++++++----
 drivers/rtc/rtc-sh.c         | 14 +++++++++-----
 7 files changed, 46 insertions(+), 31 deletions(-)

base-commit: 6465e260f48790807eef06b583b38ca9789b6072
-- 
2.40.1


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

* [PATCH 01/12] rtc: imxdi: Soften dependencies for improved compile coverage
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 02/12] rtc: at91rm9200: Mark driver struct with __refdata to prevent section mismatch warning Uwe Kleine-König
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, kernel

The driver compiles fine on x86_64, so soften the dependencies to
ARCH_MXC || COMPILE_TEST.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index d7502433c78a..f92644a10c7d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1351,7 +1351,7 @@ config RTC_DRV_DIGICOLOR
 
 config RTC_DRV_IMXDI
 	tristate "Freescale IMX DryIce Real Time Clock"
-	depends on ARCH_MXC
+	depends on ARCH_MXC || COMPILE_TEST
 	depends on OF
 	help
 	   Support for Freescale IMX DryIce RTC
-- 
2.40.1


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

* [PATCH 02/12] rtc: at91rm9200: Mark driver struct with __refdata to prevent section mismatch warning
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 01/12] rtc: imxdi: Soften dependencies for improved compile coverage Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 03/12] rtc: imxdi: " Uwe Kleine-König
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Nicolas Ferre, Claudiu Beznea, linux-rtc, linux-arm-kernel, kernel

As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent a section mismatch warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/rtc-at91rm9200.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index add4f71d7b3b..5cf54febcc40 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -635,7 +635,13 @@ static int at91_rtc_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);
 
-static struct platform_driver at91_rtc_driver = {
+/*
+ * at91_rtc_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver at91_rtc_driver __refdata = {
 	.remove		= __exit_p(at91_rtc_remove),
 	.shutdown	= at91_rtc_shutdown,
 	.driver		= {
-- 
2.40.1


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

* [PATCH 03/12] rtc: imxdi: Mark driver struct with __refdata to prevent section mismatch warning
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 01/12] rtc: imxdi: Soften dependencies for improved compile coverage Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 02/12] rtc: at91rm9200: Mark driver struct with __refdata to prevent section mismatch warning Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 04/12] rtc: mv: " Uwe Kleine-König
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-rtc, linux-arm-kernel

As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent a section mismatch warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/rtc-imxdi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 4b712e5ab08a..cf202eaa542e 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -851,7 +851,13 @@ static const struct of_device_id dryice_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, dryice_dt_ids);
 
-static struct platform_driver dryice_rtc_driver = {
+/*
+ * dryice_rtc_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver dryice_rtc_driver __refdata = {
 	.driver = {
 		   .name = "imxdi_rtc",
 		   .of_match_table = dryice_dt_ids,
-- 
2.40.1


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

* [PATCH 04/12] rtc: mv: Mark driver struct with __refdata to prevent section mismatch warning
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 03/12] rtc: imxdi: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 05/12] rtc: pxa: " Uwe Kleine-König
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, kernel

As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent a section mismatch warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/rtc-mv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index 6c526e2ec56d..d3c60c5b5897 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -303,7 +303,13 @@ static const struct of_device_id rtc_mv_of_match_table[] = {
 MODULE_DEVICE_TABLE(of, rtc_mv_of_match_table);
 #endif
 
-static struct platform_driver mv_rtc_driver = {
+/*
+ * mv_rtc_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver mv_rtc_driver __refdata = {
 	.remove		= __exit_p(mv_rtc_remove),
 	.driver		= {
 		.name	= "rtc-mv",
-- 
2.40.1


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

* [PATCH 05/12] rtc: pxa: Mark driver struct with __refdata to prevent section mismatch warning
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 04/12] rtc: mv: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 06/12] rtc: sh: " Uwe Kleine-König
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, kernel

As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent a section mismatch warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/rtc-pxa.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index e400c78252e8..41fe2e20d177 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -403,7 +403,13 @@ static int pxa_rtc_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(pxa_rtc_pm_ops, pxa_rtc_suspend, pxa_rtc_resume);
 
-static struct platform_driver pxa_rtc_driver = {
+/*
+ * pxa_rtc_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver pxa_rtc_driver __refdata = {
 	.remove		= __exit_p(pxa_rtc_remove),
 	.driver		= {
 		.name	= "pxa-rtc",
-- 
2.40.1


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

* [PATCH 06/12] rtc: sh: Mark driver struct with __refdata to prevent section mismatch warning
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 05/12] rtc: pxa: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 07/12] rtc: pcap: Drop no-op remove function Uwe Kleine-König
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, kernel

As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent a section mismatch warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/rtc/rtc-sh.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index cd146b574143..3f6a5d130690 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -668,7 +668,13 @@ static const struct of_device_id sh_rtc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sh_rtc_of_match);
 
-static struct platform_driver sh_rtc_platform_driver = {
+/*
+ * sh_rtc_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver sh_rtc_platform_driver __refdata = {
 	.driver		= {
 		.name	= DRV_NAME,
 		.pm	= &sh_rtc_pm_ops,
-- 
2.40.1


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

* [PATCH 07/12] rtc: pcap: Drop no-op remove function
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 06/12] rtc: sh: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 08/12] rtc: at91rm9200: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, kernel

A remove callback that just returns 0 is equivalent to no callback at
all as can be seen in platform_remove(). So simplify accordingly.

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

diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index 8c7a98a5452c..d6651611a0c6 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -166,13 +166,7 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
 	return devm_rtc_register_device(pcap_rtc->rtc);
 }
 
-static int __exit pcap_rtc_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
 static struct platform_driver pcap_rtc_driver = {
-	.remove = __exit_p(pcap_rtc_remove),
 	.driver = {
 		.name  = "pcap-rtc",
 	},
-- 
2.40.1


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

* [PATCH 08/12] rtc: at91rm9200: Convert to platform remove callback returning void
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 07/12] rtc: pcap: Drop no-op remove function Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 09/12] rtc: imxdi: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Nicolas Ferre, Claudiu Beznea, linux-rtc, linux-arm-kernel, 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/rtc/rtc-at91rm9200.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 5cf54febcc40..3f5ff9867c02 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -558,7 +558,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
 /*
  * Disable and remove the RTC driver
  */
-static int __exit at91_rtc_remove(struct platform_device *pdev)
+static void at91_rtc_remove(struct platform_device *pdev)
 {
 	/* Disable all interrupts */
 	at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM |
@@ -566,8 +566,6 @@ static int __exit at91_rtc_remove(struct platform_device *pdev)
 					AT91_RTC_CALEV);
 
 	clk_disable_unprepare(sclk);
-
-	return 0;
 }
 
 static void at91_rtc_shutdown(struct platform_device *pdev)
@@ -642,7 +640,7 @@ static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);
  * triggering a section mismatch warning.
  */
 static struct platform_driver at91_rtc_driver __refdata = {
-	.remove		= __exit_p(at91_rtc_remove),
+	.remove_new	= __exit_p(at91_rtc_remove),
 	.shutdown	= at91_rtc_shutdown,
 	.driver		= {
 		.name	= "at91_rtc",
-- 
2.40.1


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

* [PATCH 09/12] rtc: imxdi: Convert to platform remove callback returning void
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 08/12] rtc: at91rm9200: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 10/12] rtc: mv: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-rtc, linux-arm-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/rtc/rtc-imxdi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index cf202eaa542e..284011c419db 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -830,7 +830,7 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static int __exit dryice_rtc_remove(struct platform_device *pdev)
+static void __exit dryice_rtc_remove(struct platform_device *pdev)
 {
 	struct imxdi_dev *imxdi = platform_get_drvdata(pdev);
 
@@ -840,8 +840,6 @@ static int __exit dryice_rtc_remove(struct platform_device *pdev)
 	writel(0, imxdi->ioaddr + DIER);
 
 	clk_disable_unprepare(imxdi->clk);
-
-	return 0;
 }
 
 static const struct of_device_id dryice_dt_ids[] = {
@@ -862,7 +860,7 @@ static struct platform_driver dryice_rtc_driver __refdata = {
 		   .name = "imxdi_rtc",
 		   .of_match_table = dryice_dt_ids,
 		   },
-	.remove = __exit_p(dryice_rtc_remove),
+	.remove_new = __exit_p(dryice_rtc_remove),
 };
 
 module_platform_driver_probe(dryice_rtc_driver, dryice_rtc_probe);
-- 
2.40.1


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

* [PATCH 10/12] rtc: mv: Convert to platform remove callback returning void
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 09/12] rtc: imxdi: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 11/12] rtc: pxa: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, 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/rtc/rtc-mv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index d3c60c5b5897..db31da56bfa7 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -282,7 +282,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit mv_rtc_remove(struct platform_device *pdev)
+static void __exit mv_rtc_remove(struct platform_device *pdev)
 {
 	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
@@ -291,8 +291,6 @@ static int __exit mv_rtc_remove(struct platform_device *pdev)
 
 	if (!IS_ERR(pdata->clk))
 		clk_disable_unprepare(pdata->clk);
-
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -310,7 +308,7 @@ MODULE_DEVICE_TABLE(of, rtc_mv_of_match_table);
  * triggering a section mismatch warning.
  */
 static struct platform_driver mv_rtc_driver __refdata = {
-	.remove		= __exit_p(mv_rtc_remove),
+	.remove_new	= __exit_p(mv_rtc_remove),
 	.driver		= {
 		.name	= "rtc-mv",
 		.of_match_table = of_match_ptr(rtc_mv_of_match_table),
-- 
2.40.1


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

* [PATCH 11/12] rtc: pxa: Convert to platform remove callback returning void
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 10/12] rtc: mv: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-02  8:05 ` [PATCH 12/12] rtc: sh: " Uwe Kleine-König
  2023-10-13 10:30 ` [PATCH 00/12] rtc: various improvements Alexandre Belloni
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, 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/rtc/rtc-pxa.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index 41fe2e20d177..cdb39fc4cab5 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -365,12 +365,11 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __exit pxa_rtc_remove(struct platform_device *pdev)
+static void __exit pxa_rtc_remove(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 
 	pxa_rtc_release(dev);
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -410,7 +409,7 @@ static SIMPLE_DEV_PM_OPS(pxa_rtc_pm_ops, pxa_rtc_suspend, pxa_rtc_resume);
  * triggering a section mismatch warning.
  */
 static struct platform_driver pxa_rtc_driver __refdata = {
-	.remove		= __exit_p(pxa_rtc_remove),
+	.remove_new	= __exit_p(pxa_rtc_remove),
 	.driver		= {
 		.name	= "pxa-rtc",
 		.of_match_table = of_match_ptr(pxa_rtc_dt_ids),
-- 
2.40.1


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

* [PATCH 12/12] rtc: sh: Convert to platform remove callback returning void
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (10 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 11/12] rtc: pxa: " Uwe Kleine-König
@ 2023-10-02  8:05 ` Uwe Kleine-König
  2023-10-13 10:30 ` [PATCH 00/12] rtc: various improvements Alexandre Belloni
  12 siblings, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-10-02  8:05 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni; +Cc: linux-rtc, 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/rtc/rtc-sh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 3f6a5d130690..15020266c41f 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -620,7 +620,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit sh_rtc_remove(struct platform_device *pdev)
+static void __exit sh_rtc_remove(struct platform_device *pdev)
 {
 	struct sh_rtc *rtc = platform_get_drvdata(pdev);
 
@@ -628,8 +628,6 @@ static int __exit sh_rtc_remove(struct platform_device *pdev)
 	sh_rtc_setcie(&pdev->dev, 0);
 
 	clk_disable(rtc->clk);
-
-	return 0;
 }
 
 static void sh_rtc_set_irq_wake(struct device *dev, int enabled)
@@ -680,7 +678,7 @@ static struct platform_driver sh_rtc_platform_driver __refdata = {
 		.pm	= &sh_rtc_pm_ops,
 		.of_match_table = sh_rtc_of_match,
 	},
-	.remove		= __exit_p(sh_rtc_remove),
+	.remove_new	= __exit_p(sh_rtc_remove),
 };
 
 module_platform_driver_probe(sh_rtc_platform_driver, sh_rtc_probe);
-- 
2.40.1


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

* Re: [PATCH 00/12] rtc: various improvements
  2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
                   ` (11 preceding siblings ...)
  2023-10-02  8:05 ` [PATCH 12/12] rtc: sh: " Uwe Kleine-König
@ 2023-10-13 10:30 ` Alexandre Belloni
  12 siblings, 0 replies; 14+ messages in thread
From: Alexandre Belloni @ 2023-10-13 10:30 UTC (permalink / raw)
  To: Alessandro Zummo, Uwe Kleine-König
  Cc: linux-rtc, kernel, Nicolas Ferre, Claudiu Beznea,
	linux-arm-kernel, Shawn Guo, Sascha Hauer, Fabio Estevam,
	NXP Linux Team


On Mon, 02 Oct 2023 10:05:17 +0200, Uwe Kleine-König wrote:
> the section mismatch check will get more strict soon. See
> https://lore.kernel.org/linux-kbuild/20230930165204.2478282-1-u.kleine-koenig@pengutronix.de
> for the details.
> 
> Several rtc drivers that use module_platform_driver_probe() trigger a
> warning with the above patch applied. Here they are marked with
> __refdata to prevent this warning from triggering.
> 
> [...]

Applied, thanks!

[01/12] rtc: imxdi: Soften dependencies for improved compile coverage
        commit: 2e2ad6393b430b643e607d49190e0b2628d5f035
[02/12] rtc: at91rm9200: Mark driver struct with __refdata to prevent section mismatch warning
        commit: 5dbde0727a515df85b1773a1f6dd301194c763f4
[03/12] rtc: imxdi: Mark driver struct with __refdata to prevent section mismatch warning
        commit: e6d44306e4fb476835fa7b818f0440c707b12844
[04/12] rtc: mv: Mark driver struct with __refdata to prevent section mismatch warning
        commit: 5621f28b0122861231057e3f452573a6e8d6a4c1
[05/12] rtc: pxa: Mark driver struct with __refdata to prevent section mismatch warning
        commit: 47712bc29401240cce89e631e04ba83891c976ee
[06/12] rtc: sh: Mark driver struct with __refdata to prevent section mismatch warning
        commit: 141626dbc2e69150fbd5bf241eba85790d7e95ab
[07/12] rtc: pcap: Drop no-op remove function
        commit: 94a2da3e6b681a970b248927bfb5d7d519bd3924
[08/12] rtc: at91rm9200: Convert to platform remove callback returning void
        commit: 48bc8830fbed98dff905fdbcaa424d59bb312043
[09/12] rtc: imxdi: Convert to platform remove callback returning void
        commit: 482ca730a4fc5fe766fb7d86c46c75b171d6efdf
[10/12] rtc: mv: Convert to platform remove callback returning void
        commit: ede66fb37f12737f96b2c1cbccae9c5ccf7be074
[11/12] rtc: pxa: Convert to platform remove callback returning void
        commit: e288cfe8f25f547a5359a72940e55b3e9a173bb1
[12/12] rtc: sh: Convert to platform remove callback returning void
        commit: f4d571b31b83127c2263fdf46eebf86f4d9991a2

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2023-10-13 10:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02  8:05 [PATCH 00/12] rtc: various improvements Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 01/12] rtc: imxdi: Soften dependencies for improved compile coverage Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 02/12] rtc: at91rm9200: Mark driver struct with __refdata to prevent section mismatch warning Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 03/12] rtc: imxdi: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 04/12] rtc: mv: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 05/12] rtc: pxa: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 06/12] rtc: sh: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 07/12] rtc: pcap: Drop no-op remove function Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 08/12] rtc: at91rm9200: Convert to platform remove callback returning void Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 09/12] rtc: imxdi: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 10/12] rtc: mv: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 11/12] rtc: pxa: " Uwe Kleine-König
2023-10-02  8:05 ` [PATCH 12/12] rtc: sh: " Uwe Kleine-König
2023-10-13 10:30 ` [PATCH 00/12] rtc: various improvements Alexandre Belloni

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