greybus: kernel_ver.h: provide pwm_is_enabled()
authorGreg Kroah-Hartman <gregkh@google.com>
Wed, 8 Jun 2016 04:33:54 +0000 (21:33 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 8 Jun 2016 16:29:02 +0000 (09:29 -0700)
In the 4.7-rc1 kernel release, PWMF_ENABLED is removed and
pwm_is_enabled() is the correct way to test if a pwm device is enabled,
so provide a version of that function that will work on all older
kernels and change the pwm.c driver to use it so that it will work on
newer kernels as well.

Tested:
Tree now builds successfully against 3.14.y, 4.4.y, 4.5.y,
4.6.y, and 4.7-rc2 kernels

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/kernel_ver.h
drivers/staging/greybus/pwm.c

index f6fb3bf..9819c3e 100644 (file)
@@ -328,4 +328,11 @@ static inline void reinit_completion(struct completion *x)
 }
 #endif
 
+#ifdef PWMF_ENABLED
+static inline bool pwm_is_enabled(const struct pwm_device *pwm)
+{
+       return test_bit(PWMF_ENABLED, &pwm->flags);
+}
+#endif
+
 #endif /* __GREYBUS_KERNEL_VER_H */
index b941cb5..7131232 100644 (file)
@@ -132,7 +132,7 @@ static void gb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
        struct gb_pwm_chip *pwmc = pwm_chip_to_gb_pwm_chip(chip);
 
-       if (test_bit(PWMF_ENABLED, &pwm->flags))
+       if (pwm_is_enabled(pwm))
                dev_warn(chip->dev, "freeing PWM device without disabling\n");
 
        gb_pwm_deactivate_operation(pwmc, pwm->hwpwm);