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.

Merge tag 'clk-fixes-for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
"Two fixes for the NKMP clks on Allwinner SoCs, a locking fix for
clkdev where we forgot to hold a lock while iterating a list that can
change, and finally a build fix that adds some stubs for clk APIs that
are used by devfreq drivers on platforms without the clk APIs"

* tag 'clk-fixes-for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/clk/linux:
clk: Add missing stubs for a few functions
clkdev: Hold clocks_mutex while iterating clocks list
clk: sunxi-ng: nkmp: Explain why zero width check is needed
clk: sunxi-ng: nkmp: Avoid GENMASK(-1, 0)

+40 -5
+5
drivers/clk/clkdev.c
··· 46 46 if (con_id) 47 47 best_possible += 1; 48 48 49 + lockdep_assert_held(&clocks_mutex); 50 + 49 51 list_for_each_entry(p, &clocks, node) { 50 52 match = 0; 51 53 if (p->dev_id) { ··· 404 402 struct clk_lookup *cl; 405 403 int rval; 406 404 405 + mutex_lock(&clocks_mutex); 407 406 cl = clk_find(dev_id, con_id); 407 + mutex_unlock(&clocks_mutex); 408 + 408 409 WARN_ON(!cl); 409 410 rval = devres_release(dev, devm_clkdev_release, 410 411 devm_clk_match_clkdev, cl);
+19 -5
drivers/clk/sunxi-ng/ccu_nkmp.c
··· 167 167 unsigned long parent_rate) 168 168 { 169 169 struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw); 170 - u32 n_mask, k_mask, m_mask, p_mask; 170 + u32 n_mask = 0, k_mask = 0, m_mask = 0, p_mask = 0; 171 171 struct _ccu_nkmp _nkmp; 172 172 unsigned long flags; 173 173 u32 reg; ··· 186 186 187 187 ccu_nkmp_find_best(parent_rate, rate, &_nkmp); 188 188 189 - n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1, nkmp->n.shift); 190 - k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1, nkmp->k.shift); 191 - m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1, nkmp->m.shift); 192 - p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1, nkmp->p.shift); 189 + /* 190 + * If width is 0, GENMASK() macro may not generate expected mask (0) 191 + * as it falls under undefined behaviour by C standard due to shifts 192 + * which are equal or greater than width of left operand. This can 193 + * be easily avoided by explicitly checking if width is 0. 194 + */ 195 + if (nkmp->n.width) 196 + n_mask = GENMASK(nkmp->n.width + nkmp->n.shift - 1, 197 + nkmp->n.shift); 198 + if (nkmp->k.width) 199 + k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1, 200 + nkmp->k.shift); 201 + if (nkmp->m.width) 202 + m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1, 203 + nkmp->m.shift); 204 + if (nkmp->p.width) 205 + p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1, 206 + nkmp->p.shift); 193 207 194 208 spin_lock_irqsave(nkmp->common.lock, flags); 195 209
+16
include/linux/clk.h
··· 811 811 return true; 812 812 } 813 813 814 + static inline int clk_set_rate_range(struct clk *clk, unsigned long min, 815 + unsigned long max) 816 + { 817 + return 0; 818 + } 819 + 820 + static inline int clk_set_min_rate(struct clk *clk, unsigned long rate) 821 + { 822 + return 0; 823 + } 824 + 825 + static inline int clk_set_max_rate(struct clk *clk, unsigned long rate) 826 + { 827 + return 0; 828 + } 829 + 814 830 static inline int clk_set_parent(struct clk *clk, struct clk *parent) 815 831 { 816 832 return 0;