aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pwm.h
diff options
context:
space:
mode:
authorTushar Behera <tushar.behera@linaro.org>2012-09-12 06:01:46 -0400
committerThierry Reding <thierry.reding@avionic-design.de>2012-09-20 06:52:02 -0400
commit0bcf168b024871c64eb5df157739efd2ae9b0bdf (patch)
tree565639539efdc981bd9a7a83dfa1310f8553f902 /include/linux/pwm.h
parent7b27c160c68152581c702b9f1fe362338d2a0cad (diff)
pwm: Fix compilation error when CONFIG_PWM is not defined
Add dummy implemention of public symbols for compilation-safe inclusion of include/linux/pwm.h file when CONFIG_PWM is not defined. Reported-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Tushar Behera <tushar.behera@linaro.org> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'include/linux/pwm.h')
-rw-r--r--include/linux/pwm.h82
1 files changed, 80 insertions, 2 deletions
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 40c764318957..112b31436848 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -1,11 +1,13 @@
1#ifndef __LINUX_PWM_H 1#ifndef __LINUX_PWM_H
2#define __LINUX_PWM_H 2#define __LINUX_PWM_H
3 3
4#include <linux/err.h>
4#include <linux/of.h> 5#include <linux/of.h>
5 6
6struct pwm_device; 7struct pwm_device;
7struct seq_file; 8struct seq_file;
8 9
10#if IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM)
9/* 11/*
10 * pwm_request - request a PWM device 12 * pwm_request - request a PWM device
11 */ 13 */
@@ -30,8 +32,31 @@ int pwm_enable(struct pwm_device *pwm);
30 * pwm_disable - stop a PWM output toggling 32 * pwm_disable - stop a PWM output toggling
31 */ 33 */
32void pwm_disable(struct pwm_device *pwm); 34void pwm_disable(struct pwm_device *pwm);
35#else
36static inline struct pwm_device *pwm_request(int pwm_id, const char *label)
37{
38 return ERR_PTR(-ENODEV);
39}
40
41static inline void pwm_free(struct pwm_device *pwm)
42{
43}
44
45static inline int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
46{
47 return -EINVAL;
48}
49
50static inline int pwm_enable(struct pwm_device *pwm)
51{
52 return -EINVAL;
53}
54
55static inline void pwm_disable(struct pwm_device *pwm)
56{
57}
58#endif
33 59
34#ifdef CONFIG_PWM
35struct pwm_chip; 60struct pwm_chip;
36 61
37/** 62/**
@@ -136,6 +161,7 @@ struct pwm_chip {
136 unsigned int of_pwm_n_cells; 161 unsigned int of_pwm_n_cells;
137}; 162};
138 163
164#if IS_ENABLED(CONFIG_PWM)
139int pwm_set_chip_data(struct pwm_device *pwm, void *data); 165int pwm_set_chip_data(struct pwm_device *pwm, void *data);
140void *pwm_get_chip_data(struct pwm_device *pwm); 166void *pwm_get_chip_data(struct pwm_device *pwm);
141 167
@@ -150,6 +176,54 @@ void pwm_put(struct pwm_device *pwm);
150 176
151struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer); 177struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer);
152void devm_pwm_put(struct device *dev, struct pwm_device *pwm); 178void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
179#else
180static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data)
181{
182 return -EINVAL;
183}
184
185static inline void *pwm_get_chip_data(struct pwm_device *pwm)
186{
187 return NULL;
188}
189
190static inline int pwmchip_add(struct pwm_chip *chip)
191{
192 return -EINVAL;
193}
194
195static inline int pwmchip_remove(struct pwm_chip *chip)
196{
197 return -EINVAL;
198}
199
200static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
201 unsigned int index,
202 const char *label)
203{
204 return ERR_PTR(-ENODEV);
205}
206
207static inline struct pwm_device *pwm_get(struct device *dev,
208 const char *consumer)
209{
210 return ERR_PTR(-ENODEV);
211}
212
213static inline void pwm_put(struct pwm_device *pwm)
214{
215}
216
217static inline struct pwm_device *devm_pwm_get(struct device *dev,
218 const char *consumer)
219{
220 return ERR_PTR(-ENODEV);
221}
222
223static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
224{
225}
226#endif
153 227
154struct pwm_lookup { 228struct pwm_lookup {
155 struct list_head list; 229 struct list_head list;
@@ -167,8 +241,12 @@ struct pwm_lookup {
167 .con_id = _con_id, \ 241 .con_id = _con_id, \
168 } 242 }
169 243
244#if IS_ENABLED(CONFIG_PWM)
170void pwm_add_table(struct pwm_lookup *table, size_t num); 245void pwm_add_table(struct pwm_lookup *table, size_t num);
171 246#else
247static inline void pwm_add_table(struct pwm_lookup *table, size_t num)
248{
249}
172#endif 250#endif
173 251
174#endif /* __LINUX_PWM_H */ 252#endif /* __LINUX_PWM_H */