mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Crispin <john@phrozen.org>
To: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@kernel.org>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Vitaliy Sochnev <sochnev.v.74@gmail.com>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Felix Fietkau <nbd@nbd.name>,
	devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org, lei.dong@airoha.com,
	Linqi.zhang@airoha.com, Rajeev.kumar@airoha.com,
	upstream@airoha.com, Weifeng.xu@airoha.com,
	zhengping.zhang@airoha.com
Subject: [PATCH 3/6] clk: en7523: decouple base clock count from clock ID count
Date: Tue, 24 Nov 2026 11:12:17 +0100	[thread overview]
Message-ID: <20261124101220.3888170-4-john@phrozen.org> (raw)
In-Reply-To: <20261124101220.3888170-1-john@phrozen.org>

en7581_register_clocks() walks num_clocks entries of base_clks[], and
num_clocks also sizes hws[]. That holds only while every clock ID below
num_clocks has a descriptor. A SoC that leaves an ID unused, or whose
largest ID is not the last descriptor, either reads past the array or
writes hws[] past its allocation.

Carry the descriptor count separately. num_clocks keeps sizing hws[].

No functional change.

Signed-off-by: John Crispin <john@phrozen.org>
---
 drivers/clk/clk-en7523.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index d044841cdc05..2799b550401e 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -149,6 +149,7 @@ struct en_clk_priv {
 struct en_clk_soc_data {
 	u32 num_clocks;
 	const struct en_clk_desc *base_clks;
+	unsigned int num_base_clks;
 	const struct clk_ops pcie_ops;
 	int (*hw_init)(struct platform_device *pdev,
 		       struct clk_hw_onecell_data *clk_data);
@@ -1006,7 +1007,7 @@ static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_dat
 
 	soc_data = device_get_match_data(dev);
 
-	for (i = 0; i < soc_data->num_clocks; i++) {
+	for (i = 0; i < soc_data->num_base_clks; i++) {
 		const struct en_clk_desc *desc = &soc_data->base_clks[i];
 		u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg;
 		int err;
@@ -1527,6 +1528,7 @@ static const struct en_clk_soc_data en7523_data = {
 
 static const struct en_clk_soc_data en7581_data = {
 	.base_clks = en7581_base_clks,
+	.num_base_clks = ARRAY_SIZE(en7581_base_clks),
 	.num_clocks = ARRAY_SIZE(en7581_base_clks),
 	.pcie_ops = {
 		.is_enabled = en7581_pci_is_enabled,
@@ -1538,6 +1540,7 @@ static const struct en_clk_soc_data en7581_data = {
 
 static const struct en_clk_soc_data an7583_data = {
 	.base_clks = an7583_base_clks,
+	.num_base_clks = ARRAY_SIZE(an7583_base_clks),
 	.num_clocks = ARRAY_SIZE(an7583_base_clks),
 	.pcie_ops = {
 		.is_enabled = en7581_pci_is_enabled,
-- 
2.34.1


  parent reply	other threads:[~2026-11-24 10:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 10:12 [PATCH 0/6] clk: en7523: add support for Airoha AN7589 John Crispin
2026-11-24 10:12 ` [PATCH 1/6] dt-bindings: arm: airoha: add AN7589 chip SCU John Crispin
2026-11-24 10:12 ` [PATCH 2/6] dt-bindings: clock: airoha: add AN7589 John Crispin
2026-11-24 10:12 ` John Crispin [this message]
2026-11-24 10:12 ` [PATCH 4/6] clk: en7523: add support for Airoha AN7589 John Crispin
2026-11-24 10:12 ` [PATCH 5/6] dt-bindings: clock: airoha: allow MDIO controllers under the SCU John Crispin
2026-11-24 10:12 ` [PATCH 6/6] clk: en7523: populate SCU child devices John Crispin

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=20261124101220.3888170-4-john@phrozen.org \
    --to=john@phrozen.org \
    --cc=Linqi.zhang@airoha.com \
    --cc=Rajeev.kumar@airoha.com \
    --cc=Weifeng.xu@airoha.com \
    --cc=ansuelsmth@gmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jbrunet+clk@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lei.dong@airoha.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sochnev.v.74@gmail.com \
    --cc=upstream@airoha.com \
    --cc=zhengping.zhang@airoha.com \
    /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

all inboxes | Powered by JetHome®