xref: /linux/rust/helpers/clk.c (revision 6fa6b5cb60490db2591bb93872b95f72315e5f53)
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
10 __rust_helper struct clk *rust_helper_clk_get(struct device *dev,
11 					      const char *id)
12 {
13 	return clk_get(dev, id);
14 }
15 
16 __rust_helper void rust_helper_clk_put(struct clk *clk)
17 {
18 	clk_put(clk);
19 }
20 
21 __rust_helper int rust_helper_clk_enable(struct clk *clk)
22 {
23 	return clk_enable(clk);
24 }
25 
26 __rust_helper void rust_helper_clk_disable(struct clk *clk)
27 {
28 	clk_disable(clk);
29 }
30 
31 __rust_helper unsigned long rust_helper_clk_get_rate(struct clk *clk)
32 {
33 	return clk_get_rate(clk);
34 }
35 
36 __rust_helper int rust_helper_clk_set_rate(struct clk *clk, unsigned long rate)
37 {
38 	return clk_set_rate(clk, rate);
39 }
40 #endif
41 
42 #ifndef CONFIG_HAVE_CLK_PREPARE
43 __rust_helper int rust_helper_clk_prepare(struct clk *clk)
44 {
45 	return clk_prepare(clk);
46 }
47 
48 __rust_helper void rust_helper_clk_unprepare(struct clk *clk)
49 {
50 	clk_unprepare(clk);
51 }
52 #endif
53 
54 __rust_helper struct clk *rust_helper_clk_get_optional(struct device *dev,
55 						       const char *id)
56 {
57 	return clk_get_optional(dev, id);
58 }
59 
60 __rust_helper int rust_helper_clk_prepare_enable(struct clk *clk)
61 {
62 	return clk_prepare_enable(clk);
63 }
64 
65 __rust_helper void rust_helper_clk_disable_unprepare(struct clk *clk)
66 {
67 	clk_disable_unprepare(clk);
68 }
69