mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
Allwinner clocks fixes for 5.1
Some fixes for odd cases of the NKMP clocks. -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXLmssgAKCRDj7w1vZxhR xbj5AP4qPepKIejy736mTwQOEEL0Phi1tFrezNJZi3GE90sfkQD/WX9Tegx6YfSh BoMR2L3fyxXbzgv0aEW67LjhqITKXgY= =EsQv -----END PGP SIGNATURE----- Merge tag 'clk-fixes-for-5.1' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-fixes Pull Allwinner clk fixes from Maxime Ripard: - Some fixes for odd cases of the NKMP clocks * tag 'clk-fixes-for-5.1' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux: clk: sunxi-ng: nkmp: Explain why zero width check is needed clk: sunxi-ng: nkmp: Avoid GENMASK(-1, 0)
This commit is contained in:
commit
ac71e68746
@ -167,7 +167,7 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
unsigned long parent_rate)
|
||||
{
|
||||
struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw);
|
||||
u32 n_mask, k_mask, m_mask, p_mask;
|
||||
u32 n_mask = 0, k_mask = 0, m_mask = 0, p_mask = 0;
|
||||
struct _ccu_nkmp _nkmp;
|
||||
unsigned long flags;
|
||||
u32 reg;
|
||||
@ -186,10 +186,24 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
|
||||
ccu_nkmp_find_best(parent_rate, rate, &_nkmp);
|
||||
|
||||
n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1, nkmp->n.shift);
|
||||
k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1, nkmp->k.shift);
|
||||
m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1, nkmp->m.shift);
|
||||
p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1, nkmp->p.shift);
|
||||
/*
|
||||
* 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)
|
||||
n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1,
|
||||
nkmp->n.shift);
|
||||
if (nkmp->k.width)
|
||||
k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1,
|
||||
nkmp->k.shift);
|
||||
if (nkmp->m.width)
|
||||
m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1,
|
||||
nkmp->m.shift);
|
||||
if (nkmp->p.width)
|
||||
p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1,
|
||||
nkmp->p.shift);
|
||||
|
||||
spin_lock_irqsave(nkmp->common.lock, flags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user