Commit 639baa3c authored by Brian Masney's avatar Brian Masney
Browse files

clk: st: clkgen-pll: 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.

Note that prior to running the Coccinelle:

- round_rate_stm_pll4600c28() was renamed to stm_pll4600c28_round_rate()
- round_rate_stm_pll3200c32() was renamed to stm_pll3200c32_round_rate()

Signed-off-by: default avatarBrian Masney <bmasney@redhat.com>
parent 78d4c18e
Loading
Loading
Loading
Loading
+22 −16
Original line number Diff line number Diff line
@@ -395,25 +395,28 @@ static unsigned long recalc_stm_pll3200c32(struct clk_hw *hw,
	return rate;
}

static long round_rate_stm_pll3200c32(struct clk_hw *hw, unsigned long rate,
		unsigned long *prate)
static int stm_pll3200c32_determine_rate(struct clk_hw *hw,
					 struct clk_rate_request *req)
{
	struct stm_pll params;

	if (!clk_pll3200c32_get_params(*prate, rate, &params))
		clk_pll3200c32_get_rate(*prate, &params, &rate);
	if (!clk_pll3200c32_get_params(req->best_parent_rate, req->rate, &params))
		clk_pll3200c32_get_rate(req->best_parent_rate, &params,
					&req->rate);
	else {
		pr_debug("%s: %s rate %ld Invalid\n", __func__,
			 __clk_get_name(hw->clk), rate);
			 __clk_get_name(hw->clk), req->rate);
		req->rate = 0;

		return 0;
	}

	pr_debug("%s: %s new rate %ld [ndiv=%u] [idf=%u]\n",
		 __func__, __clk_get_name(hw->clk),
		 rate, (unsigned int)params.ndiv,
		 req->rate, (unsigned int)params.ndiv,
		 (unsigned int)params.idf);

	return rate;
	return 0;
}

static int set_rate_stm_pll3200c32(struct clk_hw *hw, unsigned long rate,
@@ -549,25 +552,28 @@ static unsigned long recalc_stm_pll4600c28(struct clk_hw *hw,
	return rate;
}

static long round_rate_stm_pll4600c28(struct clk_hw *hw, unsigned long rate,
				      unsigned long *prate)
static int stm_pll4600c28_determine_rate(struct clk_hw *hw,
					 struct clk_rate_request *req)
{
	struct stm_pll params;

	if (!clk_pll4600c28_get_params(*prate, rate, &params)) {
		clk_pll4600c28_get_rate(*prate, &params, &rate);
	if (!clk_pll4600c28_get_params(req->best_parent_rate, req->rate, &params)) {
		clk_pll4600c28_get_rate(req->best_parent_rate, &params,
					&req->rate);
	} else {
		pr_debug("%s: %s rate %ld Invalid\n", __func__,
			 __clk_get_name(hw->clk), rate);
			 __clk_get_name(hw->clk), req->rate);
		req->rate = 0;

		return 0;
	}

	pr_debug("%s: %s new rate %ld [ndiv=%u] [idf=%u]\n",
		 __func__, __clk_get_name(hw->clk),
		 rate, (unsigned int)params.ndiv,
		 req->rate, (unsigned int)params.ndiv,
		 (unsigned int)params.idf);

	return rate;
	return 0;
}

static int set_rate_stm_pll4600c28(struct clk_hw *hw, unsigned long rate,
@@ -628,7 +634,7 @@ static const struct clk_ops stm_pll3200c32_a9_ops = {
	.disable	= clkgen_pll_disable,
	.is_enabled	= clkgen_pll_is_enabled,
	.recalc_rate	= recalc_stm_pll3200c32,
	.round_rate	= round_rate_stm_pll3200c32,
	.determine_rate = stm_pll3200c32_determine_rate,
	.set_rate	= set_rate_stm_pll3200c32,
};

@@ -637,7 +643,7 @@ static const struct clk_ops stm_pll4600c28_ops = {
	.disable	= clkgen_pll_disable,
	.is_enabled	= clkgen_pll_is_enabled,
	.recalc_rate	= recalc_stm_pll4600c28,
	.round_rate	= round_rate_stm_pll4600c28,
	.determine_rate = stm_pll4600c28_determine_rate,
	.set_rate	= set_rate_stm_pll4600c28,
};