diff options
| -rw-r--r-- | drivers/clk/clkdev.c | 5 | ||||
| -rw-r--r-- | drivers/clk/sunxi-ng/ccu_nkmp.c | 24 | ||||
| -rw-r--r-- | include/linux/clk.h | 16 |
3 files changed, 40 insertions, 5 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 8c4435c53f09..6e787cc9e5b9 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
| @@ -46,6 +46,8 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) | |||
| 46 | if (con_id) | 46 | if (con_id) |
| 47 | best_possible += 1; | 47 | best_possible += 1; |
| 48 | 48 | ||
| 49 | lockdep_assert_held(&clocks_mutex); | ||
| 50 | |||
| 49 | list_for_each_entry(p, &clocks, node) { | 51 | list_for_each_entry(p, &clocks, node) { |
| 50 | match = 0; | 52 | match = 0; |
| 51 | if (p->dev_id) { | 53 | if (p->dev_id) { |
| @@ -402,7 +404,10 @@ void devm_clk_release_clkdev(struct device *dev, const char *con_id, | |||
| 402 | struct clk_lookup *cl; | 404 | struct clk_lookup *cl; |
| 403 | int rval; | 405 | int rval; |
| 404 | 406 | ||
| 407 | mutex_lock(&clocks_mutex); | ||
| 405 | cl = clk_find(dev_id, con_id); | 408 | cl = clk_find(dev_id, con_id); |
| 409 | mutex_unlock(&clocks_mutex); | ||
| 410 | |||
| 406 | WARN_ON(!cl); | 411 | WARN_ON(!cl); |
| 407 | rval = devres_release(dev, devm_clkdev_release, | 412 | rval = devres_release(dev, devm_clkdev_release, |
| 408 | devm_clk_match_clkdev, cl); | 413 | devm_clk_match_clkdev, cl); |
diff --git a/drivers/clk/sunxi-ng/ccu_nkmp.c b/drivers/clk/sunxi-ng/ccu_nkmp.c index 9b49adb20d07..cbcdf664f336 100644 --- a/drivers/clk/sunxi-ng/ccu_nkmp.c +++ b/drivers/clk/sunxi-ng/ccu_nkmp.c | |||
| @@ -167,7 +167,7 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate, | |||
| 167 | unsigned long parent_rate) | 167 | unsigned long parent_rate) |
| 168 | { | 168 | { |
| 169 | struct ccu_nkmp *nkmp = hw_to_ccu_nkmp(hw); | 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 | struct _ccu_nkmp _nkmp; | 171 | struct _ccu_nkmp _nkmp; |
| 172 | unsigned long flags; | 172 | unsigned long flags; |
| 173 | u32 reg; | 173 | u32 reg; |
| @@ -186,10 +186,24 @@ static int ccu_nkmp_set_rate(struct clk_hw *hw, unsigned long rate, | |||
| 186 | 186 | ||
| 187 | ccu_nkmp_find_best(parent_rate, rate, &_nkmp); | 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); | 189 | /* |
| 190 | k_mask = GENMASK(nkmp->k.width + nkmp->k.shift - 1, nkmp->k.shift); | 190 | * If width is 0, GENMASK() macro may not generate expected mask (0) |
| 191 | m_mask = GENMASK(nkmp->m.width + nkmp->m.shift - 1, nkmp->m.shift); | 191 | * as it falls under undefined behaviour by C standard due to shifts |
| 192 | p_mask = GENMASK(nkmp->p.width + nkmp->p.shift - 1, nkmp->p.shift); | 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 | spin_lock_irqsave(nkmp->common.lock, flags); | 208 | spin_lock_irqsave(nkmp->common.lock, flags); |
| 195 | 209 | ||
diff --git a/include/linux/clk.h b/include/linux/clk.h index d8bc1a856b39..f689fc58d7be 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
| @@ -811,6 +811,22 @@ static inline bool clk_has_parent(struct clk *clk, struct clk *parent) | |||
| 811 | return true; | 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 | static inline int clk_set_parent(struct clk *clk, struct clk *parent) | 830 | static inline int clk_set_parent(struct clk *clk, struct clk *parent) |
| 815 | { | 831 | { |
| 816 | return 0; | 832 | return 0; |
