From: Jules Maselbas <jmaselbas@zdiv.net>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@zdiv.net>
Subject: [PATCH v2 1/6] clk: divider: add error code propagation
Date: Tue, 7 Jan 2025 15:37:35 +0100 [thread overview]
Message-ID: <20250107143740.16903-2-jmaselbas@zdiv.net> (raw)
In-Reply-To: <20250107143740.16903-1-jmaselbas@zdiv.net>
divider_get_val can return a negative error code and should not be used
as a valid divider.
Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
v1->v2:
- changed value to int and removed ret variable (Ahmad)
drivers/clk/clk-divider.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index ccab70aecc..b0df34e858 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -307,7 +307,7 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct clk *clk = clk_hw_to_clk(hw);
struct clk_divider *divider = to_clk_divider(hw);
- unsigned int value;
+ int value;
u32 val;
if (divider->flags & CLK_DIVIDER_READ_ONLY)
@@ -322,6 +322,8 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
value = divider_get_val(rate, parent_rate, divider->table,
divider->width, divider->flags);
+ if (value < 0)
+ return value;
val = readl(divider->reg);
val &= ~(clk_div_mask(divider->width) << divider->shift);
--
2.47.1
next prev parent reply other threads:[~2025-01-07 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 14:37 [PATCH v2 0/6] Initial support for Allwinner A64 SoC Jules Maselbas
2025-01-07 14:37 ` Jules Maselbas [this message]
2025-01-08 14:20 ` [PATCH v2 1/6] clk: divider: add error code propagation Ahmad Fatoum
2025-01-07 14:37 ` [PATCH v2 2/6] clk: Add clock driver for sun50i-a64 Jules Maselbas
2025-01-07 14:37 ` [PATCH v2 3/6] pinctrl: Add sun50i-a64 pinctrl driver Jules Maselbas
2025-01-07 14:37 ` [PATCH v2 4/6] mci: Add sunxi-mmc driver Jules Maselbas
2025-01-07 14:37 ` [PATCH v2 5/6] ARM: sunxi: Introduce mach-sunxi Jules Maselbas
2025-01-07 14:37 ` [PATCH v2 6/6] Documentation: sunxi: Add some documentation Jules Maselbas
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=20250107143740.16903-2-jmaselbas@zdiv.net \
--to=jmaselbas@zdiv.net \
--cc=barebox@lists.infradead.org \
/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