Skip to content

Commit 6a7ace2

Browse files
rkasirajan85thierryreding
authored andcommitted
clk: tegra: Replace .round_rate() with .determine_rate()
Replace the .round_rate() callback with .determine_rate() which can consider max_rate imposed by clk_set_max_rate() while rounding the clock rate. Note that if the .determine_rate() callback is defined it will be called instead of the .round_rate() callback when calling clk_round_rate(). By using .determine_rate(), the maximum rate returned when calling clk_round_rate() is now limited by the current max_rate. Signed-off-by: Rajkumar Kasirajan <rkasirajan@nvidia.com> [jonathanh@nvidia.com: checkpatch fixes and commit message update] Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent 2db12b1 commit 6a7ace2

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

drivers/clk/tegra/clk-bpmp.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,18 @@ static unsigned long tegra_bpmp_clk_recalc_rate(struct clk_hw *hw,
164164
return response.rate;
165165
}
166166

167-
static long tegra_bpmp_clk_round_rate(struct clk_hw *hw, unsigned long rate,
168-
unsigned long *parent_rate)
167+
static int tegra_bpmp_clk_determine_rate(struct clk_hw *hw,
168+
struct clk_rate_request *rate_req)
169169
{
170170
struct tegra_bpmp_clk *clk = to_tegra_bpmp_clk(hw);
171171
struct cmd_clk_round_rate_response response;
172172
struct cmd_clk_round_rate_request request;
173173
struct tegra_bpmp_clk_message msg;
174+
unsigned long rate;
174175
int err;
175176

177+
rate = min(max(rate_req->rate, rate_req->min_rate), rate_req->max_rate);
178+
176179
memset(&request, 0, sizeof(request));
177180
request.rate = min_t(u64, rate, S64_MAX);
178181

@@ -188,7 +191,9 @@ static long tegra_bpmp_clk_round_rate(struct clk_hw *hw, unsigned long rate,
188191
if (err < 0)
189192
return err;
190193

191-
return response.rate;
194+
rate_req->rate = (unsigned long)response.rate;
195+
196+
return 0;
192197
}
193198

194199
static int tegra_bpmp_clk_set_parent(struct clk_hw *hw, u8 index)
@@ -290,7 +295,7 @@ static const struct clk_ops tegra_bpmp_clk_rate_ops = {
290295
.unprepare = tegra_bpmp_clk_unprepare,
291296
.is_prepared = tegra_bpmp_clk_is_prepared,
292297
.recalc_rate = tegra_bpmp_clk_recalc_rate,
293-
.round_rate = tegra_bpmp_clk_round_rate,
298+
.determine_rate = tegra_bpmp_clk_determine_rate,
294299
.set_rate = tegra_bpmp_clk_set_rate,
295300
};
296301

@@ -299,7 +304,7 @@ static const struct clk_ops tegra_bpmp_clk_mux_rate_ops = {
299304
.unprepare = tegra_bpmp_clk_unprepare,
300305
.is_prepared = tegra_bpmp_clk_is_prepared,
301306
.recalc_rate = tegra_bpmp_clk_recalc_rate,
302-
.round_rate = tegra_bpmp_clk_round_rate,
307+
.determine_rate = tegra_bpmp_clk_determine_rate,
303308
.set_parent = tegra_bpmp_clk_set_parent,
304309
.get_parent = tegra_bpmp_clk_get_parent,
305310
.set_rate = tegra_bpmp_clk_set_rate,

0 commit comments

Comments
 (0)