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.

clk: gate: Add devm_clk_hw_register_gate()

Add devm_clk_hw_register_gate() - devres-managed version of
clk_hw_register_gate()

Suggested-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20211103085102.1656081-2-horatiu.vultur@microchip.com

authored by

Horatiu Vultur and committed by
Nicolas Ferre
815f0e73 54104ee0

+58
+35
drivers/clk/clk-gate.c
··· 7 7 */ 8 8 9 9 #include <linux/clk-provider.h> 10 + #include <linux/device.h> 10 11 #include <linux/module.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/io.h> ··· 223 222 kfree(gate); 224 223 } 225 224 EXPORT_SYMBOL_GPL(clk_hw_unregister_gate); 225 + 226 + static void devm_clk_hw_release_gate(struct device *dev, void *res) 227 + { 228 + clk_hw_unregister_gate(*(struct clk_hw **)res); 229 + } 230 + 231 + struct clk_hw *__devm_clk_hw_register_gate(struct device *dev, 232 + struct device_node *np, const char *name, 233 + const char *parent_name, const struct clk_hw *parent_hw, 234 + const struct clk_parent_data *parent_data, 235 + unsigned long flags, 236 + void __iomem *reg, u8 bit_idx, 237 + u8 clk_gate_flags, spinlock_t *lock) 238 + { 239 + struct clk_hw **ptr, *hw; 240 + 241 + ptr = devres_alloc(devm_clk_hw_release_gate, sizeof(*ptr), GFP_KERNEL); 242 + if (!ptr) 243 + return ERR_PTR(-ENOMEM); 244 + 245 + hw = __clk_hw_register_gate(dev, np, name, parent_name, parent_hw, 246 + parent_data, flags, reg, bit_idx, 247 + clk_gate_flags, lock); 248 + 249 + if (!IS_ERR(hw)) { 250 + *ptr = hw; 251 + devres_add(dev, ptr); 252 + } else { 253 + devres_free(ptr); 254 + } 255 + 256 + return hw; 257 + } 258 + EXPORT_SYMBOL_GPL(__devm_clk_hw_register_gate);
+23
include/linux/clk-provider.h
··· 490 490 unsigned long flags, 491 491 void __iomem *reg, u8 bit_idx, 492 492 u8 clk_gate_flags, spinlock_t *lock); 493 + struct clk_hw *__devm_clk_hw_register_gate(struct device *dev, 494 + struct device_node *np, const char *name, 495 + const char *parent_name, const struct clk_hw *parent_hw, 496 + const struct clk_parent_data *parent_data, 497 + unsigned long flags, 498 + void __iomem *reg, u8 bit_idx, 499 + u8 clk_gate_flags, spinlock_t *lock); 493 500 struct clk *clk_register_gate(struct device *dev, const char *name, 494 501 const char *parent_name, unsigned long flags, 495 502 void __iomem *reg, u8 bit_idx, ··· 550 543 bit_idx, clk_gate_flags, lock) \ 551 544 __clk_hw_register_gate((dev), NULL, (name), NULL, NULL, (parent_data), \ 552 545 (flags), (reg), (bit_idx), \ 546 + (clk_gate_flags), (lock)) 547 + /** 548 + * devm_clk_hw_register_gate - register a gate clock with the clock framework 549 + * @dev: device that is registering this clock 550 + * @name: name of this clock 551 + * @parent_name: name of this clock's parent 552 + * @flags: framework-specific flags for this clock 553 + * @reg: register address to control gating of this clock 554 + * @bit_idx: which bit in the register controls gating of this clock 555 + * @clk_gate_flags: gate-specific flags for this clock 556 + * @lock: shared register lock for this clock 557 + */ 558 + #define devm_clk_hw_register_gate(dev, name, parent_name, flags, reg, bit_idx,\ 559 + clk_gate_flags, lock) \ 560 + __devm_clk_hw_register_gate((dev), NULL, (name), (parent_name), NULL, \ 561 + NULL, (flags), (reg), (bit_idx), \ 553 562 (clk_gate_flags), (lock)) 554 563 void clk_unregister_gate(struct clk *clk); 555 564 void clk_hw_unregister_gate(struct clk_hw *hw);