From 01eef91312b66edaf907da58cb1471f19605b466 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 14 Apr 2016 21:17:26 +0200 Subject: [PATCH] UPSTREAM: leds: pwm: 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()). Change-Id: I8286b16dc8d828ba8a66a17675fe6fbedcba480b Signed-off-by: Boris Brezillon Acked-by: Jacek Anaszewski Signed-off-by: Thierry Reding Signed-off-by: Tao Huang (cherry picked from commit 1b50673dfa6486a69895bd45bb5eeaaede0a2b93) --- drivers/leds/leds-pwm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 1d07e3e83d29..27f2c5108e8a 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -100,6 +100,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, struct led_pwm *led, struct device_node *child) { struct led_pwm_data *led_data = &priv->leds[priv->num_leds]; + struct pwm_args pargs; int ret; led_data->active_low = led->active_low; @@ -125,7 +126,15 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, if (led_data->can_sleep) INIT_WORK(&led_data->work, led_pwm_work); - led_data->period = pwm_get_period(led_data->pwm); + /* + * FIXME: pwm_apply_args() should be removed when switching to the + * atomic PWM API. + */ + pwm_apply_args(led_data->pwm); + + pwm_get_args(led_data->pwm, &pargs); + + led_data->period = pargs.period; if (!led_data->period && (led->pwm_period_ns > 0)) led_data->period = led->pwm_period_ns;