pwm: Add pwm_get_polarity() helper function
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 1 Jul 2015 08:21:49 +0000 (10:21 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Mon, 20 Jul 2015 07:51:27 +0000 (09:51 +0200)
Some drivers are directly accessing the ->polarity field in pwm_device.
Add a helper to retrieve the current polarity so that we can easily move
this field elsewhere (required to support atomic update).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
include/linux/pwm.h

index d8f691339a450a4ae7236effa17c140c13e60007..6f286df3002180224d33bdd81747527451e11b6c 100644 (file)
@@ -124,6 +124,11 @@ static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm)
  */
 int pwm_set_polarity(struct pwm_device *pwm, enum pwm_polarity polarity);
 
+static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)
+{
+       return pwm ? pwm->polarity : PWM_POLARITY_NORMAL;
+}
+
 /**
  * struct pwm_ops - PWM controller operations
  * @request: optional hook for requesting a PWM