[PATCH v2 01/12] clk: add new flag CLK_ROUNDING_NOOP
Stephen Boyd
sboyd at kernel.org
Tue Apr 28 19:15:36 PDT 2026
Quoting Brian Masney (2026-03-09 07:38:40)
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index fd418dc988b1c60c49e3ac9c0c44aa132dd5da28..1187e5b1dbc123d2d2c1f43690d7dcf75a7c4ac3 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -1673,7 +1690,7 @@ EXPORT_SYMBOL_GPL(clk_hw_forward_rate_request);
>
> static bool clk_core_can_round(struct clk_core * const core)
> {
> - return core->ops->determine_rate;
> + return core->ops->determine_rate || clk_is_rounding_noop(core);
> }
>
> static int clk_core_round_rate_nolock(struct clk_core *core,
> @@ -3528,6 +3545,7 @@ static const struct {
> ENTRY(CLK_IS_CRITICAL),
> ENTRY(CLK_OPS_PARENT_ENABLE),
> ENTRY(CLK_DUTY_CYCLE_PARENT),
> + ENTRY(CLK_ROUNDING_NOOP),
> #undef ENTRY
> };
>
> @@ -3906,13 +3924,19 @@ static int __clk_core_init(struct clk_core *core)
>
> /* check that clk_ops are sane. See Documentation/driver-api/clk.rst */
> if (core->ops->set_rate && !core->ops->determine_rate &&
> - core->ops->recalc_rate) {
> + core->ops->recalc_rate && !clk_is_rounding_noop(core)) {
> pr_err("%s: %s must implement .determine_rate in addition to .recalc_rate\n",
> __func__, core->name);
> ret = -EINVAL;
> goto out;
> }
>
> + if (clk_is_rounding_noop(core) && core->ops->determine_rate) {
> + pr_err("%s: %s cannot implement both .determine_rate and CLK_ROUNDING_NOOP\n",
> + __func__, core->name);
> + goto out;
> + }
> +
This hunk has me irked. I'd rather we export some function like
clk_determine_rate_noop() that just returns 0 instead of adding another
flag. The chance that someone can get it wrong goes down and you can
naturally grep for any clks that are using determine_rate() without
having to also include this flag in the grep. It makes it easier to
reason about as well because we can have code that just checks for
determine_rate presence instead of both (i.e. clk_core_can_round() isn't
changed). Plus a clk_ops structure is more self-contained because it
doesn't rely on the clk flags to go with it.
More information about the linux-arm-kernel
mailing list