All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: "Kim, Milo" <Milo.Kim@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Richard Purdie <rpurdie@rpsys.net>,
	Bryan Wu <bryan.wu@canonical.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] lp855x_bl: use generic PWM functions
Date: Fri, 19 Oct 2012 10:21:07 +0200	[thread overview]
Message-ID: <20121019082107.GA20659@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <A874F61F95741C4A9BA573A70FE3998F6417916D@DQHE02.ent.ti.com>

[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]

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.kim@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 #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-10-19  8:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19  8:11 [PATCH 1/2] lp855x_bl: use generic PWM functions Kim, Milo
2012-10-19  8:21 ` Thierry Reding [this message]
2012-10-19  8:45   ` Kim, Milo
2012-10-22 22:30     ` Andrew Morton
2012-10-24  6:01       ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121019082107.GA20659@avionic-0098.mockup.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=Milo.Kim@ti.com \
    --cc=akpm@linux-foundation.org \
    --cc=bryan.wu@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.