Skip to content

Commit 587dd44

Browse files
committed
clk: sprd: composite: Simplify determine_rate implementation
The sprd_div_helper_round_rate() function calls divider_round_rate() which calls divider_round_rate_parent() which calls divider_determine_rate(). This call chain converts back and forth from the rate request structure to make a determine_rate clk_op fit with a round_rate clk_op. Simplify the code here by directly calling divider_determine_rate() instead. This fixes a smatch warning where an unsigned long is compared to less than zero, which is impossible. This makes sprd_div_helper_round_rate() unnecessary as well so simply remove it and fold it into the only caller left. Reported-by: Harshit Mogalapalli <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Cc: Maxime Ripard <[email protected]> Fixes: 302d2f8 ("clk: sprd: composite: Switch to determine_rate") Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Maxime Ripard <[email protected]>
1 parent 3e253b2 commit 587dd44

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

drivers/clk/sprd/composite.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,8 @@ static int sprd_comp_determine_rate(struct clk_hw *hw,
1313
struct clk_rate_request *req)
1414
{
1515
struct sprd_comp *cc = hw_to_sprd_comp(hw);
16-
unsigned long rate;
1716

18-
rate = sprd_div_helper_round_rate(&cc->common, &cc->div,
19-
req->rate, &req->best_parent_rate);
20-
if (rate < 0)
21-
return rate;
22-
23-
req->rate = rate;
24-
return 0;
17+
return divider_determine_rate(hw, req, NULL, cc->div.width, 0);
2518
}
2619

2720
static unsigned long sprd_comp_recalc_rate(struct clk_hw *hw,

drivers/clk/sprd/div.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,13 @@
99

1010
#include "div.h"
1111

12-
long sprd_div_helper_round_rate(struct sprd_clk_common *common,
13-
const struct sprd_div_internal *div,
14-
unsigned long rate,
15-
unsigned long *parent_rate)
16-
{
17-
return divider_round_rate(&common->hw, rate, parent_rate,
18-
NULL, div->width, 0);
19-
}
20-
EXPORT_SYMBOL_GPL(sprd_div_helper_round_rate);
21-
2212
static long sprd_div_round_rate(struct clk_hw *hw, unsigned long rate,
2313
unsigned long *parent_rate)
2414
{
2515
struct sprd_div *cd = hw_to_sprd_div(hw);
2616

27-
return sprd_div_helper_round_rate(&cd->common, &cd->div,
28-
rate, parent_rate);
17+
return divider_round_rate(&cd->common.hw, rate, parent_rate, NULL,
18+
cd->div.width, 0);
2919
}
3020

3121
unsigned long sprd_div_helper_recalc_rate(struct sprd_clk_common *common,

drivers/clk/sprd/div.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ static inline struct sprd_div *hw_to_sprd_div(const struct clk_hw *hw)
6464
return container_of(common, struct sprd_div, common);
6565
}
6666

67-
long sprd_div_helper_round_rate(struct sprd_clk_common *common,
68-
const struct sprd_div_internal *div,
69-
unsigned long rate,
70-
unsigned long *parent_rate);
71-
7267
unsigned long sprd_div_helper_recalc_rate(struct sprd_clk_common *common,
7368
const struct sprd_div_internal *div,
7469
unsigned long parent_rate);

0 commit comments

Comments
 (0)