diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2015-11-22 18:16:24 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2015-11-24 00:06:43 +0100 |
commit | d08a5b042edb527f7572d550068bd77786a880f5 (patch) | |
tree | 421a849f2da099145418e90ef84bbc0b063133a7 | |
parent | 8485761da3ea9a8a9fb56252c0a86dcae23d93ea (diff) |
backports: add led_set_brightness_sync()
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r-- | backport/backport-include/linux/leds.h | 18 | ||||
-rw-r--r-- | backport/compat/Makefile | 1 | ||||
-rw-r--r-- | backport/compat/backport-4.5.c | 33 |
3 files changed, 52 insertions, 0 deletions
diff --git a/backport/backport-include/linux/leds.h b/backport/backport-include/linux/leds.h index 2044abfd..d6e2cef1 100644 --- a/backport/backport-include/linux/leds.h +++ b/backport/backport-include/linux/leds.h @@ -38,6 +38,24 @@ static inline void led_trigger_remove(struct led_classdev *led_cdev) {} #endif #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0) && \ + LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) +#define netif_tx_napi_add LINUX_BACKPORT(netif_tx_napi_add) +/** + * 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 registers, + * and it can sleep. + * + * Returns: 0 on success or negative error value on failure + */ +extern int led_set_brightness_sync(struct led_classdev *led_cdev, + enum led_brightness value); +#endif /* < 4.4 && >= 3.19 */ + #include <backport/leds-disabled.h> #endif /* __BACKPORT_LINUX_LEDS_H */ diff --git a/backport/compat/Makefile b/backport/compat/Makefile index fa992e78..be9e5c6c 100644 --- a/backport/compat/Makefile +++ b/backport/compat/Makefile @@ -30,6 +30,7 @@ compat-$(CPTCFG_KERNEL_4_1) += backport-4.1.o compat-$(CPTCFG_KERNEL_4_2) += backport-4.2.o compat-$(CPTCFG_KERNEL_4_3) += backport-4.3.o compat-$(CPTCFG_KERNEL_4_4) += backport-4.4.o +compat-$(CPTCFG_KERNEL_4_5) += backport-4.5.o compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o compat-$(CPTCFG_BPAUTO_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o diff --git a/backport/compat/backport-4.5.c b/backport/compat/backport-4.5.c new file mode 100644 index 00000000..e8f9b127 --- /dev/null +++ b/backport/compat/backport-4.5.c @@ -0,0 +1,33 @@ +/* + * Copyright(c) 2015 Hauke Mehrtens <hauke@hauke-m.de> + * + * Backport functionality introduced in Linux 4.5. + * + * 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 + * published by the Free Software Foundation. + */ + +#include <linux/leds.h> +#include <linux/export.h> +#include <linux/errno.h> + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) +int led_set_brightness_sync(struct led_classdev *led_cdev, + enum led_brightness value) +{ + if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) + return -EBUSY; + + led_cdev->brightness = min(value, led_cdev->max_brightness); + + if (led_cdev->flags & LED_SUSPENDED) + return 0; + + if (led_cdev->brightness_set_sync) + return led_cdev->brightness_set_sync(led_cdev, + led_cdev->brightness); + return -ENOTSUPP; +} +EXPORT_SYMBOL_GPL(led_set_brightness_sync); +#endif /* >= 3.19 */ |