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

input: misc: max77693: Use pwm_get_args() where appropriate

The PWM framework has clarified the concept of reference PWM config (the
platform dependent config retrieved from the DT or the PWM lookup table)
and real PWM state.

Use pwm_get_args() when the PWM user wants to retrieve this reference
config and not the current state.

This is part of the rework allowing the PWM framework to support
hardware readout and expose real PWM state even when the PWM has just
been requested (before the user calls pwm_config/enable/disable()).

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

authored by

Boris Brezillon and committed by
Thierry Reding
ad4e9fec 2289711c

+14 -3
+14 -3
drivers/input/misc/max77693-haptic.c
··· 70 70 71 71 static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) 72 72 { 73 - int delta = (haptic->pwm_dev->period + haptic->pwm_duty) / 2; 73 + struct pwm_args pargs; 74 + int delta; 74 75 int error; 75 76 76 - error = pwm_config(haptic->pwm_dev, delta, haptic->pwm_dev->period); 77 + pwm_get_args(haptic->pwm_dev, &pargs); 78 + delta = (pargs.period + haptic->pwm_duty) / 2; 79 + error = pwm_config(haptic->pwm_dev, delta, pargs.period); 77 80 if (error) { 78 81 dev_err(haptic->dev, "failed to configure pwm: %d\n", error); 79 82 return error; ··· 237 234 struct ff_effect *effect) 238 235 { 239 236 struct max77693_haptic *haptic = input_get_drvdata(dev); 237 + struct pwm_args pargs; 240 238 u64 period_mag_multi; 241 239 242 240 haptic->magnitude = effect->u.rumble.strong_magnitude; ··· 249 245 * The formula to convert magnitude to pwm_duty as follows: 250 246 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) 251 247 */ 252 - period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude; 248 + pwm_get_args(haptic->pwm_dev, &pargs); 249 + period_mag_multi = (u64)pargs.period * haptic->magnitude; 253 250 haptic->pwm_duty = (unsigned int)(period_mag_multi >> 254 251 MAX_MAGNITUDE_SHIFT); 255 252 ··· 333 328 dev_err(&pdev->dev, "failed to get pwm device\n"); 334 329 return PTR_ERR(haptic->pwm_dev); 335 330 } 331 + 332 + /* 333 + * FIXME: pwm_apply_args() should be removed when switching to the 334 + * atomic PWM API. 335 + */ 336 + pwm_apply_args(haptic->pwm_dev); 336 337 337 338 haptic->motor_reg = devm_regulator_get(&pdev->dev, "haptic"); 338 339 if (IS_ERR(haptic->motor_reg)) {