mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: Re: [PATCH] pwm-backlight: add regulator and GPIO support
Date: Sat, 30 Jun 2012 20:37:42 +0200	[thread overview]
Message-ID: <20120630183742.GE23990@avionic-0098.adnet.avionic-design.de> (raw)
In-Reply-To: <1340976167-27298-1-git-send-email-acourbot@nvidia.com>

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

On Fri, Jun 29, 2012 at 10:22:47PM +0900, Alexandre Courbot wrote:
> Add support for an optional power regulator and enable/disable GPIO.
> This scheme is commonly used in embedded systems.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

I've added some comments in addition to those by Stephen.

[...]
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 057389d..821e03e 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
[...]
> @@ -141,11 +178,14 @@ static int pwm_backlight_parse_dt(struct device *dev,
>  		data->max_brightness--;
>  	}
>  
> -	/*
> -	 * TODO: Most users of this driver use a number of GPIOs to control
> -	 *       backlight power. Support for specifying these needs to be
> -	 *       added.
> -	 */
> +	ret = of_get_named_gpio(node, "enable-gpios", 0);
> +	if (ret >= 0) {
> +		data->enable_gpio = of_get_named_gpio(node, "enable-gpios", 0);

Can't you just reuse the value of ret here?

[...]
> @@ -231,6 +271,22 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	if (data->pwm_period_ns > 0)
>  		pwm_set_period(pb->pwm, data->pwm_period_ns);
>  
> +
> +	pb->power_reg = devm_regulator_get(&pdev->dev, "power");
> +	if (IS_ERR(pb->power_reg))
> +		return PTR_ERR(pb->power_reg);
> +
> +	pb->enable_gpio = -EINVAL;

Perhaps initialize this to -1? Assigning standard error codes to a GPIO
doesn't make much sense.

[...]
> diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h
> index 56f4a86..5ae2cd0 100644
> --- a/include/linux/pwm_backlight.h
> +++ b/include/linux/pwm_backlight.h
> @@ -18,6 +18,11 @@ struct platform_pwm_backlight_data {
>  	void (*notify_after)(struct device *dev, int brightness);
>  	void (*exit)(struct device *dev);
>  	int (*check_fb)(struct device *dev, struct fb_info *info);
> +	/* optional GPIO that enables/disables the backlight */
> +	int enable_gpio;
> +	/* 0 (default initialization value) is a valid GPIO number. Make use of
> +	 * control gpio explicit to avoid bad surprises. */
> +	bool use_enable_gpio;

It's a shame we have to add workarounds like this...

Also the canonical form to write multi-line comments would be:

	/*
	 * 0 (default ...
	 * ... surprises.
	 */

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2012-06-30 18:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 13:22 Alexandre Courbot
2012-06-29 16:04 ` Stephen Warren
2012-06-30  3:54   ` Alex Courbot
2012-06-30 18:37 ` Thierry Reding [this message]
2012-07-02  3:35   ` Alexandre Courbot
2012-07-02  6:46     ` Thierry Reding
2012-07-02  7:18       ` Alexandre Courbot
2012-07-04 10:48 ` Sascha Hauer
2012-07-04 12:26   ` Alex Courbot
2012-07-04 12:27     ` Mark Brown
2012-07-04 13:00     ` Sascha Hauer
2012-07-04 15:14       ` Alex Courbot
2012-07-04 15:24         ` Mark Brown
2012-07-05  2:36           ` Alex Courbot
2012-07-05  6:20             ` Sascha Hauer
2012-07-05  6:25               ` Alex Courbot
2012-07-05  6:47                 ` Sascha Hauer
2012-07-05  7:43                   ` Alex Courbot
2012-07-05  7:57                     ` Thierry Reding
2012-07-05  8:12                       ` Alex Courbot
2012-07-05 16:03                         ` Stephen Warren
2012-07-09  5:19                           ` Jingoo Han
2012-07-09  6:12                             ` Alex Courbot
2012-07-05  8:02                     ` Sascha Hauer
2012-07-05 10:41                       ` Mark Brown
2012-07-05 10:39                     ` Mark Brown
2012-07-05 10:37                 ` Mark Brown
2012-07-04 20:26         ` Sascha Hauer

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=20120630183742.GE23990@avionic-0098.adnet.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=acourbot@nvidia.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome