]> git.baikalelectronics.ru Git - kernel.git/commit
clk: ti: divider: convert to use min,max,mask instead of width
authorTero Kristo <t-kristo@ti.com>
Wed, 2 Oct 2019 12:06:10 +0000 (15:06 +0300)
committerTero Kristo <t-kristo@ti.com>
Thu, 31 Oct 2019 13:32:36 +0000 (15:32 +0200)
commitf3c0132a02aee449819e20192a238face43893e7
tree2a85ca80ee3c32c01eacb1aee7f6a9acf73f750f
parente24c8cb6a30b8b6b9efb57c60d0f8be7ddcef95e
clk: ti: divider: convert to use min,max,mask instead of width

The existing width field used to check divider validity does not provide
enough protection against bad values. For example, if max divider value
is 4, the smallest all-1 bitmask that can hold this value is 7, which
allows values higher than 4 to be used. This typically causes
unpredictable results with hardware. So far this issue hasn't been
noticed as most of the dividers actually have maximum values which fit
the whole bitfield, but there are certain clocks for which this is a
problem, like dpll4_m4 divider on omap3 devices.

Thus, convert the whole validity logic to use min,max and mask values
for determining if a specific divider is valid or not. This prevents
the odd cases where bad value would otherwise be written to a divider
config register.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Tested-by: Adam Ford <aford173@gmail.com>
drivers/clk/ti/clock.h
drivers/clk/ti/divider.c