From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
sakari.ailus@linux.intel.com, stsp@users.sourceforge.net,
pavel@ucw.cz, ospite@studenti.unina.it, davem@davemloft.net,
linus.walleij@linaro.org, ricardo.ribalda@gmail.com,
p.meerwald@bct-electronic.com
Subject: Re: [PATCH 2/5] leds: core: Add LED_BLINK_CHANGE and LED_BLINK_DISABLE flags
Date: Wed, 23 Sep 2015 10:07:38 +0200 [thread overview]
Message-ID: <56025DCA.2000301@samsung.com> (raw)
In-Reply-To: <20150922184403.GB20029@lunn.ch>
Hi Andrew,
Thanks for the review.
On 09/22/2015 08:44 PM, Andrew Lunn wrote:
> On Wed, Sep 16, 2015 at 12:47:41PM +0200, Jacek Anaszewski wrote:
>> This patch adds LED_BLINK_CHANGE flag to indicate that blink brightness
>> has changed
>
> Hi Jacek
>
> The name LED_BLINK_CHANGE does not make me think of changing
> brightness. Maybe a better name would be LED_BLINK_BRIGHTNESS_CHANGE,
> although that it getting a bit long.
I had the same dilemma. We could go for shortcut like
LED_BLINK_BR_CHANGE, but is is not too meaningful either.
I will rename LED_BLINK_CHANGE to LED_BLINK_BRIGHTNESS_CHANGE, unless
better option appears.
> , and LED_BLINK_DISABLE flag to indicate that blinking
>> deactivation has been requested. In order to use the flags
>> led_timer_function and set_brightness_delayed callbacks as well as
>> led_set_brightness function are being modified. The main goal of these
>> modifications is to prepare set_brightness_work for extension of the
>> scope of its responsibilities.
>>
>> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
>> ---
>> drivers/leds/led-core.c | 36 ++++++++++++++++++++++++++----------
>> include/linux/leds.h | 10 ++++++----
>> 2 files changed, 32 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
>> index 2cb4e37..1968e24 100644
>> --- a/drivers/leds/led-core.c
>> +++ b/drivers/leds/led-core.c
>> @@ -44,18 +44,18 @@ 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 {
>> /* Store the current brightness value to be able
>> * to restore it when the delay_off period is over.
>> + * Do it only if there is no pending blink brightness
>> + * change, to avoid overwriting the new value.
>> */
>> - led_cdev->blink_brightness = brightness;
>> + if (!(led_cdev->flags & LED_BLINK_CHANGE))
>> + led_cdev->blink_brightness = brightness;
>> + else
>> + led_cdev->flags &= ~LED_BLINK_CHANGE;
>> brightness = LED_OFF;
>> delay = led_cdev->blink_delay_off;
>> }
>> @@ -84,7 +84,11 @@ static void set_brightness_delayed(struct work_struct *ws)
>> struct led_classdev *led_cdev =
>> container_of(ws, struct led_classdev, set_brightness_work);
>>
>> - led_stop_software_blink(led_cdev);
>> + if (led_cdev->flags & LED_BLINK_DISABLE) {
>> + led_cdev->delayed_set_value = LED_OFF;
>> + led_stop_software_blink(led_cdev);
>> + led_cdev->flags &= ~LED_BLINK_DISABLE;
>> + }
>>
>> led_set_brightness_async(led_cdev, led_cdev->delayed_set_value);
>> }
>> @@ -192,11 +196,23 @@ void led_set_brightness(struct led_classdev *led_cdev,
>> {
>> int ret = 0;
>>
>> - /* delay brightness if soft-blink is active */
>> + /*
>> + * In case blinking is on delay brightness setting
>> + * until the next timer tick.
>> + */
>> if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
>> - led_cdev->delayed_set_value = brightness;
>> - if (brightness == LED_OFF)
>> + /*
>> + * If need to disable soft blinking delegate this to the
>
> If _we_ need to...
OK.
>> + * work queue task to avoid problems in case we are
>> + * called from hard irq context.
>> + */
>> + if (brightness == LED_OFF) {
>> + led_cdev->flags |= LED_BLINK_DISABLE;
>> schedule_work(&led_cdev->set_brightness_work);
>> + } else {
>> + led_cdev->flags |= LED_BLINK_CHANGE;
>> + led_cdev->blink_brightness = brightness;
>> + }
>> return;
>> }
>>
>> diff --git a/include/linux/leds.h b/include/linux/leds.h
>> index b122eea..188352c 100644
>> --- a/include/linux/leds.h
>> +++ b/include/linux/leds.h
>> @@ -44,10 +44,12 @@ struct led_classdev {
>> #define LED_BLINK_ONESHOT (1 << 17)
>> #define LED_BLINK_ONESHOT_STOP (1 << 18)
>> #define LED_BLINK_INVERT (1 << 19)
>> -#define LED_SYSFS_DISABLE (1 << 20)
>> -#define SET_BRIGHTNESS_ASYNC (1 << 21)
>> -#define SET_BRIGHTNESS_SYNC (1 << 22)
>> -#define LED_DEV_CAP_FLASH (1 << 23)
>> +#define LED_BLINK_CHANGE (1 << 20)
>> +#define LED_BLINK_DISABLE (1 << 21)
>> +#define LED_SYSFS_DISABLE (1 << 22)
>> +#define SET_BRIGHTNESS_ASYNC (1 << 23)
>> +#define SET_BRIGHTNESS_SYNC (1 << 24)
>> +#define LED_DEV_CAP_FLASH (1 << 25)
>>
>> /* Set LED brightness level */
>> /* Must not sleep, use a workqueue if needed */
>> --
>> 1.7.9.5
>>
>
--
Best Regards,
Jacek Anaszewski
next prev parent reply other threads:[~2015-09-23 8:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 10:47 [PATCH 0/5] LED core improvements Jacek Anaszewski
2015-09-16 10:47 ` [PATCH 1/5] leds: core: Move LED core callbacks out of led-class.c Jacek Anaszewski
2015-09-22 19:06 ` Andrew Lunn
2015-10-06 15:31 ` Pavel Machek
2015-10-07 7:29 ` Jacek Anaszewski
2015-09-16 10:47 ` [PATCH 2/5] leds: core: Add LED_BLINK_CHANGE and LED_BLINK_DISABLE flags Jacek Anaszewski
2015-09-22 18:44 ` Andrew Lunn
2015-09-23 8:07 ` Jacek Anaszewski [this message]
2015-10-06 15:35 ` Pavel Machek
2015-09-16 10:47 ` [PATCH 3/5] leds: Rename brightness_set_sync op to brightness_set_blocking Jacek Anaszewski
2015-09-22 18:54 ` Andrew Lunn
2015-09-23 8:36 ` Jacek Anaszewski
2015-09-23 9:34 ` Jacek Anaszewski
2015-10-06 15:36 ` Pavel Machek
2015-09-16 10:47 ` [PATCH 4/5] leds: core: Add an internal led_set_brightness_nosleep function Jacek Anaszewski
2015-09-22 19:02 ` Andrew Lunn
2015-09-23 8:53 ` Jacek Anaszewski
2015-09-16 10:47 ` [PATCH 5/5] leds: core: Use set_brightness_work for the blocking op Jacek Anaszewski
2015-09-22 8:03 ` Sakari Ailus
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=56025DCA.2000301@samsung.com \
--to=j.anaszewski@samsung.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=ospite@studenti.unina.it \
--cc=p.meerwald@bct-electronic.com \
--cc=pavel@ucw.cz \
--cc=ricardo.ribalda@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=stsp@users.sourceforge.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.