Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932116AbbGCNO1 (ORCPT ); Fri, 3 Jul 2015 09:14:27 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:49392 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755173AbbGCNOV (ORCPT ); Fri, 3 Jul 2015 09:14:21 -0400 X-AuditID: cbfee61a-f79516d000006302-6d-55968aa9f126 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, pavel@ucw.cz, sakari.ailus@linux.intel.com, andreas.werner@men.de, andrew@lunn.ch, ospite@studenti.unina.it, anemo@mba.ocn.ne.jp, ben@simtec.co.uk, bootc@bootc.net, dmurphy@ti.com, daniel.jeong@ti.com, daniel@zonque.org, davem@davemloft.net, fabio.baltieri@gmail.com, balbi@ti.com, florian@openwrt.org, gshark.jeong@gmail.com, g.liakhovetski@gmx.de, ingi2.kim@samsung.com, dl9pf@gmx.de, johan@kernel.org, lenz@cs.wisc.edu, jogo@openwrt.org, q1.kim@samsung.com, kris@krisk.org, kristoffer.ericson@gmail.com, linus.walleij@linaro.org, broonie@kernel.org, michael.hennerich@analog.com, milo.kim@ti.com, nm127@freemail.hu, ncase@xes-inc.com, neilb@suse.de, nick.forbes@incepta.com, lost.distance@yahoo.com, p.meerwald@bct-electronic.com, n0-1@freewrt.org, philippe.retornaz@epfl.ch, raph@8d.com, rpurdie@openedhand.com, rod@whitby.id.au, dave@sr71.net, giometti@linux.it, bigeasy@linutronix.de, shuahkhan@gmail.com, sguinot@lacie.com, kyungmin.park@samsung.com, Jacek Anaszewski Subject: [PATCH/RFC v3 3/7] leds: Add an internal led_set_brightness_nosleep function Date: Fri, 03 Jul 2015 15:10:48 +0200 Message-id: <1435929052-8736-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1435929052-8736-1-git-send-email-j.anaszewski@samsung.com> References: <1435929052-8736-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSe0yTVxjGPd93vgvNas6Kl7O6GFMvMV5QojFvjHP4h/HEmMWpxEQIW9VP NHJLq0SIyaBqBsWVS7WL2AGiwAoGwlWuUUuqQkFQLAoK3qg6Bjh1IqUbmrL53y/P87zv888j 85oLglY+FHdEMcTpY3SiCrunnpOVDrMtfHWXaQFktGRh6Bpw8lBk3QXXH/8EJe53GGx3cni4 7NoMZ58OieBqyOaguc7Lg+nfYQypjqsc2LtOYjjjtwuQ4a4R4MTEARh/3YHhdWUeB1f6p3iw NpkFqO/7W4RfPC8RPCxvF8H04LQAvuo0CfLaKHSaRiRwtTYKcOafEg56Gu0i1I6UI5iw1ImQ 1VotQclkOYaxMT8Gb+Z1CVryUzB86PzIw0i9WwB/RhMGi/MrGGh3idDT6cJQ+SyXA29HP4Kb t9o48LU84aGp0SvA25pxDiqGVPDeFwbpFhsOW8s+VhciNuzZxH4fHODYO0cxZp7JUp7VOPo4 VnyqjGeX0iYk9v7tsMQacgck9tebKJZXdI1nVaXpIrP2nhaYo+cJxx71Novbl+xRbdivxBxK VAyrNv6oOliVf0lMyPryWPqNfikF+dVmFCRTspamWs6j/3gO7R6sEM1IJWtIIaIvcgqlgKEh PkQL7DsCLJJQ6nv1J2dGsjyLzKcNHUmBPE/GZFrgaJ1+FEx203u/esUAY7KYZnjap3U12ULb Rjw4cEvJAmrP2RCQgwijv02m/V+1hdalVqAspC5AM0rRbCVhX4Jxb3RsaIhRH2s8Ghcdsi8+ tgpND+eFth45UsCJiIx0X6i73WfDNYI+0ZgU60RU5nWz1C932sI16v36pGTFEP+D4WiMYnSi eTLWzVW3xW8L15Bo/RHlsKIkKIbPLicHaVNQsCZq81Tl1xdtx/uzV962rKjZtdVzt/lY9nej chRxje8JUm0r7U2W1o8nF6UtIsndVf6Q4rujC2eC9Vxm5Pm4UydH/1CWf3t/3c+7XYNLoxda TSSxVjskhDVkLl1xomy0qaRj7JtlkRHV23POrR7Wft9liZg/cw3f1162tyyp9mlwrg4bD+pD l/EGo/4T12z+HDQDAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2371 Lines: 71 This patch adds led_set_brightness_nosleep function as well as LED_BRIGHTNESS_FAST flag. The flag, when set by a driver means that its brightness_set op is guaranteed not to sleep. Basing on this information the function decides whether brightness should be set in an asynchronous or synchronous way. Signed-off-by: Jacek Anaszewski --- drivers/leds/leds.h | 18 ++++++++++++++++++ include/linux/leds.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index ca38f6a..6c56142 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 @@ -23,6 +25,22 @@ 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) +{ + if (led_cdev->flags & LED_BRIGHTNESS_FAST) { + led_set_brightness_sync(led_cdev, value); + return; + } + + /* + * Delegate setting brightness to a work queue task only for slow + * LEDs as the FAST ones are guaranteed not to sleep while setting + * brightness. + */ + 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 bf4a938..a982626 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -49,6 +49,7 @@ struct led_classdev { #define SET_BRIGHTNESS_SYNC (1 << 22) #define LED_DEV_CAP_FLASH (1 << 23) #define LED_BLINK_DISABLE (1 << 24) +#define LED_BRIGHTNESS_FAST (1 << 25) /* Set LED brightness level */ /* Must not sleep, use a workqueue if needed */ -- 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/