All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sebastian Reichel <sre@kernel.org>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	kernel@pengutronix.de, linux-kbuild@vger.kernel.org
Subject: [PATCH 03/14] power: reset: at91-sama5d2_shdwc: Stop using module_platform_driver_probe()
Date: Sat,  4 Nov 2023 22:15:05 +0100	[thread overview]
Message-ID: <20231104211501.3676352-19-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20231104211501.3676352-16-u.kleine-koenig@pengutronix.de>

On today's platforms the benefit of platform_driver_probe() isn't that
relevant any more. It allows to drop some code after booting (or module
loading) for .probe() and discard the .remove() function completely if
the driver is built-in. This typically saves a few 100k.

The downside of platform_driver_probe() is that the driver cannot be
bound and unbound at runtime which is ancient and so slightly
complicates testing. There are also thoughts to deprecate
platform_driver_probe() because it adds some complexity in the driver
core for little gain. Also many drivers don't use it correctly. This
driver for example misses to mark the driver struct with __ref which is
needed to suppress a (W=1) modpost warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/power/reset/at91-sama5d2_shdwc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
index e76b102b57b1..ef8add623363 100644
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -329,7 +329,7 @@ static const struct of_device_id at91_pmc_ids[] = {
 	{ /* Sentinel. */ }
 };
 
-static int __init at91_shdwc_probe(struct platform_device *pdev)
+static int at91_shdwc_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
 	struct device_node *np;
@@ -421,7 +421,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit at91_shdwc_remove(struct platform_device *pdev)
+static int at91_shdwc_remove(struct platform_device *pdev)
 {
 	struct shdwc *shdw = platform_get_drvdata(pdev);
 
@@ -442,13 +442,14 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver at91_shdwc_driver = {
-	.remove = __exit_p(at91_shdwc_remove),
+	.probe = at91_shdwc_probe,
+	.remove = at91_shdwc_remove,
 	.driver = {
 		.name = "at91-shdwc",
 		.of_match_table = at91_shdwc_of_match,
 	},
 };
-module_platform_driver_probe(at91_shdwc_driver, at91_shdwc_probe);
+module_platform_driver(at91_shdwc_driver);
 
 MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@atmel.com>");
 MODULE_DESCRIPTION("Atmel shutdown controller driver");
-- 
2.42.0


WARNING: multiple messages have this Message-ID (diff)
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sebastian Reichel <sre@kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-pm@vger.kernel.org, linux-kbuild@vger.kernel.org,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/14] power: reset: at91-sama5d2_shdwc: Stop using module_platform_driver_probe()
Date: Sat,  4 Nov 2023 22:15:05 +0100	[thread overview]
Message-ID: <20231104211501.3676352-19-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20231104211501.3676352-16-u.kleine-koenig@pengutronix.de>

On today's platforms the benefit of platform_driver_probe() isn't that
relevant any more. It allows to drop some code after booting (or module
loading) for .probe() and discard the .remove() function completely if
the driver is built-in. This typically saves a few 100k.

The downside of platform_driver_probe() is that the driver cannot be
bound and unbound at runtime which is ancient and so slightly
complicates testing. There are also thoughts to deprecate
platform_driver_probe() because it adds some complexity in the driver
core for little gain. Also many drivers don't use it correctly. This
driver for example misses to mark the driver struct with __ref which is
needed to suppress a (W=1) modpost warning.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/power/reset/at91-sama5d2_shdwc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
index e76b102b57b1..ef8add623363 100644
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -329,7 +329,7 @@ static const struct of_device_id at91_pmc_ids[] = {
 	{ /* Sentinel. */ }
 };
 
-static int __init at91_shdwc_probe(struct platform_device *pdev)
+static int at91_shdwc_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
 	struct device_node *np;
@@ -421,7 +421,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit at91_shdwc_remove(struct platform_device *pdev)
+static int at91_shdwc_remove(struct platform_device *pdev)
 {
 	struct shdwc *shdw = platform_get_drvdata(pdev);
 
@@ -442,13 +442,14 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver at91_shdwc_driver = {
-	.remove = __exit_p(at91_shdwc_remove),
+	.probe = at91_shdwc_probe,
+	.remove = at91_shdwc_remove,
 	.driver = {
 		.name = "at91-shdwc",
 		.of_match_table = at91_shdwc_of_match,
 	},
 };
-module_platform_driver_probe(at91_shdwc_driver, at91_shdwc_probe);
+module_platform_driver(at91_shdwc_driver);
 
 MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@atmel.com>");
 MODULE_DESCRIPTION("Atmel shutdown controller driver");
-- 
2.42.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-11-04 21:16 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-04 21:15 [PATCH 00/14] power: reset: Drop platform_driver_probe() and convert to platform remove callback returning void Uwe Kleine-König
2023-11-04 21:15 ` Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 01/14] power: reset: at91-poweroff: Stop using module_platform_driver_probe() Uwe Kleine-König
2023-11-04 21:15   ` Uwe Kleine-König
2023-11-08  6:54   ` claudiu beznea
2023-11-08  6:54     ` claudiu beznea
2023-11-04 21:15 ` [PATCH 02/14] power: reset: at91-reset:: " Uwe Kleine-König
2023-11-04 21:15   ` Uwe Kleine-König
2023-11-08  6:54   ` claudiu beznea
2023-11-08  6:54     ` claudiu beznea
2023-11-04 21:15 ` Uwe Kleine-König [this message]
2023-11-04 21:15   ` [PATCH 03/14] power: reset: at91-sama5d2_shdwc: " Uwe Kleine-König
2023-11-08  6:55   ` claudiu beznea
2023-11-08  6:55     ` claudiu beznea
2023-11-04 21:15 ` [PATCH 04/14] power: reset: as3722-poweroff: Convert to platform remove callback returning void Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 05/14] power: reset: at91-poweroff: " Uwe Kleine-König
2023-11-04 21:15   ` Uwe Kleine-König
2023-11-08  6:55   ` claudiu beznea
2023-11-08  6:55     ` claudiu beznea
2023-11-04 21:15 ` [PATCH 06/14] power: reset: atc260x-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 07/14] power: reset: ltc2952-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 08/14] power: reset: mt6323-poweroff: " Uwe Kleine-König
2023-11-04 21:15   ` Uwe Kleine-König
2023-11-06  8:21   ` AngeloGioacchino Del Regno
2023-11-06  8:21     ` AngeloGioacchino Del Regno
2023-11-04 21:15 ` [PATCH 09/14] power: reset: qnap-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 10/14] power: reset: regulator-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 11/14] power: reset: restart-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 12/14] power: reset: rmobile-reset: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 13/14] power: reset: syscon-poweroff: " Uwe Kleine-König
2023-11-04 21:15 ` [PATCH 14/14] power: reset: tps65086-restart: " Uwe Kleine-König
2023-11-05  9:47 ` [PATCH 15/14] power: reset: at91-reset: " Uwe Kleine-König
2023-11-05  9:47   ` Uwe Kleine-König
2023-11-08  6:56   ` claudiu beznea
2023-11-08  6:56     ` claudiu beznea
2023-11-05  9:47 ` [PATCH 16/14] power: reset: at91-sama5d2_shdwc: " Uwe Kleine-König
2023-11-05  9:47   ` Uwe Kleine-König
2023-11-08  6:56   ` claudiu beznea
2023-11-08  6:56     ` claudiu beznea
2023-11-05  9:53 ` [PATCH 00/14] power: reset: Drop platform_driver_probe() and convert " Uwe Kleine-König
2023-11-05  9:53   ` Uwe Kleine-König
2023-11-16  0:38 ` Sebastian Reichel
2023-11-16  0:38   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231104211501.3676352-19-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.