Commit a076fe9f authored by Brian Masney's avatar Brian Masney Committed by Raphael Gallais-Pou
Browse files

drm/sun4i/sun4i_tcon_dclk: convert from round_rate() to determine_rate()



The round_rate() clk ops is deprecated, so migrate this driver from
round_rate() to determine_rate() using the Coccinelle semantic patch
on the cover letter of this series.

Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Signed-off-by: default avatarBrian Masney <bmasney@redhat.com>
Link: https://lore.kernel.org/r/20250811-drm-clk-round-rate-v2-9-4a91ccf239cf@redhat.com


Signed-off-by: default avatarRaphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
parent 5c04f481
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -67,8 +67,8 @@ static unsigned long sun4i_dclk_recalc_rate(struct clk_hw *hw,
	return parent_rate / val;
}

static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
				  unsigned long *parent_rate)
static int sun4i_dclk_determine_rate(struct clk_hw *hw,
				     struct clk_rate_request *req)
{
	struct sun4i_dclk *dclk = hw_to_dclk(hw);
	struct sun4i_tcon *tcon = dclk->tcon;
@@ -77,7 +77,7 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
	int i;

	for (i = tcon->dclk_min_div; i <= tcon->dclk_max_div; i++) {
		u64 ideal = (u64)rate * i;
		u64 ideal = (u64)req->rate * i;
		unsigned long rounded;

		/*
@@ -99,17 +99,19 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
			goto out;
		}

		if (abs(rate - rounded / i) <
		    abs(rate - best_parent / best_div)) {
		if (abs(req->rate - rounded / i) <
		    abs(req->rate - best_parent / best_div)) {
			best_parent = rounded;
			best_div = i;
		}
	}

out:
	*parent_rate = best_parent;
	req->best_parent_rate = best_parent;

	return best_parent / best_div;
	req->rate = best_parent / best_div;

	return 0;
}

static int sun4i_dclk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -155,7 +157,7 @@ static const struct clk_ops sun4i_dclk_ops = {
	.is_enabled	= sun4i_dclk_is_enabled,

	.recalc_rate	= sun4i_dclk_recalc_rate,
	.round_rate	= sun4i_dclk_round_rate,
	.determine_rate = sun4i_dclk_determine_rate,
	.set_rate	= sun4i_dclk_set_rate,

	.get_phase	= sun4i_dclk_get_phase,