lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1440081846-11697-5-git-send-email-j.anaszewski@samsung.com>
Date:	Thu, 20 Aug 2015 16:43:34 +0200
From:	Jacek Anaszewski <j.anaszewski@...sung.com>
To:	linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:	Jacek Anaszewski <j.anaszewski@...sung.com>,
	Andrew Lunn <andrew@...n.ch>,
	Sakari Ailus <sakari.ailus@...ux.intel.com>,
	Pavel Machek <pavel@....cz>,
	Stas Sergeev <stsp@...rs.sourceforge.net>
Subject: [PATCH/RFC v6 04/36] leds: Add an internal led_set_brightness_nosleep
 function

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@...sung.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: Pavel Machek <pavel@....cz>
Cc: Stas Sergeev <stsp@...rs.sourceforge.net>
---
 drivers/leds/led-core.c |   21 +++++++++++++++++++++
 drivers/leds/leds.h     |    4 ++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index b69271f..0200407 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -114,6 +114,27 @@ void led_stop_software_blink(struct led_classdev *led_cdev)
 }
 EXPORT_SYMBOL_GPL(led_stop_software_blink);
 
+void led_set_brightness_nosleep(struct led_classdev *led_cdev,
+				enum led_brightness value)
+{
+	int ret;
+
+	/*
+	 * Drivers that implement brightness_set op are guaranteed
+	 * not to sleep while setting brightness.
+	 */
+	if (led_cdev->brightness_set) {
+		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);
+}
+EXPORT_SYMBOL_GPL(led_set_brightness_nosleep);
+
 void led_set_brightness(struct led_classdev *led_cdev,
 			enum led_brightness brightness)
 {
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index ca38f6a..cd251be 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
@@ -28,6 +30,8 @@ static inline int led_get_brightness(struct led_classdev *led_cdev)
 	return led_cdev->brightness;
 }
 
+void led_set_brightness_nosleep(struct led_classdev *led_cdev,
+				enum led_brightness value);
 void led_stop_software_blink(struct led_classdev *led_cdev);
 
 extern struct rw_semaphore leds_list_lock;
-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ