Skip to content

Commit

Permalink
pwm: Fix compilation error when CONFIG_PWM is not defined
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tushar Behera authored and Thierry Reding committed Sep 20, 2012
1 parent 7b27c16 commit 0bcf168
Showing 1 changed file with 80 additions and 2 deletions.
82 changes: 80 additions & 2 deletions include/linux/pwm.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#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
*/
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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 */

0 comments on commit 0bcf168

Please sign in to comment.