diff options
-rw-r--r-- | drivers/leds/led-class.c | 9 | ||||
-rw-r--r-- | include/linux/leds.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index a8dd59ebedf8..ac05a928f764 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -24,6 +24,12 @@ static struct class *leds_class; +static void led_update_brightness(struct led_classdev *led_cdev) +{ + if (led_cdev->brightness_get) + led_cdev->brightness = led_cdev->brightness_get(led_cdev); +} + static ssize_t led_brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -31,6 +37,7 @@ static ssize_t led_brightness_show(struct device *dev, ssize_t ret = 0; /* no lock needed for this */ + led_update_brightness(led_cdev); sprintf(buf, "%u\n", led_cdev->brightness); ret = strlen(buf) + 1; @@ -113,6 +120,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) list_add_tail(&led_cdev->node, &leds_list); up_write(&leds_list_lock); + led_update_brightness(led_cdev); + #ifdef CONFIG_LEDS_TRIGGERS init_rwsem(&led_cdev->trigger_lock); diff --git a/include/linux/leds.h b/include/linux/leds.h index c195a674b6ca..ff1570f97045 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -37,6 +37,8 @@ struct led_classdev { /* Set LED brightness level */ void (*brightness_set)(struct led_classdev *led_cdev, enum led_brightness brightness); + /* Get LED brightness level */ + enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); /* Activate hardware accelerated blink */ int (*blink_set)(struct led_classdev *led_cdev, |