linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Yisheng Xie <ysxie@foxmail.com>
Cc: jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: pwm: fix max_brightness works abnormal when active_low
Date: Sun, 10 Feb 2019 17:39:30 +0100	[thread overview]
Message-ID: <20190210163929.GA5780@amd> (raw)
In-Reply-To: <1549802229-31170-1-git-send-email-ysxie@foxmail.com>

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

On Sun 2019-02-10 20:37:09, Yisheng Xie wrote:
> When leds-pwm is active_low, smaller number of  duty kept in led_dat
> means less brighness, so we should disable pwm when led_dat->duty is
> equal to period instead of zero, which means max_brightness.

Will all pwm drivers leave the signal 'low' when pwm is disabled? Not
tristate or something?

Plus please use temporary variable. This is really hard to read.

Or maybe

   led_dat->active_low * new_duty == led_dat->period

?
									Pavel

> Signed-off-by: Yisheng Xie <ysxie@foxmail.com>
> ---
>  drivers/leds/leds-pwm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index df80c89..07fb772 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -41,7 +41,7 @@ static void __led_pwm_set(struct led_pwm_data *led_dat)
>  
>  	pwm_config(led_dat->pwm, new_duty, led_dat->period);
>  
> -	if (new_duty == 0)
> +	if (led_dat->active_low ? new_duty == led_dat->period : new_duty == 0)
>  		pwm_disable(led_dat->pwm);
>  	else
>  		pwm_enable(led_dat->pwm);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

      reply	other threads:[~2019-02-10 16:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-10 12:37 [PATCH] leds: pwm: fix max_brightness works abnormal when active_low Yisheng Xie
2019-02-10 16:39 ` Pavel Machek [this message]

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=20190210163929.GA5780@amd \
    --to=pavel@ucw.cz \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=ysxie@foxmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).