lkml.org 
[lkml]   [2015]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH/RFC v5 05/57] leds: Add an internal led_set_brightness_nosleep function
Date
This patch adds led_set_brightness_nosleep function. It guarantees setting
LED brightness in a non-blocking way.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Bryan Wu <cooloney@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Stas Sergeev <stsp@users.sourceforge.net>
---
drivers/leds/leds.h | 22 ++++++++++++++++++++++
include/linux/leds.h | 2 +-
2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index f700400..308f60f 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@openedhand.com>
+ * Author: Jacek Anaszewski <j.anaszewski@samsung.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
@@ -39,6 +41,26 @@ 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)
+{
+ int ret;
+
+ /*
+ * Drivers that implement brightness_set_nonblocking op are guaranteed
+ * not to sleep while setting brightness.
+ */
+ if (led_cdev->brightness_set_nonblocking) {
+ ret = led_set_brightness_sync(led_cdev, value);
+ if (ret < 0)
+ dev_err(led_cdev->dev,
+ "cannot set led brightness %d\n", ret);
+ return;
+ }
+
+ 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 a004e84..9603a73 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -52,7 +52,7 @@ struct led_classdev {
#define LED_BLINK_DISABLE (1 << 25)

/* Set LED brightness level */
- /* Must not sleep, use a workqueue if needed */
+ /* Intended for drivers that may set brightness in a blocking way. */
void (*brightness_set)(struct led_classdev *led_cdev,
enum led_brightness brightness);
/* Intended for drivers that set brightness in a non-blocking way */
--
1.7.9.5


\
 
 \ /
  Last update: 2015-08-11 12:21    [W:0.186 / U:2.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site