diff options
author | Florian Vaussard <florian.vaussard@epfl.ch> | 2013-01-28 09:00:57 -0500 |
---|---|---|
committer | Thierry Reding <thierry.reding@avionic-design.de> | 2013-01-30 03:12:18 -0500 |
commit | 6e69ab1361c44e3ee1398158b56d114b1aef8179 (patch) | |
tree | 44994b7b6cdfebaf1de44473597bb5a9adf2f912 | |
parent | 0132267d659107616eb044777f1b0be55381129a (diff) |
pwm: Add pwm_can_sleep() as exported API to users
Calls to some external PWM chips can sleep. To help users,
add pwm_can_sleep() API.
Cc: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
-rw-r--r-- | drivers/pwm/core.c | 12 | ||||
-rw-r--r-- | include/linux/pwm.h | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 903138b18842..ffbef95e88dc 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c | |||
@@ -733,6 +733,18 @@ void devm_pwm_put(struct device *dev, struct pwm_device *pwm) | |||
733 | } | 733 | } |
734 | EXPORT_SYMBOL_GPL(devm_pwm_put); | 734 | EXPORT_SYMBOL_GPL(devm_pwm_put); |
735 | 735 | ||
736 | /** | ||
737 | * pwm_can_sleep() - report whether PWM access will sleep | ||
738 | * @pwm: PWM device | ||
739 | * | ||
740 | * It returns true if accessing the PWM can sleep, false otherwise. | ||
741 | */ | ||
742 | bool pwm_can_sleep(struct pwm_device *pwm) | ||
743 | { | ||
744 | return pwm->chip->can_sleep; | ||
745 | } | ||
746 | EXPORT_SYMBOL_GPL(pwm_can_sleep); | ||
747 | |||
736 | #ifdef CONFIG_DEBUG_FS | 748 | #ifdef CONFIG_DEBUG_FS |
737 | static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) | 749 | static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) |
738 | { | 750 | { |
diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 6d661f32e0e4..3fef47733ea3 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h | |||
@@ -146,6 +146,8 @@ struct pwm_ops { | |||
146 | * @base: number of first PWM controlled by this chip | 146 | * @base: number of first PWM controlled by this chip |
147 | * @npwm: number of PWMs controlled by this chip | 147 | * @npwm: number of PWMs controlled by this chip |
148 | * @pwms: array of PWM devices allocated by the framework | 148 | * @pwms: array of PWM devices allocated by the framework |
149 | * @can_sleep: must be true if the .config(), .enable() or .disable() | ||
150 | * operations may sleep | ||
149 | */ | 151 | */ |
150 | struct pwm_chip { | 152 | struct pwm_chip { |
151 | struct device *dev; | 153 | struct device *dev; |
@@ -159,6 +161,7 @@ struct pwm_chip { | |||
159 | struct pwm_device * (*of_xlate)(struct pwm_chip *pc, | 161 | struct pwm_device * (*of_xlate)(struct pwm_chip *pc, |
160 | const struct of_phandle_args *args); | 162 | const struct of_phandle_args *args); |
161 | unsigned int of_pwm_n_cells; | 163 | unsigned int of_pwm_n_cells; |
164 | bool can_sleep; | ||
162 | }; | 165 | }; |
163 | 166 | ||
164 | #if IS_ENABLED(CONFIG_PWM) | 167 | #if IS_ENABLED(CONFIG_PWM) |
@@ -179,6 +182,8 @@ void pwm_put(struct pwm_device *pwm); | |||
179 | 182 | ||
180 | struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer); | 183 | struct pwm_device *devm_pwm_get(struct device *dev, const char *consumer); |
181 | void devm_pwm_put(struct device *dev, struct pwm_device *pwm); | 184 | void devm_pwm_put(struct device *dev, struct pwm_device *pwm); |
185 | |||
186 | bool pwm_can_sleep(struct pwm_device *pwm); | ||
182 | #else | 187 | #else |
183 | static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) | 188 | static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data) |
184 | { | 189 | { |
@@ -226,6 +231,11 @@ static inline struct pwm_device *devm_pwm_get(struct device *dev, | |||
226 | static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) | 231 | static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) |
227 | { | 232 | { |
228 | } | 233 | } |
234 | |||
235 | static inline bool pwm_can_sleep(struct pwm_device *pwm) | ||
236 | { | ||
237 | return false; | ||
238 | } | ||
229 | #endif | 239 | #endif |
230 | 240 | ||
231 | struct pwm_lookup { | 241 | struct pwm_lookup { |