Re: [PATCH 2/4] driver: core: platform: add subsys_platform_driver() macro
From: Geert Uytterhoeven
Date: Wed Sep 09 2026 - 12:34:54 EST
Hi Brian,
On Tue, 8 Sept 2026 at 19:47, Brian Masney <bmasney@xxxxxxxxxx> wrote:
> Add a new macro subsys_platform_driver() to eliminate some boilerplate
> code in drivers that need to register earlier in the boot at the
> subsys_initcall level.
>
> Signed-off-by: Brian Masney <bmasney@xxxxxxxxxx>
> Assisted-by: Claude:claude-opus-4-8
Thanks for your patch!
Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -376,6 +389,23 @@ static int __init __platform_driver##_init(void) \
> } \
> device_initcall(__platform_driver##_init); \
>
> +/*
> + * subsys_platform_driver_probe() - Helper macro for drivers that don't do
> + * anything special in device init and have no exit, but need to register
> + * earlier, at subsys_initcall level. This eliminates some boilerplate. Each
> + * driver may only use this macro once, and using it replaces subsys_initcall.
> + * This is meant to be a parallel of builtin_platform_driver_probe above, but
> + * with the init call promoted to subsys_initcall so the provider is available
> + * earlier during boot.
> + */
> +#define subsys_platform_driver_probe(__platform_driver, __platform_probe) \
> +static int __init __platform_driver##_init(void) \
> +{ \
> + return platform_driver_probe(&(__platform_driver), \
> + __platform_probe); \
> +} \
> +subsys_initcall(__platform_driver##_init) \
Nit: The backslash is not needed.
Yeah, builtin_platform_driver_probe() has it, too...
> +
> #define platform_create_bundle(driver, probe, res, n_res, data, size) \
> __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE, KBUILD_MODNAME)
> extern struct platform_device *__platform_create_bundle(
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
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