Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clk: imx: get stdout clk count from device tree

Currently the clk_count is specified by API users, but this
parameter is wrongly used, for example, i.MX8M clk driver use 4,
however the uart device tree node only use 2 clock entries. So
let using of_clk_get_parent_count to get the exact clock count.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20230104110032.1220721-3-peng.fan@oss.nxp.com

authored by

Peng Fan and committed by
Abel Vesa
8658f0ac f4419db4

+9 -3
+9 -3
drivers/clk/imx/clk.c
··· 167 167 168 168 void imx_register_uart_clocks(unsigned int clk_count) 169 169 { 170 + unsigned int num __maybe_unused; 171 + 170 172 imx_enabled_uart_clocks = 0; 171 173 172 174 /* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */ ··· 176 174 if (imx_keep_uart_clocks) { 177 175 int i; 178 176 179 - imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); 180 - if (!imx_uart_clocks) 177 + num = of_clk_get_parent_count(of_stdout); 178 + if (!num) 181 179 return; 182 180 183 181 if (!of_stdout) 184 182 return; 185 183 186 - for (i = 0; i < clk_count; i++) { 184 + imx_uart_clocks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL); 185 + if (!imx_uart_clocks) 186 + return; 187 + 188 + for (i = 0; i < num; i++) { 187 189 imx_uart_clocks[imx_enabled_uart_clocks] = of_clk_get(of_stdout, i); 188 190 189 191 /* Stop if there are no more of_stdout references */