From: Rosen Penev <rosenp@gmail.com>
To: linux-clk@vger.kernel.org
Cc: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney@redhat.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] clk: pistachio: Use flexible array for clock table
Date: Mon, 11 May 2026 18:09:38 -0700 [thread overview]
Message-ID: <20260512010938.41114-1-rosenp@gmail.com> (raw)
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
reply other threads:[~2026-05-12 1:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512010938.41114-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=bmasney@redhat.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox