forked from luck/tmp_suning_uos_patched
leds: core: add helpers for calling brightness_set(_blocking)
Add helpers for calling brightness_set(_blocking) allowing to simplify the code and make it better readable. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
This commit is contained in:
parent
2d88a331e4
commit
d4887af9c2
|
@ -25,6 +25,26 @@ EXPORT_SYMBOL_GPL(leds_list_lock);
|
||||||
LIST_HEAD(leds_list);
|
LIST_HEAD(leds_list);
|
||||||
EXPORT_SYMBOL_GPL(leds_list);
|
EXPORT_SYMBOL_GPL(leds_list);
|
||||||
|
|
||||||
|
static int __led_set_brightness(struct led_classdev *led_cdev,
|
||||||
|
enum led_brightness value)
|
||||||
|
{
|
||||||
|
if (!led_cdev->brightness_set)
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
|
led_cdev->brightness_set(led_cdev, value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __led_set_brightness_blocking(struct led_classdev *led_cdev,
|
||||||
|
enum led_brightness value)
|
||||||
|
{
|
||||||
|
if (!led_cdev->brightness_set_blocking)
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
|
return led_cdev->brightness_set_blocking(led_cdev, value);
|
||||||
|
}
|
||||||
|
|
||||||
static void led_timer_function(unsigned long data)
|
static void led_timer_function(unsigned long data)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = (void *)data;
|
struct led_classdev *led_cdev = (void *)data;
|
||||||
|
@ -91,13 +111,10 @@ static void set_brightness_delayed(struct work_struct *ws)
|
||||||
led_cdev->flags &= ~LED_BLINK_DISABLE;
|
led_cdev->flags &= ~LED_BLINK_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (led_cdev->brightness_set)
|
ret = __led_set_brightness(led_cdev, led_cdev->delayed_set_value);
|
||||||
led_cdev->brightness_set(led_cdev, led_cdev->delayed_set_value);
|
if (ret == -ENOTSUPP)
|
||||||
else if (led_cdev->brightness_set_blocking)
|
ret = __led_set_brightness_blocking(led_cdev,
|
||||||
ret = led_cdev->brightness_set_blocking(led_cdev,
|
led_cdev->delayed_set_value);
|
||||||
led_cdev->delayed_set_value);
|
|
||||||
else
|
|
||||||
ret = -ENOTSUPP;
|
|
||||||
if (ret < 0 &&
|
if (ret < 0 &&
|
||||||
/* LED HW might have been unplugged, therefore don't warn */
|
/* LED HW might have been unplugged, therefore don't warn */
|
||||||
!(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) &&
|
!(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) &&
|
||||||
|
@ -236,10 +253,8 @@ void led_set_brightness_nopm(struct led_classdev *led_cdev,
|
||||||
enum led_brightness value)
|
enum led_brightness value)
|
||||||
{
|
{
|
||||||
/* Use brightness_set op if available, it is guaranteed not to sleep */
|
/* Use brightness_set op if available, it is guaranteed not to sleep */
|
||||||
if (led_cdev->brightness_set) {
|
if (!__led_set_brightness(led_cdev, value))
|
||||||
led_cdev->brightness_set(led_cdev, value);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* If brightness setting can sleep, delegate it to a work queue task */
|
/* If brightness setting can sleep, delegate it to a work queue task */
|
||||||
led_cdev->delayed_set_value = value;
|
led_cdev->delayed_set_value = value;
|
||||||
|
@ -270,10 +285,7 @@ int led_set_brightness_sync(struct led_classdev *led_cdev,
|
||||||
if (led_cdev->flags & LED_SUSPENDED)
|
if (led_cdev->flags & LED_SUSPENDED)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (led_cdev->brightness_set_blocking)
|
return __led_set_brightness_blocking(led_cdev, led_cdev->brightness);
|
||||||
return led_cdev->brightness_set_blocking(led_cdev,
|
|
||||||
led_cdev->brightness);
|
|
||||||
return -ENOTSUPP;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(led_set_brightness_sync);
|
EXPORT_SYMBOL_GPL(led_set_brightness_sync);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user