[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200912232022.GE3715@yoga>
Date: Sat, 12 Sep 2020 18:20:22 -0500
From: Bjorn Andersson <bjorn.andersson@...aro.org>
To: Marc Zyngier <maz@...nel.org>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Enric Balletbo i Serra <enric.balletbo@...labora.com>,
Frank Wunderlich <linux@...web.de>,
John Stultz <john.stultz@...aro.org>,
Saravana Kannan <saravanak@...gle.com>,
Hanks Chen <hanks.chen@...iatek.com>,
Andy Gross <agross@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Jason Cooper <jason@...edaemon.net>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>, kernel-team@...roid.com
Subject: Re: [PATCH 1/6] of: Add basic infrastructure to create early probe
arrays
On Sat 12 Sep 07:51 CDT 2020, Marc Zyngier wrote:
> We currently probe interrupt controller and timers that need
> to be available very early using an infratstructure that creates
> struct of_device_id instances in a special section. These are
> individual structures that are ultimately collated by the linker.
>
> In order to facilitate further use of this infrastructure for
> drivers that can either be built modular or as an early driver,
> let's add a couple of helpers that will make it look like a
> "normal" device_id array, like this:
>
> _OF_DECLARE_ARRAY_START(table, name)
> _OF_DECLARE_ELMT("compat-1", probe, type)
> _OF_DECLARE_ELMT("compat-2", probe, type)
> _OF_DECLARE_ELMT("compat-3", other_probe, type)
> _OF_DECLARE_ARRAY_END
>
Reviewed-by: Bjorn Andersson <bjorn.andersson@...aro.org>
Regards,
Bjorn
> Signed-off-by: Marc Zyngier <maz@...nel.org>
> ---
> include/linux/of.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 5cf7ae0465d1..08f78da95378 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -1291,20 +1291,35 @@ static inline int of_get_available_child_count(const struct device_node *np)
> return num;
> }
>
> +#define __OF_DECLARE_ARRAY_START(name, section) \
> + static const struct of_device_id __of_table_##name[] \
> + __used __section(section) = {
> +
> #if defined(CONFIG_OF) && !defined(MODULE)
> #define _OF_DECLARE(table, name, compat, fn, fn_type) \
> static const struct of_device_id __of_table_##name \
> __used __section(__##table##_of_table) \
> = { .compatible = compat, \
> .data = (fn == (fn_type)NULL) ? fn : fn }
> +#define _OF_DECLARE_ARRAY_START(table, name) \
> + __OF_DECLARE_ARRAY_START(name, __##table##_of_table)
> #else
> #define _OF_DECLARE(table, name, compat, fn, fn_type) \
> static const struct of_device_id __of_table_##name \
> __attribute__((unused)) \
> = { .compatible = compat, \
> .data = (fn == (fn_type)NULL) ? fn : fn }
> +#define _OF_DECLARE_ARRAY_START(table, name) \
> + __OF_DECLARE_ARRAY_START(name, unused)
> #endif
>
> +#define _OF_DECLARE_ARRAY_END }
> +#define _OF_DECLARE_ELMT(compat, fn, fn_type) \
> + { \
> + .compatible = compat, \
> + .data = (fn == (fn_type)NULL) ? fn : fn, \
> + },
> +
> typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
> typedef int (*of_init_fn_1_ret)(struct device_node *);
> typedef void (*of_init_fn_1)(struct device_node *);
> --
> 2.28.0
>
Powered by blists - more mailing lists