[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1435929052-8736-4-git-send-email-j.anaszewski@samsung.com>
Date: Fri, 03 Jul 2015 15:10:48 +0200
From: Jacek Anaszewski <j.anaszewski@...sung.com>
To: linux-leds@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, cooloney@...il.com,
rpurdie@...ys.net, stsp@...rs.sourceforge.net, pavel@....cz,
sakari.ailus@...ux.intel.com, andreas.werner@....de,
andrew@...n.ch, ospite@...denti.unina.it, anemo@....ocn.ne.jp,
ben@...tec.co.uk, bootc@...tc.net, dmurphy@...com,
daniel.jeong@...com, daniel@...que.org, davem@...emloft.net,
fabio.baltieri@...il.com, balbi@...com, florian@...nwrt.org,
gshark.jeong@...il.com, g.liakhovetski@....de,
ingi2.kim@...sung.com, dl9pf@....de, johan@...nel.org,
lenz@...wisc.edu, jogo@...nwrt.org, q1.kim@...sung.com,
kris@...sk.org, kristoffer.ericson@...il.com,
linus.walleij@...aro.org, broonie@...nel.org,
michael.hennerich@...log.com, milo.kim@...com, nm127@...email.hu,
ncase@...-inc.com, neilb@...e.de, nick.forbes@...epta.com,
lost.distance@...oo.com, p.meerwald@...-electronic.com,
n0-1@...ewrt.org, philippe.retornaz@...l.ch, raph@...com,
rpurdie@...nedhand.com, rod@...tby.id.au, dave@...1.net,
giometti@...ux.it, bigeasy@...utronix.de, shuahkhan@...il.com,
sguinot@...ie.com, kyungmin.park@...sung.com,
Jacek Anaszewski <j.anaszewski@...sung.com>
Subject: [PATCH/RFC v3 3/7] leds: Add an internal led_set_brightness_nosleep
function
This patch adds led_set_brightness_nosleep function as well
as LED_BRIGHTNESS_FAST flag. The flag, when set by a driver
means that its brightness_set op is guaranteed not to sleep.
Basing on this information the function decides whether
brightness should be set in an asynchronous or synchronous
way.
Signed-off-by: Jacek Anaszewski <j.anaszewski@...sung.com>
---
drivers/leds/leds.h | 18 ++++++++++++++++++
include/linux/leds.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index ca38f6a..6c56142 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -2,8 +2,10 @@
* LED Core
*
* Copyright 2005 Openedhand Ltd.
+ * Copyright 2014, 2015 Samsung Electronics Co., Ltd.
*
* Author: Richard Purdie <rpurdie@...nedhand.com>
+ * Author: Jacek Anaszewski <j.anaszewski@...sung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -23,6 +25,22 @@ static inline void led_set_brightness_async(struct led_classdev *led_cdev,
schedule_work(&led_cdev->set_brightness_work);
}
+static inline void led_set_brightness_nosleep(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ if (led_cdev->flags & LED_BRIGHTNESS_FAST) {
+ led_set_brightness_sync(led_cdev, value);
+ return;
+ }
+
+ /*
+ * Delegate setting brightness to a work queue task only for slow
+ * LEDs as the FAST ones are guaranteed not to sleep while setting
+ * brightness.
+ */
+ led_set_brightness_async(led_cdev, value);
+}
+
static inline int led_get_brightness(struct led_classdev *led_cdev)
{
return led_cdev->brightness;
diff --git a/include/linux/leds.h b/include/linux/leds.h
index bf4a938..a982626 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -49,6 +49,7 @@ struct led_classdev {
#define SET_BRIGHTNESS_SYNC (1 << 22)
#define LED_DEV_CAP_FLASH (1 << 23)
#define LED_BLINK_DISABLE (1 << 24)
+#define LED_BRIGHTNESS_FAST (1 << 25)
/* Set LED brightness level */
/* Must not sleep, use a workqueue if needed */
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists