1 --- orig/kernel-source/drivers/leds/led-class.c 2008-12-25 01:26:37.000000000 +0200
2 +++ kernel-source/drivers/leds/led-class.c 2010-04-16 15:43:04.000000000 +0300
4 #include <linux/leds.h>
7 +#define LED_FLAG_DBRIGHTNESS 0x100
9 static struct class *leds_class;
11 static void led_update_brightness(struct led_classdev *led_cdev)
13 unsigned long state = simple_strtoul(buf, &after, 10);
14 size_t count = after - buf;
16 + if (led_cdev->flags & LED_FLAG_DBRIGHTNESS)
19 if (*after && isspace(*after))
23 static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
26 +static ssize_t led_dbrightness_show(struct device *dev,
27 + struct device_attribute *attr, char *buf)
29 + struct led_classdev *led_cdev = dev_get_drvdata(dev);
31 + if (!(led_cdev->flags & LED_FLAG_DBRIGHTNESS))
32 + return sprintf(buf, "-1\n");
34 + /* no lock needed for this */
35 + led_update_brightness(led_cdev);
37 + return sprintf(buf, "%u\n", led_cdev->brightness);
40 +static ssize_t led_dbrightness_store(struct device *dev,
41 + struct device_attribute *attr, const char *buf, size_t size)
43 + struct led_classdev *led_cdev = dev_get_drvdata(dev);
44 + ssize_t ret = -EINVAL;
46 + unsigned long state = simple_strtol(buf, &after, 10);
47 + size_t count = after - buf;
50 + led_cdev->flags &= ~LED_FLAG_DBRIGHTNESS;
54 + if (*after && isspace(*after))
57 + if (count == size) {
60 + led_cdev->flags |= LED_FLAG_DBRIGHTNESS;
61 + if (state == LED_OFF)
62 + led_trigger_remove(led_cdev);
63 + led_set_brightness(led_cdev, state);
69 +static DEVICE_ATTR(dbrightness, 0644, led_dbrightness_show, led_dbrightness_store);
72 * led_classdev_suspend - suspend an led_classdev.
73 * @led_cdev: the led_classdev to suspend.
78 + rc = device_create_file(led_cdev->dev, &dev_attr_dbrightness);
80 + goto err_out_dbrightness;
82 #ifdef CONFIG_LEDS_TRIGGERS
83 init_rwsem(&led_cdev->trigger_lock);
87 #ifdef CONFIG_LEDS_TRIGGERS
89 - device_remove_file(led_cdev->dev, &dev_attr_brightness);
90 + device_remove_file(led_cdev->dev, &dev_attr_dbrightness);
91 list_del(&led_cdev->node);
94 + device_remove_file(led_cdev->dev, &dev_attr_brightness);
96 device_unregister(led_cdev->dev);