From: Alex Elder <elder@riscstar.com>
To: Haylen Chu <heylenay@4d2.org>,
p.zabel@pengutronix.de, mturquette@baylibre.com,
sboyd@kernel.org, dlan@gentoo.org
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
guodong@riscstar.com, paul.walmsley@sifive.com,
palmer@dabbelt.com, aou@eecs.berkeley.edu,
spacemit@lists.linux.dev, devicetree@vger.kernel.org,
linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND 2/7] clk: spacemit: define struct k1_ccu_data
Date: Mon, 24 Mar 2025 07:17:17 -0500 [thread overview]
Message-ID: <b8edc46b-bc99-47c1-8900-0e08c97de9d6@riscstar.com> (raw)
In-Reply-To: <Z-FHt3mDyEBKpa8O@ketchup>
On 3/24/25 6:53 AM, Haylen Chu wrote:
> On Fri, Mar 21, 2025 at 10:18:25AM -0500, Alex Elder wrote:
>> Define a new structure type to be used for describing the OF match data.
>> Rather than using the array of spacemit_ccu_clk structures for match
>> data, we use this structure instead.
>>
>> Move the definition of the spacemit_ccu_clk structure closer to the top
>> of the source file, and add the new structure definition below it.
>>
>> Shorten the name of spacemit_ccu_register() to be k1_ccu_register().
>
> I've read your conversation about moving parts of the patch into the
> clock series, I'm of course willing to :)
>
>> Signed-off-by: Alex Elder <elder@riscstar.com>
>> ---
>> drivers/clk/spacemit/ccu-k1.c | 58 ++++++++++++++++++++++++++---------
>> 1 file changed, 43 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
>> index 44db48ae71313..f7367271396a0 100644
>> --- a/drivers/clk/spacemit/ccu-k1.c
>> +++ b/drivers/clk/spacemit/ccu-k1.c
>> @@ -129,6 +129,15 @@
>> #define APMU_EMAC0_CLK_RES_CTRL 0x3e4
>> #define APMU_EMAC1_CLK_RES_CTRL 0x3ec
>>
>> +struct spacemit_ccu_clk {
>> + int id;
>> + struct clk_hw *hw;
>> +};
>> +
>> +struct k1_ccu_data {
>> + struct spacemit_ccu_clk *clk; /* array with sentinel */
>> +};
>
> This is something like what I've dropped in v5 of the clock series so I
> doubt whether it should be added back in clock series again, as at that
> point there's no reason for an extra structure: Alex, is it okay for you
> to keep the change in reset series?
That's perfectly fine with me. It's not necessary yet, so it's
just fine for you to do things the way you did, and I'll add this
in as part of the reset series.
> ...
>
>> +static int k1_ccu_register(struct device *dev, struct regmap *regmap,
>> + struct regmap *lock_regmap,
>> + struct spacemit_ccu_clk *clks)
>> {
>> const struct spacemit_ccu_clk *clk;
>> int i, ret, max_id = 0;
>> @@ -1648,15 +1668,24 @@ static int spacemit_ccu_register(struct device *dev,
>>
>> clk_data->num = max_id + 1;
>>
>> - return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
>> + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
>> + if (ret)
>> + dev_err(dev, "error %d adding clock hardware provider\n", ret);
>
> This error message definitely should go in the clock series.
>
>> + return ret;
>> }
>
>> static int k1_ccu_probe(struct platform_device *pdev)
>> {
>> struct regmap *base_regmap, *lock_regmap = NULL;
>> struct device *dev = &pdev->dev;
>> + const struct k1_ccu_data *data;
>> int ret;
>>
>> + data = of_device_get_match_data(dev);
>> + if (!data)
>> + return -EINVAL;
>
> Looking through the reset series, I don't see a reason that
> of_device_get_match_data() could return NULL. This is also something
> you've asked me to drop in v4 of the clock series, so I guess it isn't
> necessary.
You are correct. I'll drop it. I contemplated this and thought
it's useful to tell the reader it's necessary to not be null, but
you can tell it has to be by inspection.
>> base_regmap = device_node_to_regmap(dev->of_node);
>> if (IS_ERR(base_regmap))
>> return dev_err_probe(dev, PTR_ERR(base_regmap),
>> @@ -1677,8 +1706,7 @@ static int k1_ccu_probe(struct platform_device *pdev)
>> "failed to get lock regmap\n");
>> }
>>
>> - ret = spacemit_ccu_register(dev, base_regmap, lock_regmap,
>> - of_device_get_match_data(dev));
>> + ret = k1_ccu_register(dev, base_regmap, lock_regmap, data->clk);
>> if (ret)
>> return dev_err_probe(dev, ret, "failed to register clocks\n");
>
> For using ARRAY_SIZE() to simplify runtime code, it's mostly okay since
> binding IDs are continuous 0-based integers. But I split the handling of
> TWSI8 into another patch, which creates a hole in the range and breaks
> the assumption. Do you think the TWSI8 commit should be merged back in
> the clock driver one?
I didn't understand the reason why you separated the TWSI8 into a
separate commit. Now I know. The hole in the range doesn't really
matter much; you already initialize your ->hws[] array of pointers
with ERR_PTR(-ENOENT), so any holes are handled properly.
-Alex
>
> Best regards,
> Haylen Chu
next prev parent reply other threads:[~2025-03-24 12:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 15:18 [PATCH RESEND 0/7] clk: spacemit: add K1 reset support Alex Elder
2025-03-21 15:18 ` [PATCH RESEND 1/7] dt-bindings: soc: spacemit: define spacemit,k1-ccu resets Alex Elder
2025-03-21 20:42 ` Rob Herring
2025-03-21 22:25 ` Yixun Lan
2025-03-22 14:27 ` Alex Elder
2025-03-22 16:51 ` Yixun Lan
2025-03-21 15:18 ` [PATCH RESEND 2/7] clk: spacemit: define struct k1_ccu_data Alex Elder
2025-03-22 15:50 ` Yixun Lan
2025-03-23 12:43 ` Alex Elder
2025-03-23 13:04 ` Yixun Lan
2025-03-23 22:30 ` Alex Elder
2025-03-28 17:24 ` Alex Elder
2025-03-24 11:53 ` Haylen Chu
2025-03-24 12:17 ` Alex Elder [this message]
2025-03-21 15:18 ` [PATCH RESEND 3/7] clk: spacemit: add reset controller support Alex Elder
2025-03-22 16:19 ` Yixun Lan
2025-03-23 13:23 ` Alex Elder
2025-03-24 6:40 ` Yixun Lan
2025-03-24 12:20 ` Haylen Chu
2025-03-24 12:52 ` Alex Elder
2025-03-21 15:18 ` [PATCH RESEND 4/7] clk: spacemit: define existing syscon resets Alex Elder
2025-03-22 16:29 ` Yixun Lan
2025-03-23 13:23 ` Alex Elder
2025-03-24 6:24 ` Yixun Lan
2025-03-21 15:18 ` [PATCH RESEND 5/7] clk: spacemit: make clocks optional Alex Elder
2025-03-21 15:18 ` [PATCH RESEND 6/7] clk: spacemit: define new syscons with only resets Alex Elder
2025-03-22 16:42 ` Yixun Lan
2025-03-23 13:23 ` Alex Elder
2025-03-24 6:21 ` Yixun Lan
2025-03-28 17:24 ` Alex Elder
2025-03-21 15:18 ` [PATCH RESEND 7/7] riscv: dts: spacemit: add reset support for the K1 SoC Alex Elder
2025-03-22 16:48 ` Yixun Lan
2025-03-23 13:23 ` Alex Elder
2025-03-24 6:06 ` Yixun Lan
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=b8edc46b-bc99-47c1-8900-0e08c97de9d6@riscstar.com \
--to=elder@riscstar.com \
--cc=aou@eecs.berkeley.edu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=guodong@riscstar.com \
--cc=heylenay@4d2.org \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=spacemit@lists.linux.dev \
/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®