summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-versaclock5.c
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2018-12-15 01:55:19 +0100
committerStephen Boyd <sboyd@kernel.org>2019-01-09 19:53:58 +0100
commit2137a109a5e39c2bdccfffe65230ed3fadbaac0e (patch)
tree46f69d35292d3d4214f9c7643b85e77cedad1bc1 /drivers/clk/clk-versaclock5.c
parentclk: sysfs: fix invalid JSON in clk_dump (diff)
downloadlinux-2137a109a5e39c2bdccfffe65230ed3fadbaac0e.tar.xz
linux-2137a109a5e39c2bdccfffe65230ed3fadbaac0e.zip
clk: vc5: Abort clock configuration without upstream clock
In case the upstream clock are not set, which can happen in case the VC5 has no valid upstream clock, the $src variable is used uninited by regmap_update_bits(). Check for this condition and return -EINVAL in such case. Note that in case the VC5 has no valid upstream clock, the VC5 can not operate correctly. That is a hardware property of the VC5. The internal oscilator present in some VC5 models is also considered upstream clock. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Alexey Firago <alexey_firago@mentor.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Stephen Boyd <sboyd@kernel.org> Cc: linux-renesas-soc@vger.kernel.org [sboyd@kernel.org: Added comment about probe preventing this from happening in the first place] Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/clk-versaclock5.c')
-rw-r--r--drivers/clk/clk-versaclock5.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 5b393e711e94..7d16ab0784ec 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -262,8 +262,10 @@ static int vc5_mux_set_parent(struct clk_hw *hw, u8 index)
if (vc5->clk_mux_ins == VC5_MUX_IN_XIN)
src = VC5_PRIM_SRC_SHDN_EN_XTAL;
- if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN)
+ else if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN)
src = VC5_PRIM_SRC_SHDN_EN_CLKIN;
+ else /* Invalid; should have been caught by vc5_probe() */
+ return -EINVAL;
}
return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src);