[PATCH 01/20] mtd: rawnand: txx9ndfmc: Mark driver struct with __refdata to prevent section mismatch warning
Masahiro Yamada
masahiroy at kernel.org
Mon Oct 9 00:22:27 PDT 2023
On Mon, Oct 9, 2023 at 5:02 AM Uwe Kleine-König
<u.kleine-koenig at pengutronix.de> wrote:
>
> 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 with
> CONFIG_MTD_NAND_TXX9NDFMC=m:
>
> WARNING: modpost: drivers/mtd/nand/raw/txx9ndfmc: section mismatch in reference: txx9ndfmc_driver+0x4 (section: .data) -> txx9ndfmc_remove (section: .exit.text)
>
> Fixes: 64fb65baffa5 ("[MTD] TXx9 SoC NAND Flash Memory Controller driver")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> Hello,
>
> note this warning only triggers with f177cd0c15fc ("modpost: Don't let
> "driver"s reference .exit.*") that currently waits in next for the next
> merge window + building with W=1.
>
> Best regards
> Uwe
>
> drivers/mtd/nand/raw/txx9ndfmc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/txx9ndfmc.c b/drivers/mtd/nand/raw/txx9ndfmc.c
> index eddcc0728a67..aff9d6f16851 100644
> --- a/drivers/mtd/nand/raw/txx9ndfmc.c
> +++ b/drivers/mtd/nand/raw/txx9ndfmc.c
> @@ -406,7 +406,13 @@ static int txx9ndfmc_resume(struct platform_device *dev)
> #define txx9ndfmc_resume NULL
> #endif
>
> -static struct platform_driver txx9ndfmc_driver = {
> +/*
> + * txx9ndfmc_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 txx9ndfmc_driver __refdata = {
> .remove = __exit_p(txx9ndfmc_remove),
> .resume = txx9ndfmc_resume,
> .driver = {
> --
> 2.40.1
>
We have thousands of module_platform_drivers.
I would be scared if they started to add __refdata.
I am not sure if this is the right direction.
I added Greg and Arnd to CC.
In my understanding of the current DT overlay,
there is no way to create/remove a platform device dynamically.
I do not know if that will happen in the future.
--
Best Regards
Masahiro Yamada
More information about the linux-mtd
mailing list