Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964834AbbGQJP6 (ORCPT ); Fri, 17 Jul 2015 05:15:58 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:58419 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751706AbbGQIrw (ORCPT ); Fri, 17 Jul 2015 04:47:52 -0400 X-AuditID: cbfee61b-f79416d0000014c0-87-55a8c136aa07 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 01/51] leds: Add led_set_brightness_sync to the public LED subsystem API Date: Fri, 17 Jul 2015 10:46:47 +0200 Message-id: <1437122857-6765-2-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1437122857-6765-1-git-send-email-j.anaszewski@samsung.com> References: <1437122857-6765-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFLMWRmVeSWpSXmKPExsVy+t9jAV2zgytCDb6tlrE4f/cQs8XRnROZ LHqvPme0uLxrDpvF1jfrGC3unjrKZrF711NWi09bvjFZdPZNY3Hg9Ng56y67x7yTgR47d3xm 8tgz/werR9+WVYweK1Z/Z/doOtXO6vF5k1wARxSXTUpqTmZZapG+XQJXRt+1uWwF78Urpm5h bWB8LNzFyMkhIWAi8e/XNRYIW0ziwr31bF2MXBxCAosYJc5t3cwK4fxklNjx5BQ7SBWbgKHE zxevmboYOThEBOQkdp6pBKlhFvjHKDHr1VM2kBphgTiJA6d/MYHYLAKqEi0Hm1lBbF4Bd4kT 5yewgvRKCChIzJlkAxLmFPCQeP9gJdgRQkAlbX8usk1g5F3AyLCKUTS1ILmgOCk910ivODG3 uDQvXS85P3cTIzgEn0nvYFzVYHGIUYCDUYmHt8F1RagQa2JZcWXuIUYJDmYlEd7KnUAh3pTE yqrUovz4otKc1OJDjNIcLErivCfzfUKFBNITS1KzU1MLUotgskwcnFINjNUu7H4XOyZs7V9+ cMJyiXffL+7Y3dky5/Ha6Qm7rCf8kSjSTpBTSmBV37UsZImDq7H6A62YzWyneFfPW3FCZsNh 9SMTVvgI/zlv5WTJk+eTkurRZW9wTEH62Lot0adiCnf4d6zfPDFRSkBQa0XYsmeyP87/qZxu sy7p6uPM5ZvUXe+oJQXs2qXEUpyRaKjFXFScCACq2g0ePQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3211 Lines: 94 led_set_brightness_sync function was visible only internally to the LED subsystem. It is now being made publicly available since it has become apparent that this is a caller who should decide whether brightness is to be set in a synchronous or an asynchronous way. The function is modified to use brightness_set op as the second option if brightness_set_sync is not implemented. Eventually all LED subsystem drivers will be modfified to set brightness only in a synchronous way with use of brightness_set op and brightness_set_sync op will be removed. LED core will take care of calling brightness_set op asynchronously if needed. Signed-off-by: Jacek Anaszewski Cc: Bryan Wu Cc: Andrew Lunn Cc: Sakari Ailus Cc: Pavel Machek Cc: Stas Sergeev --- drivers/leds/leds.h | 13 ------------- include/linux/leds.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index bc89d7a..1c026c9 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -26,19 +26,6 @@ static inline void led_set_brightness_async(struct led_classdev *led_cdev, led_cdev->brightness_set(led_cdev, value); } -static inline int led_set_brightness_sync(struct led_classdev *led_cdev, - enum led_brightness value) -{ - int ret = 0; - - led_cdev->brightness = min(value, led_cdev->max_brightness); - - if (!(led_cdev->flags & LED_SUSPENDED)) - ret = led_cdev->brightness_set_sync(led_cdev, - led_cdev->brightness); - return ret; -} - 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 b122eea..31d9ebf 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -160,6 +160,35 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev, */ extern void led_set_brightness(struct led_classdev *led_cdev, enum led_brightness brightness); + +/** + * led_set_brightness_sync - set LED brightness synchronously + * @led_cdev: the LED to set + * @brightness: the brightness to set it to + * + * Set an LED's brightness immediately. This function will block + * the caller for the time required for accessing device register, + * and it can sleep. + */ +static inline int led_set_brightness_sync(struct led_classdev *led_cdev, + enum led_brightness value) +{ + int ret = 0; + + led_cdev->brightness = min(value, led_cdev->max_brightness); + + if (led_cdev->flags & LED_SUSPENDED) + return 0; + + if (led_cdev->brightness_set_sync) + ret = led_cdev->brightness_set_sync(led_cdev, + led_cdev->brightness); + else + led_cdev->brightness_set(led_cdev, led_cdev->brightness); + + return ret; +} + /** * led_update_brightness - update LED brightness * @led_cdev: the LED to query -- 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/