On Fri, Oct 19, 2012 at 08:11:50AM +0000, Kim, Milo wrote:
>  The LP855x family devices support the PWM input for the backlight control.
>  Period of the PWM is configurable in the platform side.
>  Platform specific functions are unnecessary anymore because
>  generic PWM functions are used inside the driver.
> 
>  (PWM input mode)
>  To set the brightness, new lp855x_pwm_ctrl() is used.
>  If a PWM device is not allocated, devm_pwm_get() is called.
>  The PWM consumer name is from the chip name such as 'lp8550' and 'lp8556'.
>  To get the brightness value, no additional handling is required.
>  Just the value of 'props.brightness' is returned.
> 
>  If the PWM driver is not ready while initializing the LP855x driver, it's OK.
>  The PWM device can be retrieved later, when the brightness value is changed.
> 
>  Documentation is updated with an example.
> 
> Signed-off-by: Milo(Woogyom) Kim <milo....@ti.com>

Generally this looks good. Obviously you'll need to update any users of
this driver as well. It might make sense to include those changes in
this patch to avoid interim build failures.

Other than that I have just one smaller comment below.

> @@ -121,6 +123,25 @@ static int lp855x_init_registers(struct lp855x *lp)
>       return ret;
>  }
>  
> +static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
> +{
> +     unsigned int period = lp->pdata->period_ns;
> +     unsigned int duty = br * period / max_br;
> +     struct pwm_device *pwm;
> +
> +     /* request pwm device with the consumer name */
> +     if (!lp->pwm) {
> +             pwm = devm_pwm_get(lp->dev, lp->chipname);
> +             if (IS_ERR(pwm))
> +                     return;
> +
> +             lp->pwm = pwm;
> +     }
> +
> +     pwm_config(lp->pwm, duty, period);
> +     duty == 0 ? pwm_disable(lp->pwm) : pwm_enable(lp->pwm);

This is really ugly and should be written explicitly:

        if (duty == 0)
                pwm_disable(lp->pwm);
        else
                pwm_enable(lp->pwm);

Thierry

Attachment: pgpKYexP5O0Nn.pgp
Description: PGP signature

Reply via email to