From: Tushar Behera Date: Wed, 12 Sep 2012 10:01:46 +0000 (+0530) Subject: pwm: Fix compilation error when CONFIG_PWM is not defined X-Git-Tag: v3.7-rc1~59^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0bcf168b024871c64eb5df157739efd2ae9b0bdf;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git 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 Signed-off-by: Tushar Behera Signed-off-by: Thierry Reding --- diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 40c7643..112b314 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -1,11 +1,13 @@ #ifndef __LINUX_PWM_H #define __LINUX_PWM_H +#include #include struct pwm_device; struct seq_file; +#if IS_ENABLED(CONFIG_PWM) || IS_ENABLED(CONFIG_HAVE_PWM) /* * pwm_request - request a PWM device */ @@ -30,8 +32,31 @@ int pwm_enable(struct pwm_device *pwm); * pwm_disable - stop a PWM output toggling */ void pwm_disable(struct pwm_device *pwm); +#else +static inline struct pwm_device *pwm_request(int pwm_id, const char *label) +{ + return ERR_PTR(-ENODEV); +} + +static inline void pwm_free(struct pwm_device *pwm) +{ +} + +static inline int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) +{ + return -EINVAL; +} + +static inline int pwm_enable(struct pwm_device *pwm) +{ + return -EINVAL; +} + +static inline void pwm_disable(struct pwm_device *pwm) +{ +} +#endif -#ifdef CONFIG_PWM struct pwm_chip; /** @@ -136,6 +161,7 @@ struct pwm_chip { unsigned int of_pwm_n_cells; }; +#if IS_ENABLED(CONFIG_PWM) int pwm_set_chip_data(struct pwm_device *pwm, void *data); void *pwm_get_chip_data(struct pwm_device *pwm); @@ -150,6 +176,54 @@ void pwm_put(struct pwm_device *pwm); struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer); void devm_pwm_put(struct device *dev, struct pwm_device *pwm); +#else +static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) +{ + return -EINVAL; +} + +static inline void *pwm_get_chip_data(struct pwm_device *pwm) +{ + return NULL; +} + +static inline int pwmchip_add(struct pwm_chip *chip) +{ + return -EINVAL; +} + +static inline int pwmchip_remove(struct pwm_chip *chip) +{ + return -EINVAL; +} + +static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, + unsigned int index, + const char *label) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct pwm_device *pwm_get(struct device *dev, + const char *consumer) +{ + return ERR_PTR(-ENODEV); +} + +static inline void pwm_put(struct pwm_device *pwm) +{ +} + +static inline struct pwm_device *devm_pwm_get(struct device *dev, + const char *consumer) +{ + return ERR_PTR(-ENODEV); +} + +static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) +{ +} +#endif struct pwm_lookup { struct list_head list; @@ -167,8 +241,12 @@ struct pwm_lookup { .con_id = _con_id, \ } +#if IS_ENABLED(CONFIG_PWM) void pwm_add_table(struct pwm_lookup *table, size_t num); - +#else +static inline void pwm_add_table(struct pwm_lookup *table, size_t num) +{ +} #endif #endif /* __LINUX_PWM_H */