diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2012-07-30 17:39:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:11 -0400 |
commit | 93abe8e4b13ae9a0428ce940a8a03ac72a7626f1 (patch) | |
tree | 00ee23e5533c0bda7a76c2dc63e0bfcfcde7fa7f /include | |
parent | bf7c27e9887af48952743753916f9cfbe900d0e9 (diff) |
clk: add non CONFIG_HAVE_CLK routines
Many drivers are shared between architectures that may or may not have
HAVE_CLK selected for them. To remove compilation errors for them we
enclose clk_*() calls in these drivers within #ifdef CONFIG_HAVE_CLK,
#endif.
This patch removes the need of these CONFIG_HAVE_CLK statements, by
introducing dummy routines when HAVE_CLK is not selected by platforms.
So, definition of these routines will always be available. These calls
will return error for platforms that don't select HAVE_CLK.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Bhupesh Sharma <bhupesh.sharma@st.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: viresh kumar <viresh.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/clk.h | 168 |
1 files changed, 109 insertions, 59 deletions
diff --git a/include/linux/clk.h b/include/linux/clk.h index 2fd6a4234531..b3ac22d0fc1f 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
@@ -85,6 +85,43 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb); | |||
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * clk_prepare - prepare a clock source | ||
89 | * @clk: clock source | ||
90 | * | ||
91 | * This prepares the clock source for use. | ||
92 | * | ||
93 | * Must not be called from within atomic context. | ||
94 | */ | ||
95 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
96 | int clk_prepare(struct clk *clk); | ||
97 | #else | ||
98 | static inline int clk_prepare(struct clk *clk) | ||
99 | { | ||
100 | might_sleep(); | ||
101 | return 0; | ||
102 | } | ||
103 | #endif | ||
104 | |||
105 | /** | ||
106 | * clk_unprepare - undo preparation of a clock source | ||
107 | * @clk: clock source | ||
108 | * | ||
109 | * This undoes a previously prepared clock. The caller must balance | ||
110 | * the number of prepare and unprepare calls. | ||
111 | * | ||
112 | * Must not be called from within atomic context. | ||
113 | */ | ||
114 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
115 | void clk_unprepare(struct clk *clk); | ||
116 | #else | ||
117 | static inline void clk_unprepare(struct clk *clk) | ||
118 | { | ||
119 | might_sleep(); | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | #ifdef CONFIG_HAVE_CLK | ||
124 | /** | ||
88 | * clk_get - lookup and obtain a reference to a clock producer. | 125 | * clk_get - lookup and obtain a reference to a clock producer. |
89 | * @dev: device for clock "consumer" | 126 | * @dev: device for clock "consumer" |
90 | * @id: clock consumer ID | 127 | * @id: clock consumer ID |
@@ -122,24 +159,6 @@ struct clk *clk_get(struct device *dev, const char *id); | |||
122 | struct clk *devm_clk_get(struct device *dev, const char *id); | 159 | struct clk *devm_clk_get(struct device *dev, const char *id); |
123 | 160 | ||
124 | /** | 161 | /** |
125 | * clk_prepare - prepare a clock source | ||
126 | * @clk: clock source | ||
127 | * | ||
128 | * This prepares the clock source for use. | ||
129 | * | ||
130 | * Must not be called from within atomic context. | ||
131 | */ | ||
132 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
133 | int clk_prepare(struct clk *clk); | ||
134 | #else | ||
135 | static inline int clk_prepare(struct clk *clk) | ||
136 | { | ||
137 | might_sleep(); | ||
138 | return 0; | ||
139 | } | ||
140 | #endif | ||
141 | |||
142 | /** | ||
143 | * clk_enable - inform the system when the clock source should be running. | 162 | * clk_enable - inform the system when the clock source should be running. |
144 | * @clk: clock source | 163 | * @clk: clock source |
145 | * | 164 | * |
@@ -167,47 +186,6 @@ int clk_enable(struct clk *clk); | |||
167 | */ | 186 | */ |
168 | void clk_disable(struct clk *clk); | 187 | void clk_disable(struct clk *clk); |
169 | 188 | ||
170 | |||
171 | /** | ||
172 | * clk_unprepare - undo preparation of a clock source | ||
173 | * @clk: clock source | ||
174 | * | ||
175 | * This undoes a previously prepared clock. The caller must balance | ||
176 | * the number of prepare and unprepare calls. | ||
177 | * | ||
178 | * Must not be called from within atomic context. | ||
179 | */ | ||
180 | #ifdef CONFIG_HAVE_CLK_PREPARE | ||
181 | void clk_unprepare(struct clk *clk); | ||
182 | #else | ||
183 | static inline void clk_unprepare(struct clk *clk) | ||
184 | { | ||
185 | might_sleep(); | ||
186 | } | ||
187 | #endif | ||
188 | |||
189 | /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ | ||
190 | static inline int clk_prepare_enable(struct clk *clk) | ||
191 | { | ||
192 | int ret; | ||
193 | |||
194 | ret = clk_prepare(clk); | ||
195 | if (ret) | ||
196 | return ret; | ||
197 | ret = clk_enable(clk); | ||
198 | if (ret) | ||
199 | clk_unprepare(clk); | ||
200 | |||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ | ||
205 | static inline void clk_disable_unprepare(struct clk *clk) | ||
206 | { | ||
207 | clk_disable(clk); | ||
208 | clk_unprepare(clk); | ||
209 | } | ||
210 | |||
211 | /** | 189 | /** |
212 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. | 190 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. |
213 | * This is only valid once the clock source has been enabled. | 191 | * This is only valid once the clock source has been enabled. |
@@ -298,6 +276,78 @@ struct clk *clk_get_parent(struct clk *clk); | |||
298 | */ | 276 | */ |
299 | struct clk *clk_get_sys(const char *dev_id, const char *con_id); | 277 | struct clk *clk_get_sys(const char *dev_id, const char *con_id); |
300 | 278 | ||
279 | #else /* !CONFIG_HAVE_CLK */ | ||
280 | |||
281 | static inline struct clk *clk_get(struct device *dev, const char *id) | ||
282 | { | ||
283 | return NULL; | ||
284 | } | ||
285 | |||
286 | static inline struct clk *devm_clk_get(struct device *dev, const char *id) | ||
287 | { | ||
288 | return NULL; | ||
289 | } | ||
290 | |||
291 | static inline void clk_put(struct clk *clk) {} | ||
292 | |||
293 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} | ||
294 | |||
295 | static inline int clk_enable(struct clk *clk) | ||
296 | { | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static inline void clk_disable(struct clk *clk) {} | ||
301 | |||
302 | static inline unsigned long clk_get_rate(struct clk *clk) | ||
303 | { | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static inline int clk_set_rate(struct clk *clk, unsigned long rate) | ||
308 | { | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static inline long clk_round_rate(struct clk *clk, unsigned long rate) | ||
313 | { | ||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static inline int clk_set_parent(struct clk *clk, struct clk *parent) | ||
318 | { | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static inline struct clk *clk_get_parent(struct clk *clk) | ||
323 | { | ||
324 | return NULL; | ||
325 | } | ||
326 | |||
327 | #endif | ||
328 | |||
329 | /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ | ||
330 | static inline int clk_prepare_enable(struct clk *clk) | ||
331 | { | ||
332 | int ret; | ||
333 | |||
334 | ret = clk_prepare(clk); | ||
335 | if (ret) | ||
336 | return ret; | ||
337 | ret = clk_enable(clk); | ||
338 | if (ret) | ||
339 | clk_unprepare(clk); | ||
340 | |||
341 | return ret; | ||
342 | } | ||
343 | |||
344 | /* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */ | ||
345 | static inline void clk_disable_unprepare(struct clk *clk) | ||
346 | { | ||
347 | clk_disable(clk); | ||
348 | clk_unprepare(clk); | ||
349 | } | ||
350 | |||
301 | /** | 351 | /** |
302 | * clk_add_alias - add a new clock alias | 352 | * clk_add_alias - add a new clock alias |
303 | * @alias: name for clock alias | 353 | * @alias: name for clock alias |