Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932644AbbENIpB (ORCPT ); Thu, 14 May 2015 04:45:01 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:39148 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbbENIo5 (ORCPT ); Thu, 14 May 2015 04:44:57 -0400 X-AuditID: cbfec7f4-f79c56d0000012ee-06-55546085298f Message-id: <55546084.9050704@samsung.com> Date: Thu, 14 May 2015 10:44:52 +0200 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: Stas Sergeev Cc: linux-leds@vger.kernel.org, Linux kernel , Bryan Wu , Richard Purdie , Kyungmin Park Subject: Re: [PATCH] leds: fix brightness changing when software blinking is active References: <55535DA4.2010509@list.ru> In-reply-to: <55535DA4.2010509@list.ru> Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsVy+t/xa7qtCSGhBqtmK1gc3TmRyeJs0xt2 i8u75rBZbH2zjtFi966nrBatmxqYHdg8ds66y+5xb8tlZo8983+wevRtWcXo8XmTXABrFJdN SmpOZllqkb5dAlfG3ualjAXPFCu+/jnI3sB4VLqLkZNDQsBE4tfbW2wQtpjEhXvrgWwuDiGB pYwS+x+8gnKeMUrc3zibCaSKV0BL4tbUM0A2BweLgKrExyYfkDCbgKHEzxevwUpEBSIk/pze xwpRLijxY/I9FpByEQF5iQ2NZSAjmQX2MkpM/vkWbLGwQKjE75lf2UFsIQE1iTdPpjCC2JwC 6hK3Fv8Dm8ksYCbxqGUdM4QtL7F5zVvmCYwCs5CsmIWkbBaSsgWMzKsYRVNLkwuKk9JzDfWK E3OLS/PS9ZLzczcxQkL7yw7GxcesDjEKcDAq8fCuUA8OFWJNLCuuzD3EKMHBrCTCuz46JFSI NyWxsiq1KD++qDQntfgQozQHi5I479xd70OEBNITS1KzU1MLUotgskwcnFINjEqrjfLP61ze EOQWpn2+ep6Y3pMZct8rFHXlGBtvXYpd9uXf0xPfX86/39qvmPz8xr+J0mGvZom/6TzF+bjA bfnywKOn0w8sadz36dTO5DnBXMKWy/XvrBTc8H9bfUrjk6trPkrfDLjN9rfG8830jScXH2oV 8//BU9IpKjvluMWFnYnm767t+nhUiaU4I9FQi7moOBEA/rSRjGkCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4447 Lines: 129 On 05/13/2015 04:20 PM, Stas Sergeev wrote: > > The following sequence: > echo timer >/sys/class/leds//trigger > echo 1 >/sys/class/leds//brightness > should change the ON brightness for blinking. > The function led_set_brightness() was mistakenly initiating the > delayed blink stop procedure, which resulted in no blinking with > the timer trigger still active. > > This patch fixes the problem by changing led_set_brightness() > to not initiate the delayed blink stop. The callers that need > a blink stop, were updated to explicitly call led_stop_software_blink(). > > CC: Bryan Wu > CC: Richard Purdie > CC: Jacek Anaszewski > CC: Kyungmin Park > CC: linux-leds@vger.kernel.org > CC: linux-kernel@vger.kernel.org > > Signed-off-by: Stas Sergeev > --- > drivers/leds/led-class.c | 5 +++++ > drivers/leds/led-core.c | 3 +-- > drivers/leds/trigger/ledtrig-oneshot.c | 1 + > drivers/leds/trigger/ledtrig-timer.c | 2 ++ > 4 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 795ec99..65c2c80 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -121,6 +121,11 @@ static void led_timer_function(unsigned long data) > brightness = led_get_brightness(led_cdev); > if (!brightness) { > /* Time to switch the LED on. */ > + if (led_cdev->delayed_set_value) { > + led_cdev->blink_brightness = > + led_cdev->delayed_set_value; > + led_cdev->delayed_set_value = 0; > + } > brightness = led_cdev->blink_brightness; > delay = led_cdev->blink_delay_on; > } else { > diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c > index 9886dac..3210020 100644 > --- a/drivers/leds/led-core.c > +++ b/drivers/leds/led-core.c > @@ -119,10 +119,9 @@ void led_set_brightness(struct led_classdev *led_cdev, > { > int ret = 0; > > - /* delay brightness setting if need to stop soft-blink timer */ > + /* delay brightness setting to next soft-blink */ How about: /* delay brightness setting if soft-blink is activated */ > if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) { > led_cdev->delayed_set_value = brightness; > - schedule_work(&led_cdev->set_brightness_work); This line is still required. Please refer to the patch d23a22a74. The author however mistakenly assumes that setting brightness while soft blink is activated should result in disabling the trigger. This is contrary to the documentation, which says: "You can change the brightness value of a LED independently of the timer trigger. However, if you set the brightness value to LED_OFF it will also disable the timer trigger." What needs tweaking here is set_brightness_delayed function, which should call led_stop_software_blink only if delayed_set_value is 0. Please fix the patch accordingly. > return; > } > > diff --git a/drivers/leds/trigger/ledtrig-oneshot.c b/drivers/leds/trigger/ledtrig-oneshot.c > index fbd02cd..c1bff10 100644 > --- a/drivers/leds/trigger/ledtrig-oneshot.c > +++ b/drivers/leds/trigger/ledtrig-oneshot.c > @@ -177,6 +177,7 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev) > } > > /* Stop blinking */ > + led_stop_software_blink(led_cdev); This won't be needed. > led_set_brightness(led_cdev, LED_OFF); > } > > diff --git a/drivers/leds/trigger/ledtrig-timer.c b/drivers/leds/trigger/ledtrig-timer.c > index 8d09327..3577c23 100644 > --- a/drivers/leds/trigger/ledtrig-timer.c > +++ b/drivers/leds/trigger/ledtrig-timer.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include "../leds.h" > > static ssize_t led_delay_on_show(struct device *dev, > struct device_attribute *attr, char *buf) > @@ -103,6 +104,7 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev) > } > > /* Stop blinking */ > + led_stop_software_blink(led_cdev); This won't be needed. > led_set_brightness(led_cdev, LED_OFF); > } > -- Best Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/