mirror of https://gitee.com/openkylin/linux.git
clk: sunxi-ng: nkmp: Explain why zero width check is needed
Add an explanation why zero width check is needed when generating factor mask using GENMASK() macro. Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
This commit is contained in:
parent
2abc330c51
commit
1054e4dd1c
|
@ -186,6 +186,12 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||||
|
|
||||||
ccu_nkmp_find_best(parent_rate, rate, &_nkmp);
|
ccu_nkmp_find_best(parent_rate, rate, &_nkmp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If width is 0, GENMASK() macro may not generate expected mask (0)
|
||||||
|
* as it falls under undefined behaviour by C standard due to shifts
|
||||||
|
* which are equal or greater than width of left operand. This can
|
||||||
|
* be easily avoided by explicitly checking if width is 0.
|
||||||
|
*/
|
||||||
if (nkmp->n.width)
|
if (nkmp->n.width)
|
||||||
n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1,
|
n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1,
|
||||||
nkmp->n.shift);
|
nkmp->n.shift);
|
||||||
|
|
Loading…
Reference in New Issue