* [PATCH] serial: ami: Mark driver struct with __refdata to prevent section mismatch
[not found] <2e3783106bf6bd9a7bdeb12b706378fb16316471.1711748999.git.u.kleine-koenig@pengutronix.de>
@ 2024-03-29 21:54 ` Uwe Kleine-König
2024-03-29 21:54 ` [PATCH] serial: pmac_zilog: Drop usage of platform_driver_probe() Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2024-03-29 21:54 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: linux-kbuild, linux-serial, 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 the following section mismatch warning
WARNING: modpost: drivers/tty/amiserial: section mismatch in reference: amiga_serial_driver+0x8 (section: .data) -> amiga_serial_remove (section: .exit.text)
that triggers on an allmodconfig W=1 build.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/tty/amiserial.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index e27360652d9b..8c964da75f2d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1578,7 +1578,13 @@ static void __exit amiga_serial_remove(struct platform_device *pdev)
free_irq(IRQ_AMIGA_RBF, state);
}
-static struct platform_driver amiga_serial_driver = {
+/*
+ * amiga_serial_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 amiga_serial_driver __refdata = {
.remove_new = __exit_p(amiga_serial_remove),
.driver = {
.name = "amiga-serial",
base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] serial: pmac_zilog: Drop usage of platform_driver_probe()
[not found] <2e3783106bf6bd9a7bdeb12b706378fb16316471.1711748999.git.u.kleine-koenig@pengutronix.de>
2024-03-29 21:54 ` [PATCH] serial: ami: Mark driver struct with __refdata to prevent section mismatch Uwe Kleine-König
@ 2024-03-29 21:54 ` Uwe Kleine-König
2024-04-03 5:15 ` Michael Ellerman
1 sibling, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2024-03-29 21:54 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Dawei Li,
Damien Le Moal, Jakub Kicinski, Thomas Gleixner
Cc: Nicholas Piggin, Christophe Leroy, Aneesh Kumar K.V,
Naveen N. Rao, linux-kbuild, linux-serial, linuxppc-dev, kernel
There are considerations to drop platform_driver_probe() as a concept
that isn't relevant any more today. It comes with an added complexity
that makes many users hold it wrong. (E.g. this driver should have
marked the driver struct with __refdata to prevent the below mentioned
false positive section mismatch warning.)
This fixes a W=1 build warning:
WARNING: modpost: drivers/tty/serial/pmac_zilog: section mismatch in reference: pmz_driver+0x8 (section: .data) -> pmz_detach (section: .exit.text)
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/tty/serial/pmac_zilog.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 05d97e89511e..e44621218248 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1695,7 +1695,7 @@ static void pmz_dispose_port(struct uart_pmac_port *uap)
memset(uap, 0, sizeof(struct uart_pmac_port));
}
-static int __init pmz_attach(struct platform_device *pdev)
+static int pmz_attach(struct platform_device *pdev)
{
struct uart_pmac_port *uap;
int i;
@@ -1714,7 +1714,7 @@ static int __init pmz_attach(struct platform_device *pdev)
return uart_add_one_port(&pmz_uart_reg, &uap->port);
}
-static void __exit pmz_detach(struct platform_device *pdev)
+static void pmz_detach(struct platform_device *pdev)
{
struct uart_pmac_port *uap = platform_get_drvdata(pdev);
@@ -1789,7 +1789,8 @@ static struct macio_driver pmz_driver = {
#else
static struct platform_driver pmz_driver = {
- .remove_new = __exit_p(pmz_detach),
+ .probe = pmz_attach,
+ .remove_new = pmz_detach,
.driver = {
.name = "scc",
},
@@ -1837,7 +1838,7 @@ static int __init init_pmz(void)
#ifdef CONFIG_PPC_PMAC
return macio_register_driver(&pmz_driver);
#else
- return platform_driver_probe(&pmz_driver, pmz_attach);
+ return platform_driver_register(&pmz_driver);
#endif
}
base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] serial: pmac_zilog: Drop usage of platform_driver_probe()
2024-03-29 21:54 ` [PATCH] serial: pmac_zilog: Drop usage of platform_driver_probe() Uwe Kleine-König
@ 2024-04-03 5:15 ` Michael Ellerman
0 siblings, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2024-04-03 5:15 UTC (permalink / raw)
To: Uwe Kleine-König, Greg Kroah-Hartman, Jiri Slaby, Dawei Li,
Damien Le Moal, Jakub Kicinski, Thomas Gleixner
Cc: Nicholas Piggin, Christophe Leroy, Aneesh Kumar K.V,
Naveen N. Rao, linux-kbuild, linux-serial, linuxppc-dev, kernel
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:
> There are considerations to drop platform_driver_probe() as a concept
> that isn't relevant any more today. It comes with an added complexity
> that makes many users hold it wrong. (E.g. this driver should have
> marked the driver struct with __refdata to prevent the below mentioned
> false positive section mismatch warning.)
>
> This fixes a W=1 build warning:
>
> WARNING: modpost: drivers/tty/serial/pmac_zilog: section mismatch in reference: pmz_driver+0x8 (section: .data) -> pmz_detach (section: .exit.text)
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/tty/serial/pmac_zilog.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
I gave it a quick spin in qemu, no issues.
Tested-by: Michael Ellerman <mpe@ellerman.id.au>
cheers
> diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
> index 05d97e89511e..e44621218248 100644
> --- a/drivers/tty/serial/pmac_zilog.c
> +++ b/drivers/tty/serial/pmac_zilog.c
> @@ -1695,7 +1695,7 @@ static void pmz_dispose_port(struct uart_pmac_port *uap)
> memset(uap, 0, sizeof(struct uart_pmac_port));
> }
>
> -static int __init pmz_attach(struct platform_device *pdev)
> +static int pmz_attach(struct platform_device *pdev)
> {
> struct uart_pmac_port *uap;
> int i;
> @@ -1714,7 +1714,7 @@ static int __init pmz_attach(struct platform_device *pdev)
> return uart_add_one_port(&pmz_uart_reg, &uap->port);
> }
>
> -static void __exit pmz_detach(struct platform_device *pdev)
> +static void pmz_detach(struct platform_device *pdev)
> {
> struct uart_pmac_port *uap = platform_get_drvdata(pdev);
>
> @@ -1789,7 +1789,8 @@ static struct macio_driver pmz_driver = {
> #else
>
> static struct platform_driver pmz_driver = {
> - .remove_new = __exit_p(pmz_detach),
> + .probe = pmz_attach,
> + .remove_new = pmz_detach,
> .driver = {
> .name = "scc",
> },
> @@ -1837,7 +1838,7 @@ static int __init init_pmz(void)
> #ifdef CONFIG_PPC_PMAC
> return macio_register_driver(&pmz_driver);
> #else
> - return platform_driver_probe(&pmz_driver, pmz_attach);
> + return platform_driver_register(&pmz_driver);
> #endif
> }
>
> base-commit: a6bd6c9333397f5a0e2667d4d82fef8c970108f2
> --
> 2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-03 5:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2e3783106bf6bd9a7bdeb12b706378fb16316471.1711748999.git.u.kleine-koenig@pengutronix.de>
2024-03-29 21:54 ` [PATCH] serial: ami: Mark driver struct with __refdata to prevent section mismatch Uwe Kleine-König
2024-03-29 21:54 ` [PATCH] serial: pmac_zilog: Drop usage of platform_driver_probe() Uwe Kleine-König
2024-04-03 5:15 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox