Commit 89d079dc authored by Jerome Brunet's avatar Jerome Brunet Committed by Stephen Boyd
Browse files

clk: let init callback return an error code



If the init callback is allowed to request resources, it needs a return
value to report the outcome of such a request.

Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://lkml.kernel.org/r/20190924123954.31561-3-jbrunet@baylibre.com


Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Acked-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent f6fa75ca
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -3316,16 +3316,21 @@ static int __clk_core_init(struct clk_core *core)
	 * optional platform-specific magic
	 *
	 * The .init callback is not used by any of the basic clock types, but
	 * exists for weird hardware that must perform initialization magic.
	 * Please consider other ways of solving initialization problems before
	 * using this callback, as its use is discouraged.
	 * exists for weird hardware that must perform initialization magic for
	 * CCF to get an accurate view of clock for any other callbacks. It may
	 * also be used needs to perform dynamic allocations. Such allocation
	 * must be freed in the terminate() callback.
	 * This callback shall not be used to initialize the parameters state,
	 * such as rate, parent, etc ...
	 *
	 * If it exist, this callback should called before any other callback of
	 * the clock
	 */
	if (core->ops->init)
		core->ops->init(core->hw);

	if (core->ops->init) {
		ret = core->ops->init(core->hw);
		if (ret)
			goto out;
	}

	core->parent = __clk_init_parent(core);

+3 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ static int mpll_set_rate(struct clk_hw *hw,
	return 0;
}

static void mpll_init(struct clk_hw *hw)
static int mpll_init(struct clk_hw *hw)
{
	struct clk_regmap *clk = to_clk_regmap(hw);
	struct meson_clk_mpll_data *mpll = meson_clk_mpll_data(clk);
@@ -151,6 +151,8 @@ static void mpll_init(struct clk_hw *hw)
	/* Set the magic misc bit if required */
	if (MESON_PARM_APPLICABLE(&mpll->misc))
		meson_parm_write(clk->map, &mpll->misc, 1);

	return 0;
}

const struct clk_ops meson_clk_mpll_ro_ops = {
+3 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ meson_clk_triphase_data(struct clk_regmap *clk)
	return (struct meson_clk_triphase_data *)clk->data;
}

static void meson_clk_triphase_sync(struct clk_hw *hw)
static int meson_clk_triphase_sync(struct clk_hw *hw)
{
	struct clk_regmap *clk = to_clk_regmap(hw);
	struct meson_clk_triphase_data *tph = meson_clk_triphase_data(clk);
@@ -88,6 +88,8 @@ static void meson_clk_triphase_sync(struct clk_hw *hw)
	val = meson_parm_read(clk->map, &tph->ph0);
	meson_parm_write(clk->map, &tph->ph1, val);
	meson_parm_write(clk->map, &tph->ph2, val);

	return 0;
}

static int meson_clk_triphase_get_phase(struct clk_hw *hw)
+3 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ static int meson_clk_pll_wait_lock(struct clk_hw *hw)
	return -ETIMEDOUT;
}

static void meson_clk_pll_init(struct clk_hw *hw)
static int meson_clk_pll_init(struct clk_hw *hw)
{
	struct clk_regmap *clk = to_clk_regmap(hw);
	struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
@@ -288,6 +288,8 @@ static void meson_clk_pll_init(struct clk_hw *hw)
				       pll->init_count);
		meson_parm_write(clk->map, &pll->rst, 0);
	}

	return 0;
}

static int meson_clk_pll_is_enabled(struct clk_hw *hw)
+3 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ static int sclk_div_is_enabled(struct clk_hw *hw)
	return 0;
}

static void sclk_div_init(struct clk_hw *hw)
static int sclk_div_init(struct clk_hw *hw)
{
	struct clk_regmap *clk = to_clk_regmap(hw);
	struct meson_sclk_div_data *sclk = meson_sclk_div_data(clk);
@@ -231,6 +231,8 @@ static void sclk_div_init(struct clk_hw *hw)
		sclk->cached_div = val + 1;

	sclk_div_get_duty_cycle(hw, &sclk->cached_duty);

	return 0;
}

const struct clk_ops meson_sclk_div_ops = {
Loading