From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Peter Rosin <peda@lysator.liu.se>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Michael Hennerich <michael.hennerich@analog.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Andi Shyti <andi.shyti@kernel.org>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v12 1/7] i2c: core: add callback to change bus frequency
Date: Thu, 23 Jul 2026 13:36:29 +0200 [thread overview]
Message-ID: <amH8vX-M6lAWajQ_@gmail.com> (raw)
In-Reply-To: <19dbf4be-5f17-46b3-924d-eb24ae41fdd9@lysator.liu.se>
[-- Attachment #1: Type: text/plain, Size: 1916 bytes --]
Hi Peter!
On Thu, Jul 23, 2026 at 01:03:53PM +0200, Peter Rosin wrote:
> > + *
> > + * @set_clk_freq: Set clock frequency for the adapter. Returns the actual set frequency.
> > + * This function is optional.
> > */
> > struct i2c_adapter {
> > struct module *owner;
> > @@ -742,6 +745,8 @@ struct i2c_adapter {
> > struct rt_mutex mux_lock;
> >
> > int timeout; /* in jiffies */
> > + u32 clock_Hz; /* bus clock speed */
> > + int (*set_clk_freq)(struct i2c_adapter *adap, u32 clock_Hz); /* Optional */
>
> To expand on the comment from v9 by Wolfram [1], I too think it
> would be good if this function pointer did not live directly in
> i2c_adapter but instead in some other struct so that the actual
> pointer could live in read-only memory. I.e. if i2c_algorithm
> does not fit for some reason, a new function pointer struct might
> be called for?
My objection to move it to i2c_algorithm, was mostly based on that the
algorithm should not be aware of the current clock frequency. When I
reread the comment from Wolfram (and you), I realize that we are only
talking about the function pointer, which is fine to put into the
i2c_algorithm struct.
Sorry for the misinterpretation, I will move the pointer to
i2c_algorithm and keep clock_Hz in i2c_adapter.
>
> Also, returning int instead of unsigned hints that the function
> might return a negative error code, but the new code in 3/7 does
> not handle errors. So, either change to unsigned int, or update
> the support code in 3/7 to handle errors. I think the latter is
> the better approach.
Agree, thanks.
>
> Cheers,
> Peter
>
> [1] https://lore.kernel.org/all/ahX44_rzaRlTLSLU@shikoro/
>
> > int retries;
> > struct device dev; /* the adapter device */
> > unsigned long locked_flags; /* owned by the I2C core */
> >
>
Best regards,
Marcus Folkesson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-23 11:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 14:59 [PATCH v12 0/7] I2C Mux per channel bus speed Marcus Folkesson
2026-07-19 14:59 ` [PATCH v12 1/7] i2c: core: add callback to change bus frequency Marcus Folkesson
2026-07-23 11:03 ` Peter Rosin
2026-07-23 11:36 ` Marcus Folkesson [this message]
2026-07-23 14:04 ` Peter Rosin
2026-07-19 14:59 ` [PATCH v12 2/7] i2c: mux: add idle_state property to i2c_mux_core Marcus Folkesson
2026-07-23 11:04 ` Peter Rosin
2026-07-24 6:24 ` Marcus Folkesson
2026-07-19 14:59 ` [PATCH v12 3/7] i2c: mux: add support for per channel bus frequency Marcus Folkesson
2026-07-23 11:05 ` Peter Rosin
2026-07-19 14:59 ` [PATCH v12 4/7] i2c: davinci: calculate bus freq from Hz instead of kHz Marcus Folkesson
2026-07-23 11:05 ` Peter Rosin
2026-07-19 14:59 ` [PATCH v12 5/7] i2c: davinci: add support for setting bus frequency Marcus Folkesson
2026-07-23 11:05 ` Peter Rosin
2026-07-19 14:59 ` [PATCH v12 6/7] i2c: mux: ltc4306: set correct idle_state in i2c_mux_core Marcus Folkesson
2026-07-23 11:05 ` Peter Rosin
2026-07-19 14:59 ` [PATCH v12 7/7] docs: i2c: i2c-topology: add section about bus speed Marcus Folkesson
2026-07-23 11:06 ` Peter Rosin
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=amH8vX-M6lAWajQ_@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=brgl@bgdev.pl \
--cc=brgl@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=peda@lysator.liu.se \
--cc=wsa+renesas@sang-engineering.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