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 git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
"One clk driver fix and two clk framework fixes:

- Fix an OOB access when devm_get_clk_from_child() is used and
devm_clk_release() casts the void pointer to the wrong type

- Move clk_rate_exclusive_{get,put}() within the correct ifdefs in
clk.h so that the stubs are used when CONFIG_COMMON_CLK=n

- Register the proper clk provider function depending on the value of
#clock-cells in the TI keystone driver"

* tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
clk: Fix slab-out-of-bounds error in devm_clk_release()
clk: Fix undefined reference to `clk_rate_exclusive_{get,put}'
clk: keystone: syscon-clk: Fix audio refclk

+51 -48
+7 -6
drivers/clk/clk-devres.c
··· 205 205 struct clk *devm_get_clk_from_child(struct device *dev, 206 206 struct device_node *np, const char *con_id) 207 207 { 208 - struct clk **ptr, *clk; 208 + struct devm_clk_state *state; 209 + struct clk *clk; 209 210 210 - ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); 211 - if (!ptr) 211 + state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL); 212 + if (!state) 212 213 return ERR_PTR(-ENOMEM); 213 214 214 215 clk = of_clk_get_by_name(np, con_id); 215 216 if (!IS_ERR(clk)) { 216 - *ptr = clk; 217 - devres_add(dev, ptr); 217 + state->clk = clk; 218 + devres_add(dev, state); 218 219 } else { 219 - devres_free(ptr); 220 + devres_free(state); 220 221 } 221 222 222 223 return clk;
+4 -2
drivers/clk/keystone/syscon-clk.c
··· 151 151 data[i].name); 152 152 } 153 153 154 - return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, 155 - hw_data); 154 + if (num_clks == 1) 155 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, 156 + hw_data->hws[0]); 157 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, hw_data); 156 158 } 157 159 158 160 #define TI_SYSCON_CLK_GATE(_name, _offset, _bit_idx) \
+40 -40
include/linux/clk.h
··· 183 183 */ 184 184 bool clk_is_match(const struct clk *p, const struct clk *q); 185 185 186 + /** 187 + * clk_rate_exclusive_get - get exclusivity over the rate control of a 188 + * producer 189 + * @clk: clock source 190 + * 191 + * This function allows drivers to get exclusive control over the rate of a 192 + * provider. It prevents any other consumer to execute, even indirectly, 193 + * opereation which could alter the rate of the provider or cause glitches 194 + * 195 + * If exlusivity is claimed more than once on clock, even by the same driver, 196 + * the rate effectively gets locked as exclusivity can't be preempted. 197 + * 198 + * Must not be called from within atomic context. 199 + * 200 + * Returns success (0) or negative errno. 201 + */ 202 + int clk_rate_exclusive_get(struct clk *clk); 203 + 204 + /** 205 + * clk_rate_exclusive_put - release exclusivity over the rate control of a 206 + * producer 207 + * @clk: clock source 208 + * 209 + * This function allows drivers to release the exclusivity it previously got 210 + * from clk_rate_exclusive_get() 211 + * 212 + * The caller must balance the number of clk_rate_exclusive_get() and 213 + * clk_rate_exclusive_put() calls. 214 + * 215 + * Must not be called from within atomic context. 216 + */ 217 + void clk_rate_exclusive_put(struct clk *clk); 218 + 186 219 #else 187 220 188 221 static inline int clk_notifier_register(struct clk *clk, ··· 268 235 { 269 236 return p == q; 270 237 } 238 + 239 + static inline int clk_rate_exclusive_get(struct clk *clk) 240 + { 241 + return 0; 242 + } 243 + 244 + static inline void clk_rate_exclusive_put(struct clk *clk) {} 271 245 272 246 #endif 273 247 ··· 623 583 */ 624 584 struct clk *devm_get_clk_from_child(struct device *dev, 625 585 struct device_node *np, const char *con_id); 626 - /** 627 - * clk_rate_exclusive_get - get exclusivity over the rate control of a 628 - * producer 629 - * @clk: clock source 630 - * 631 - * This function allows drivers to get exclusive control over the rate of a 632 - * provider. It prevents any other consumer to execute, even indirectly, 633 - * opereation which could alter the rate of the provider or cause glitches 634 - * 635 - * If exlusivity is claimed more than once on clock, even by the same driver, 636 - * the rate effectively gets locked as exclusivity can't be preempted. 637 - * 638 - * Must not be called from within atomic context. 639 - * 640 - * Returns success (0) or negative errno. 641 - */ 642 - int clk_rate_exclusive_get(struct clk *clk); 643 - 644 - /** 645 - * clk_rate_exclusive_put - release exclusivity over the rate control of a 646 - * producer 647 - * @clk: clock source 648 - * 649 - * This function allows drivers to release the exclusivity it previously got 650 - * from clk_rate_exclusive_get() 651 - * 652 - * The caller must balance the number of clk_rate_exclusive_get() and 653 - * clk_rate_exclusive_put() calls. 654 - * 655 - * Must not be called from within atomic context. 656 - */ 657 - void clk_rate_exclusive_put(struct clk *clk); 658 586 659 587 /** 660 588 * clk_enable - inform the system when the clock source should be running. ··· 981 973 static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {} 982 974 983 975 static inline void devm_clk_put(struct device *dev, struct clk *clk) {} 984 - 985 - 986 - static inline int clk_rate_exclusive_get(struct clk *clk) 987 - { 988 - return 0; 989 - } 990 - 991 - static inline void clk_rate_exclusive_put(struct clk *clk) {} 992 976 993 977 static inline int clk_enable(struct clk *clk) 994 978 {