From: Andi Shyti <andi.shyti@kernel.org>
To: Hongliang Wang <wanghongliang@loongson.cn>
Cc: Binbin Zhou <zhoubinbin@loongson.cn>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
loongarch@lists.linux.dev, Huacai Chen <chenhuacai@loongson.cn>,
stable@vger.kernel.org
Subject: Re: [PATCH v8 2/2] i2c: ls2x: Add clocks property parsing and adjust bus speed
Date: Sat, 25 Jul 2026 01:39:35 +0200 [thread overview]
Message-ID: <amPz7-dljqdfwNGc@zenone.zhora.eu> (raw)
In-Reply-To: <20260721122604.12717-3-wanghongliang@loongson.cn>
On Tue, Jul 21, 2026 at 08:26:04PM +0800, Hongliang Wang wrote:
> The i2c-ls2x driver supports dts and acpi parameter passing.
>
> In dts, uses clock framework, by parsing clocks property to
> get i2c bus reference clock, and define the div of reference
> clock by device data.
>
> In acpi, by passing clocks property to describe i2c bus reference
> clock and clock-div property to describe the div of reference clock.
>
> Based on i2c bus reference clock(clock_a), i2c bus speed(clock_s)
> and div, calculate the prcescale of i2c divider register. The
> calculation formula is
>
> prcescale = (clock_a*10)/(div*clock_s)-1
This commit log is not understandable, what did you actually do
here? Please read carefully the submitting-patches documentation
(under the "Describe your changes" paragraph).
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
I haven't seen Huacai's review on patch 2, as far as I've seen he
has reviewed only patch 1. Have I missed anything?
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
Is this a Fix? I asked you this already. Please read carefully
the paragraph I suggested and add the necessary tag.
> ---
> drivers/i2c/busses/i2c-ls2x.c | 40 ++++++++++++++++++++++++++++++++---
> 1 file changed, 37 insertions(+), 3 deletions(-)
>
...
> @@ -107,12 +116,13 @@ static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)
> else
> t->bus_freq_hz = LS2X_I2C_FREQ_STD;
>
> + val = (priv->pclk * 10) / (priv->div * t->bus_freq_hz) - 1;
Sashiko pointed out that this might overflow. While your replied
that the expected platform values may not overflow, the code does
not enforce those constraints.
The clock rate comes from firmware or the clock framework, so at
least a zero rate should be rejected. Using 64-bit arithmetic here
would also avoid relying on undocumented assumptions about the
input range at essentially no cost.
> +
...
> + if (dev_of_node(dev)) {
> + clk = devm_clk_get_optional_enabled(dev, NULL);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> + if (clk)
> + priv->pclk = clk_get_rate(clk);
> + else
> + priv->pclk = LS2X_I2C_PCLK_FREQ;
> +
> + priv->div = (unsigned long)device_get_match_data(dev);
> + if (!priv->div)
> + priv->div = LS2X_I2C_2K_CLOCK_DIV;
> + } else {
> + /* clocks and clock-div are only ACPI properties. */
clocks is also DT property.
Andi
> + ret = device_property_read_u32(dev, "clocks", &priv->pclk);
> + if (ret)
> + priv->pclk = LS2X_I2C_PCLK_FREQ;
next prev parent reply other threads:[~2026-07-24 23:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 12:26 [PATCH v8 0/2] i2c: ls2x: Add clock- related properties and parsing Hongliang Wang
2026-07-21 12:26 ` [PATCH v8 1/2] dt-bindings: i2c: ls2x-i2c: Add clocks and clock-frequency properties Hongliang Wang
2026-07-21 12:26 ` [PATCH v8 2/2] i2c: ls2x: Add clocks property parsing and adjust bus speed Hongliang Wang
2026-07-24 23:39 ` Andi Shyti [this message]
2026-08-01 9:17 ` Hongliang Wang
2026-07-29 8:09 ` Xi Ruoyao
2026-08-01 9:12 ` Hongliang Wang
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=amPz7-dljqdfwNGc@zenone.zhora.eu \
--to=andi.shyti@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=wanghongliang@loongson.cn \
--cc=wsa+renesas@sang-engineering.com \
--cc=zhoubinbin@loongson.cn \
/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