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)
Unified · Split
| @@ -46,6 +46,8 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) · 45 unmodified lines | ||
| 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) { |
| @@ -402,7 +404,10 @@ void devm_clk_release_clkdev(struct device *dev, const char *con_id, · 350 unmodified lines | ||
| 402 | 404 | struct clk_lookup *cl; |
| 403 | 405 | int rval; |
| 404 | 406 | |
| 407 | + mutex_lock(&clocks_mutex); | |
| 405 | 408 | cl = clk_find(dev_id, con_id); |
| 409 | + mutex_unlock(&clocks_mutex); | |
| 410 | + | |
| 406 | 411 | WARN_ON(!cl); |
| 407 | 412 | rval = devres_release(dev, devm_clkdev_release, |
| 408 | 413 | devm_clk_match_clkdev, cl); |
| @@ -167,7 +167,7 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate, · 166 unmodified lines | ||
| 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,10 +186,24 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate, · 12 unmodified lines | ||
| 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 | |
| @@ -811,6 +811,22 @@ static inline bool clk_has_parent(struct clk *clk, struct clk *parent) · 810 unmodified lines | ||
| 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; |