* [PATCH] clk: pistachio: Use flexible array for clock table
@ 2026-05-12 1:09 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-05-12 1:09 UTC (permalink / raw)
To: linux-clk; +Cc: Michael Turquette, Stephen Boyd, Brian Masney, open list
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>
---
drivers/clk/pistachio/clk.c | 15 ++++-----------
drivers/clk/pistachio/clk.h | 1 +
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/clk/pistachio/clk.c b/drivers/clk/pistachio/clk.c
index 80c722c77a1b..03e28779011f 100644
--- a/drivers/clk/pistachio/clk.c
+++ b/drivers/clk/pistachio/clk.c
@@ -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)
diff --git a/drivers/clk/pistachio/clk.h b/drivers/clk/pistachio/clk.h
index 2f4ffbd98282..1b9b311b9656 100644
--- a/drivers/clk/pistachio/clk.h
+++ b/drivers/clk/pistachio/clk.h
@@ -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 *
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-12 1:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 1:09 [PATCH] clk: pistachio: Use flexible array for clock table Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox