xref: /linux/rust/helpers/clk.c (revision 976aa630da5b5508c278487db31b873ddf6bae8f)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/clk.h>
4 
5 /*
6  * The "inline" implementation of below helpers are only available when
7  * CONFIG_HAVE_CLK or CONFIG_HAVE_CLK_PREPARE aren't set.
8  */
9 #ifndef CONFIG_HAVE_CLK
rust_helper_clk_get(struct device * dev,const char * id)10 struct clk *rust_helper_clk_get(struct device *dev, const char *id)
11 {
12 	return clk_get(dev, id);
13 }
14 
rust_helper_clk_put(struct clk * clk)15 void rust_helper_clk_put(struct clk *clk)
16 {
17 	clk_put(clk);
18 }
19 
rust_helper_clk_enable(struct clk * clk)20 int rust_helper_clk_enable(struct clk *clk)
21 {
22 	return clk_enable(clk);
23 }
24 
rust_helper_clk_disable(struct clk * clk)25 void rust_helper_clk_disable(struct clk *clk)
26 {
27 	clk_disable(clk);
28 }
29 
rust_helper_clk_get_rate(struct clk * clk)30 unsigned long rust_helper_clk_get_rate(struct clk *clk)
31 {
32 	return clk_get_rate(clk);
33 }
34 
rust_helper_clk_set_rate(struct clk * clk,unsigned long rate)35 int rust_helper_clk_set_rate(struct clk *clk, unsigned long rate)
36 {
37 	return clk_set_rate(clk, rate);
38 }
39 #endif
40 
41 #ifndef CONFIG_HAVE_CLK_PREPARE
rust_helper_clk_prepare(struct clk * clk)42 int rust_helper_clk_prepare(struct clk *clk)
43 {
44 	return clk_prepare(clk);
45 }
46 
rust_helper_clk_unprepare(struct clk * clk)47 void rust_helper_clk_unprepare(struct clk *clk)
48 {
49 	clk_unprepare(clk);
50 }
51 #endif
52 
rust_helper_clk_get_optional(struct device * dev,const char * id)53 struct clk *rust_helper_clk_get_optional(struct device *dev, const char *id)
54 {
55 	return clk_get_optional(dev, id);
56 }
57 
rust_helper_clk_prepare_enable(struct clk * clk)58 int rust_helper_clk_prepare_enable(struct clk *clk)
59 {
60 	return clk_prepare_enable(clk);
61 }
62 
rust_helper_clk_disable_unprepare(struct clk * clk)63 void rust_helper_clk_disable_unprepare(struct clk *clk)
64 {
65 	clk_disable_unprepare(clk);
66 }
67