Commit 0bcf168b authored by Tushar Behera's avatar Tushar Behera Committed by Thierry Reding

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: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarTushar Behera <tushar.behera@linaro.org>
Signed-off-by: default avatarThierry Reding <thierry.reding@avionic-design.de>
parent 7b27c160
#ifndef __LINUX_PWM_H
#define __LINUX_PWM_H
#include <linux/err.h>
#include <linux/of.h>
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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment