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

clk: Extract OF clock helpers in <linux/of_clk.h>

The use of of_clk_get_parent_{count,name}() and of_clk_init() is not
limited to clock providers.

Hence move these helpers into their own header file, so callers that are
not clock providers no longer have to include <linux/clk-provider.h>.

Suggested-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Geert Uytterhoeven and committed by
Stephen Boyd
eb06d6bb 60cc43fc

+32 -13
+1
MAINTAINERS
··· 3556 3556 X: drivers/clk/clkdev.c 3557 3557 F: include/linux/clk-pr* 3558 3558 F: include/linux/clk/ 3559 + F: include/linux/of_clk.h 3559 3560 3560 3561 COMMON INTERNET FILE SYSTEM (CIFS) 3561 3562 M: Steve French <sfrench@samba.org>
+1 -13
include/linux/clk-provider.h
··· 13 13 14 14 #include <linux/io.h> 15 15 #include <linux/of.h> 16 + #include <linux/of_clk.h> 16 17 17 18 #ifdef CONFIG_COMMON_CLK 18 19 ··· 891 890 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); 892 891 struct clk_hw *of_clk_hw_onecell_get(struct of_phandle_args *clkspec, 893 892 void *data); 894 - unsigned int of_clk_get_parent_count(struct device_node *np); 895 893 int of_clk_parent_fill(struct device_node *np, const char **parents, 896 894 unsigned int size); 897 - const char *of_clk_get_parent_name(struct device_node *np, int index); 898 895 int of_clk_detect_critical(struct device_node *np, int index, 899 896 unsigned long *flags); 900 - void of_clk_init(const struct of_device_id *matches); 901 897 902 898 #else /* !CONFIG_OF */ 903 899 ··· 941 943 { 942 944 return ERR_PTR(-ENOENT); 943 945 } 944 - static inline unsigned int of_clk_get_parent_count(struct device_node *np) 945 - { 946 - return 0; 947 - } 948 946 static inline int of_clk_parent_fill(struct device_node *np, 949 947 const char **parents, unsigned int size) 950 948 { 951 949 return 0; 952 - } 953 - static inline const char *of_clk_get_parent_name(struct device_node *np, 954 - int index) 955 - { 956 - return NULL; 957 950 } 958 951 static inline int of_clk_detect_critical(struct device_node *np, int index, 959 952 unsigned long *flags) 960 953 { 961 954 return 0; 962 955 } 963 - static inline void of_clk_init(const struct of_device_id *matches) {} 964 956 #endif /* CONFIG_OF */ 965 957 966 958 /*
+30
include/linux/of_clk.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * OF clock helpers 4 + */ 5 + 6 + #ifndef __LINUX_OF_CLK_H 7 + #define __LINUX_OF_CLK_H 8 + 9 + #if defined(CONFIG_COMMON_CLK) && defined(CONFIG_OF) 10 + 11 + unsigned int of_clk_get_parent_count(struct device_node *np); 12 + const char *of_clk_get_parent_name(struct device_node *np, int index); 13 + void of_clk_init(const struct of_device_id *matches); 14 + 15 + #else /* !CONFIG_COMMON_CLK || !CONFIG_OF */ 16 + 17 + static inline unsigned int of_clk_get_parent_count(struct device_node *np) 18 + { 19 + return 0; 20 + } 21 + static inline const char *of_clk_get_parent_name(struct device_node *np, 22 + int index) 23 + { 24 + return NULL; 25 + } 26 + static inline void of_clk_init(const struct of_device_id *matches) {} 27 + 28 + #endif /* !CONFIG_COMMON_CLK || !CONFIG_OF */ 29 + 30 + #endif /* __LINUX_OF_CLK_H */