Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753251AbbHTOoz (ORCPT ); Thu, 20 Aug 2015 10:44:55 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:48213 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751738AbbHTOow (ORCPT ); Thu, 20 Aug 2015 10:44:52 -0400 X-AuditID: cbfee61a-f79a06d000005c6f-14-55d5e7e3da2c From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jacek Anaszewski , Andrew Lunn , Sakari Ailus , Pavel Machek , Stas Sergeev Subject: [PATCH/RFC v6 04/36] leds: Add an internal led_set_brightness_nosleep function Date: Thu, 20 Aug 2015 16:43:34 +0200 Message-id: <1440081846-11697-5-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1440081846-11697-1-git-send-email-j.anaszewski@samsung.com> References: <1440081846-11697-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsVy+t9jAd3Hz6+GGmxcyGdx/u4hZoveq88Z LS7vmsNmsfXNOkaLu6eOsll82vKNyaKzbxqLA7vHvJOBHjt3fGby6NuyitFjxerv7B5Np9pZ PT5vkgtgi+KySUnNySxLLdK3S+DK6J9+g6ngk2DF/FNf2BsY3/F1MXJwSAiYSMw5rtvFyAlk iklcuLeerYuRi0NIYCmjxLGr69ghnJ+MEneXH2UDqWITMJT4+eI1E4gtImAj0TtjEpjNLHCM UeLn3mgQW1ggUmLNqx5WEJtFQFXi8dXTLCDLeAU8JP68ioTYqyAxZ5INSAWngKfEvPlf2UFs IaCKF++3ME9g5F3AyLCKUSK1ILmgOCk91zAvtVyvODG3uDQvXS85P3cTIzi8nkntYDy4y/0Q owAHoxIP7wXhq6FCrIllxZW5hxglOJiVRHhvPQMK8aYkVlalFuXHF5XmpBYfYpTmYFES55Xd sDlUSCA9sSQ1OzW1ILUIJsvEwSnVwHjh+7HXnXWmNZ2NX/OtxNnvaXzY4Vs2R1+gNIyhP+DF f0GV2W63O0rXr9Cvc+5/JGry5WSlmkLMGt/VsaGHgx55x6sH/Du1I7vP8oJWKUPsgsALntE1 yy+Vcf5N2z/rfvxaHou/She3XheQS4iZdTmCx2XdorNL+6PtgzJj1uUu+uj/13OjnRJLcUai oRZzUXEiAP9sDWsrAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2463 Lines: 77 This patch adds led_set_brightness_nosleep function. It guarantees setting LED brightness in a non-blocking way. Signed-off-by: Jacek Anaszewski Cc: Andrew Lunn Cc: Sakari Ailus Cc: Pavel Machek Cc: Stas Sergeev --- 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 + * Author: Jacek Anaszewski * * 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/