clk: qcom: clk-alpha-pll: Fix pll post div mask when width is not set
authorBarnabás Czémán <barnabas.czeman@mainlining.org>
Sun, 6 Oct 2024 20:51:58 +0000 (22:51 +0200)
committerBjorn Andersson <andersson@kernel.org>
Mon, 14 Oct 2024 23:51:29 +0000 (18:51 -0500)
Many qcom clock drivers do not have .width set. In that case value of
(p)->width - 1 will be negative which breaks clock tree. Fix this
by checking if width is zero, and pass 3 to GENMASK if that's the case.

Fixes: 1c3541145cbf ("clk: qcom: support for 2 bit PLL post divider")
Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Christopher Obbard <christopher.obbard@linaro.org>
Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
Link: https://lore.kernel.org/r/20241006-fix-postdiv-mask-v3-1-160354980433@mainlining.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/clk/qcom/clk-alpha-pll.c

index f9105443d7dbb104e3cb091e59f43df25999f8b3..be9bee6ab65f6e08d5ae764d94a92e395e227fbc 100644 (file)
@@ -40,7 +40,7 @@
 
 #define PLL_USER_CTL(p)                ((p)->offset + (p)->regs[PLL_OFF_USER_CTL])
 # define PLL_POST_DIV_SHIFT    8
-# define PLL_POST_DIV_MASK(p)  GENMASK((p)->width - 1, 0)
+# define PLL_POST_DIV_MASK(p)  GENMASK((p)->width ? (p)->width - 1 : 3, 0)
 # define PLL_ALPHA_MSB         BIT(15)
 # define PLL_ALPHA_EN          BIT(24)
 # define PLL_ALPHA_MODE                BIT(25)