diff mbox series

pcmcia: omap_cf: : Mark driver struct with __refdata to prevent section mismatch

Message ID 9e56c0d03509d79736961ded7a1b90a361fd2e06.1730895069.git.geert+renesas@glider.be (mailing list archive)
State New
Headers show
Series pcmcia: omap_cf: : Mark driver struct with __refdata to prevent section mismatch | expand

Commit Message

Geert Uytterhoeven Nov. 6, 2024, 12:13 p.m. UTC
As described in the added code comment, a reference to .exit.text is ok
for drivers registered via platform_driver_probe().  Make this explicit
to prevent the following section mismatch warning

    WARNING: modpost: drivers/pcmcia/omap_cf: section mismatch in reference: omap_cf_driver+0x4 (section: .data) -> omap_cf_remove (section: .exit.text)

that triggers on an omap1_defconfig + CONFIG_OMAP_CF=m build.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/pcmcia/omap_cf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Geert Uytterhoeven Nov. 6, 2024, 12:51 p.m. UTC | #1
On Wed, Nov 6, 2024 at 1:14 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> As described in the added code comment, a reference to .exit.text is ok
> for drivers registered via platform_driver_probe().  Make this explicit
> to prevent the following section mismatch warning
>
>     WARNING: modpost: drivers/pcmcia/omap_cf: section mismatch in reference: omap_cf_driver+0x4 (section: .data) -> omap_cf_remove (section: .exit.text)
>
> that triggers on an omap1_defconfig + CONFIG_OMAP_CF=m build.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

There is one more in the DaVinci cpufreq driver, but that one never
triggers a warning, as it cannot be a module.

So either davinci_cpufreq_remove() should be removed (it is never
emitted), or the __exit and __exit_p() should be dropped (then it can
be unbound manually, but never rebound).

https://elixir.bootlin.com/linux/v6.11.6/source/drivers/cpufreq/davinci-cpufreq.c#L134

Thoughts?

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Aaro Koskinen Nov. 7, 2024, 7:56 p.m. UTC | #2
Hi,

On Wed, Nov 06, 2024 at 01:13:57PM +0100, Geert Uytterhoeven wrote:
> As described in the added code comment, a reference to .exit.text is ok
> for drivers registered via platform_driver_probe().  Make this explicit
> to prevent the following section mismatch warning
> 
>     WARNING: modpost: drivers/pcmcia/omap_cf: section mismatch in reference: omap_cf_driver+0x4 (section: .data) -> omap_cf_remove (section: .exit.text)
> 
> that triggers on an omap1_defconfig + CONFIG_OMAP_CF=m build.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>

A.

> ---
>  drivers/pcmcia/omap_cf.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
> index 80137c7afe0d9bcf..938fad9c12aa8a4e 100644
> --- a/drivers/pcmcia/omap_cf.c
> +++ b/drivers/pcmcia/omap_cf.c
> @@ -302,7 +302,13 @@ static void __exit omap_cf_remove(struct platform_device *pdev)
>  	kfree(cf);
>  }
>  
> -static struct platform_driver omap_cf_driver = {
> +/*
> + * omap_cf_remove() lives in .exit.text. For drivers registered via
> + * 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 omap_cf_driver __refdata = {
>  	.driver = {
>  		.name	= driver_name,
>  	},
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 80137c7afe0d9bcf..938fad9c12aa8a4e 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -302,7 +302,13 @@  static void __exit omap_cf_remove(struct platform_device *pdev)
 	kfree(cf);
 }
 
-static struct platform_driver omap_cf_driver = {
+/*
+ * omap_cf_remove() lives in .exit.text. For drivers registered via
+ * 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 omap_cf_driver __refdata = {
 	.driver = {
 		.name	= driver_name,
 	},