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

clk: qcom: clk-hfpll: use poll_timeout macro

Use regmap_read_poll_timeout macro instead of do-while structure to tidy
things up. Also set a timeout to prevent any sort of system stall.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220430054458.31321-2-ansuelsmth@gmail.com

authored by

Ansuel Smith and committed by
Bjorn Andersson
fcfbfe37 255a47e7

+9 -6
+9 -6
drivers/clk/qcom/clk-hfpll.c
··· 72 72 regmap_update_bits(regmap, hd->mode_reg, PLL_RESET_N, PLL_RESET_N); 73 73 74 74 /* Wait for PLL to lock. */ 75 - if (hd->status_reg) { 76 - do { 77 - regmap_read(regmap, hd->status_reg, &val); 78 - } while (!(val & BIT(hd->lock_bit))); 79 - } else { 75 + if (hd->status_reg) 76 + /* 77 + * Busy wait. Should never timeout, we add a timeout to 78 + * prevent any sort of stall. 79 + */ 80 + regmap_read_poll_timeout(regmap, hd->status_reg, val, 81 + !(val & BIT(hd->lock_bit)), 0, 82 + 100 * USEC_PER_MSEC); 83 + else 80 84 udelay(60); 81 - } 82 85 83 86 /* Enable PLL output. */ 84 87 regmap_update_bits(regmap, hd->mode_reg, PLL_OUTCTRL, PLL_OUTCTRL);