Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

greybus: kernel_ver.h: provide pwm_is_enabled()

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>

+8 -1
+7
drivers/staging/greybus/kernel_ver.h
··· 328 328 } 329 329 #endif 330 330 331 + #ifdef PWMF_ENABLED 332 + static inline bool pwm_is_enabled(const struct pwm_device *pwm) 333 + { 334 + return test_bit(PWMF_ENABLED, &pwm->flags); 335 + } 336 + #endif 337 + 331 338 #endif /* __GREYBUS_KERNEL_VER_H */
+1 -1
drivers/staging/greybus/pwm.c
··· 132 132 { 133 133 struct gb_pwm_chip *pwmc = pwm_chip_to_gb_pwm_chip(chip); 134 134 135 - if (test_bit(PWMF_ENABLED, &pwm->flags)) 135 + if (pwm_is_enabled(pwm)) 136 136 dev_warn(chip->dev, "freeing PWM device without disabling\n"); 137 137 138 138 gb_pwm_deactivate_operation(pwmc, pwm->hwpwm);