Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clkdev: add possibility to get a clock based on the device name

This adds clk_get_sys to get a clock without the associated struct
device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

+26 -2
+9 -2
arch/arm/common/clkdev.c
··· 62 62 return clk; 63 63 } 64 64 65 - struct clk *clk_get(struct device *dev, const char *con_id) 65 + struct clk *clk_get_sys(const char *dev_id, const char *con_id) 66 66 { 67 - const char *dev_id = dev ? dev_name(dev) : NULL; 68 67 struct clk *clk; 69 68 70 69 mutex_lock(&clocks_mutex); ··· 73 74 mutex_unlock(&clocks_mutex); 74 75 75 76 return clk ? clk : ERR_PTR(-ENOENT); 77 + } 78 + EXPORT_SYMBOL(clk_get_sys); 79 + 80 + struct clk *clk_get(struct device *dev, const char *con_id) 81 + { 82 + const char *dev_id = dev ? dev_name(dev) : NULL; 83 + 84 + return clk_get_sys(dev_id, con_id); 76 85 } 77 86 EXPORT_SYMBOL(clk_get); 78 87
+17
include/linux/clk.h
··· 125 125 */ 126 126 struct clk *clk_get_parent(struct clk *clk); 127 127 128 + /** 129 + * clk_get_sys - get a clock based upon the device name 130 + * @dev_id: device name 131 + * @con_id: connection ID 132 + * 133 + * Returns a struct clk corresponding to the clock producer, or 134 + * valid IS_ERR() condition containing errno. The implementation 135 + * uses @dev_id and @con_id to determine the clock consumer, and 136 + * thereby the clock producer. In contrast to clk_get() this function 137 + * takes the device name instead of the device itself for identification. 138 + * 139 + * Drivers must assume that the clock source is not enabled. 140 + * 141 + * clk_get_sys should not be called from within interrupt context. 142 + */ 143 + struct clk *clk_get_sys(const char *dev_id, const char *con_id); 144 + 128 145 #endif