[PATCH v5 02/15] clk: renesas: r8a78000: Replace sentinel by explicit ID map size
Marek Vasut
marek.vasut at mailbox.org
Thu Nov 19 19:02:31 PST 2026
On 11/18/26 8:44 PM, Geert Uytterhoeven wrote:
> The use of a sentinel in the clock ID mapping array will become
> cumbersome when the need arises to find out the actual number of
> elements in the array. Rework the mapping data structure to fix this,
> also improving naming. Add a CLK_ID_MAP() initialization macro for
> brevity.
>
> While at it, drop the check for "!map" in clk_id_map_find(), as that
> pointer can never be NULL.
>
> Suggested-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
Reviewed-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
[...]
> -struct clk_map {
> - int dt_id; /* DT binding clock ID or -1 sentinel */
> +struct clk_id_map_entry {
> + u32 dt_id; /* DT binding clock ID */
> u32 fw_id; /* FIXED_CLK() ID */
> };
>
> +struct clk_id_map {
> + const struct clk_id_map_entry *entries;
> + unsigned int size;
> +};
> +
> +#define CLK_ID_MAP(_entries) &(struct clk_id_map) { \
> + .entries = _entries, \
> + .size = ARRAY_SIZE(_entries), \
> +}
I am surprised there is no generic ARRAY_AND_SIZE() macro for this already.
More information about the linux-arm-kernel
mailing list