Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965156AbbHKJxg (ORCPT ); Tue, 11 Aug 2015 05:53:36 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:33652 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934116AbbHKJig (ORCPT ); Tue, 11 Aug 2015 05:38:36 -0400 X-AuditID: cbfee61a-f79a06d000005c6f-ff-55c9c29acd8d From: Jacek Anaszewski To: linux-leds@vger.kernel.org Cc: linux-kernel@vger.kernel.org, cooloney@gmail.com, rpurdie@rpsys.net, stsp@users.sourceforge.net, Jacek Anaszewski , Andrew Lunn , Sakari Ailus , Pavel Machek Subject: [PATCH/RFC v5 05/57] leds: Add an internal led_set_brightness_nosleep function Date: Tue, 11 Aug 2015 11:37:18 +0200 Message-id: <1439285890-27329-6-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1439285890-27329-1-git-send-email-j.anaszewski@samsung.com> References: <1439285890-27329-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsVy+t9jQd1Zh06GGtxepGpx/u4hZoujOycy WfRefc5ocXnXHDaLrW/WMVrcPXWUzWL3rqesFp+2fGOy6OybxuLA6bFz1l12j3knAz127vjM 5LFn/g9Wj74tqxg9Vqz+zu7RdKqd1ePzJrkAjigum5TUnMyy1CJ9uwSujFdfbrMWfBKquPBk BlMD4y7+LkZODgkBE4nprRuYIGwxiQv31rOB2EICsxglzu8M6GLkArJ/MkrM2HyEBSTBJmAo 8fPFa6AGDg4RATmJnWcqQWqYBf4xSsx69RSsWVggUuJXw3dWkBoWAVWJ1gm5IGFeAQ+Jw98f g4UlBBQk5kyyAQlzCnhKXH++iBFirYfE8dlNbBMYeRcwMqxilEgtSC4oTkrPNcxLLdcrTswt Ls1L10vOz93ECA7DZ1I7GA/ucj/EKMDBqMTDK+B5MlSINbGsuDL3EKMEB7OSCG/hVKAQb0pi ZVVqUX58UWlOavEhRmkOFiVxXtkNm0OFBNITS1KzU1MLUotgskwcnFINjBcZr91Umf07w2Wj 5vsGw2hXVd5fts9qT6xfKbpmOusupRI2maPZB+/v8V6Yuij5+r6j8ZOsV76+z7QoRE2gYb/+ ynfWic3sb/tdA3+c+GH5eVsw88kJ1pKFqv03YxmmSlrUx0VP7/155d/Pv9nfbdKr/DPuLrLa IV9V8dRl+55r/2pO3JG6uECJpTgj0VCLuag4EQAklu8XPwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2591 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: Bryan Wu Cc: Andrew Lunn Cc: Sakari Ailus Cc: Pavel Machek Cc: Stas Sergeev --- 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 + * 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 @@ -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 -- 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/