clk: pistachio: Use flexible array for clock table

Store the clock lookup table in the Pistachio clock provider
allocation instead of allocating it separately.

This ties the table lifetime directly to the provider and removes a
separate allocation failure path while preserving the clk_onecell_data
lookup interface.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Brian Masney <bmasney@redhat.com>
This commit is contained in:
Rosen Penev 2026-05-11 18:09:38 -07:00 committed by Brian Masney
parent e98e3d7120
commit d27364c5db
2 changed files with 5 additions and 11 deletions

View File

@ -17,28 +17,21 @@ pistachio_clk_alloc_provider(struct device_node *node, unsigned int num_clks)
{
struct pistachio_clk_provider *p;
p = kzalloc_obj(*p);
p = kzalloc_flex(*p, clks, num_clks);
if (!p)
return p;
p->clk_data.clks = kzalloc_objs(struct clk *, num_clks);
if (!p->clk_data.clks)
goto free_provider;
p->clk_data.clks = p->clks;
p->clk_data.clk_num = num_clks;
p->node = node;
p->base = of_iomap(node, 0);
if (!p->base) {
pr_err("Failed to map clock provider registers\n");
goto free_clks;
kfree(p);
return NULL;
}
return p;
free_clks:
kfree(p->clk_data.clks);
free_provider:
kfree(p);
return NULL;
}
void pistachio_clk_register_provider(struct pistachio_clk_provider *p)

View File

@ -142,6 +142,7 @@ struct pistachio_clk_provider {
struct device_node *node;
void __iomem *base;
struct clk_onecell_data clk_data;
struct clk *clks[];
};
extern struct pistachio_clk_provider *