Date:2012-09-12 12:01:46 (7 years 2 months ago)
Author:Tushar Behera
Commit:7220711f20949434621ec8baa6692b9f4553945a
Message: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>
Files: include/linux/pwm.h (5 diffs)

Change Details

include/linux/pwm.h
11#ifndef __LINUX_PWM_H
22#define __LINUX_PWM_H
33
4#include <linux/err.h>
45#include <linux/of.h>
56
67struct pwm_device;
78struct seq_file;
89
10#if IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM)
911/*
1012 * pwm_request - request a PWM device
1113 */
...... 
3032 * pwm_disable - stop a PWM output toggling
3133 */
3234void 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
3359
34#ifdef CONFIG_PWM
3560struct pwm_chip;
3661
3762enum {
...... 
113138    unsigned int of_pwm_n_cells;
114139};
115140
141#if IS_ENABLED(CONFIG_PWM)
116142int pwm_set_chip_data(struct pwm_device *pwm, void *data);
117143void *pwm_get_chip_data(struct pwm_device *pwm);
118144
...... 
125151struct pwm_device *pwm_get(struct device *dev, const char *consumer);
126152void pwm_put(struct pwm_device *pwm);
127153
154struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer);
155void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
156#else
157static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data)
158{
159    return -EINVAL;
160}
161
162static inline void *pwm_get_chip_data(struct pwm_device *pwm)
163{
164    return NULL;
165}
166
167static inline int pwmchip_add(struct pwm_chip *chip)
168{
169    return -EINVAL;
170}
171
172static inline int pwmchip_remove(struct pwm_chip *chip)
173{
174    return -EINVAL;
175}
176
177static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
178                               unsigned int index,
179                               const char *label)
180{
181    return ERR_PTR(-ENODEV);
182}
183
184static inline struct pwm_device *pwm_get(struct device *dev,
185                     const char *consumer)
186{
187    return ERR_PTR(-ENODEV);
188}
189
190static inline void pwm_put(struct pwm_device *pwm)
191{
192}
193
194static inline struct pwm_device *devm_pwm_get(struct device *dev,
195                          const char *consumer)
196{
197    return ERR_PTR(-ENODEV);
198}
199
200static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
201{
202}
203#endif
204
128205struct pwm_lookup {
129206    struct list_head list;
130207    const char *provider;
...... 
141218        .con_id = _con_id, \
142219    }
143220
221#if IS_ENABLED(CONFIG_PWM)
144222void pwm_add_table(struct pwm_lookup *table, size_t num);
145
223#else
224static inline void pwm_add_table(struct pwm_lookup *table, size_t num)
225{
226}
146227#endif
147228
148229#endif /* __LINUX_PWM_H */

Archive Download the corresponding diff file



interactive