Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>, linux-clk@vger.kernel.org
Subject: Re: [PATCH 1/2] clk: en7523: convert to full clk_hw implementation for en7581
Date: Thu, 22 Oct 2026 21:02:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-182041@kernel.org> (raw)
In-Reply-To: <20261022205535.688352-2-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: en7523: negative error returned as unsigned rate in en7581_recalc_rate()
--

commit 3b91713eaffa8e4eb9f5cbbb86a0f1a541e129cc
Author: Christian Marangi <ansuelsmth@gmail.com>

clk: en7523: convert to full clk_hw implementation for en7581

This commit converts the Airoha EN7581 clock registration in
drivers/clk/clk-en7523.c from fixed-rate clocks to a full clk_hw
implementation with a dedicated .recalc_rate callback in preparation for
adding .set_rate support.

> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 24fdec2e6198c..2f203c94f87e9 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c

[ ... ]

> @@ -742,46 +748,76 @@ static int en7523_clk_hw_init(struct platform_device *pdev,
>  				     en7581_rst_ofs);
>  }
>  
> -static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data,
> -				   struct regmap *map, void __iomem *base)
> +static unsigned long en7581_recalc_rate(struct clk_hw *hw,
> +					unsigned long parent_rate)
>  {
> -	struct clk_hw *hw;
> +	struct en_clk *c = container_of(hw, struct en_clk, hw);
> +	const struct en_clk_desc *desc = c->desc;
> +	struct regmap *map = c->map;
> +	u32 val, reg;
>  	u32 rate;
> +	int err;
> +
> +	err = regmap_read(map, desc->base_reg, &val);
> +	if (err) {
> +		pr_err("Failed reading fixed clk rate %s: %d\n",
> +		       desc->name, err);
> +		return err;
> +	}
> +	rate = en7523_get_base_rate(desc, val);
> +
> +	reg = desc->div_reg ? desc->div_reg : desc->base_reg;
> +	err = regmap_read(map, reg, &val);
> +	if (err) {
> +		pr_err("Failed reading fixed clk div %s: %d\n",
> +		       desc->name, err);
> +		return err;
> +	}

[Severity: Medium]
In drivers/clk/clk-en7523.c, when either regmap_read() call on desc->base_reg
or reg fails in en7581_recalc_rate(), returning the negative int err from an
unsigned long .recalc_rate callback converts it into a large positive value
instead of 0.

Per struct clk_ops in include/linux/clk-provider.h, .recalc_rate must return 0
if the driver cannot figure out a rate for the clock, as callers such as
__clk_core_init() and clk_recalc() in drivers/clk/clk.c store the returned
unsigned long directly into core->rate.

Should both error paths in en7581_recalc_rate() return 0 instead of err?

> +
> +	return rate / en7523_get_div(desc, val);
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261022205535.688352-1-ansuelsmth@gmail.com?part=1

  reply	other threads:[~2026-10-22 21:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 20:55 [PATCH 0/2] clk: en7523: full clk_hw + set_rate for en7581 Christian Marangi
2026-10-22 20:55 ` [PATCH 1/2] clk: en7523: convert to full clk_hw implementation " Christian Marangi
2026-10-22 21:02   ` sashiko-bot [this message]
2026-10-22 20:55 ` [PATCH 2/2] clk: en7523: add support for .set_rate " Christian Marangi

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=sashiko-outbox-182041@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=sashiko-reviews@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