Re: [PATCH] leds: driver for ab5500 high voltage leds

From: Linus Walleij
Date: Wed Dec 07 2011 - 09:16:07 EST


On Sat, Dec 3, 2011 at 10:49 PM, Mark Brown
<broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> On Fri, Dec 02, 2011 at 02:56:22PM +0100, Linus Walleij wrote:
>
>> +What:                /sys/class/leds/<led>/led_current
>> +Date:                December 2011
>> +KernelVersion:       3.3
>> +Contact:     Shreshtha Kumar SAHU <shreshthakumar.sahu@xxxxxxxxxxxxxx>
>> +Description:
>> +             Read and set the current limit for the LED. Value in
>> +             milliampere.
>
> This sounds like a platform data thing - normally if you get a current
> limit wrong you're heading for magic smoke so it's not something you
> want to be playing with at runtime from userspace.

There is a platform thing, it sets the upper limit for the
current:

+/**
+ * struct ab5500_led
+ * @id: hvled index
+ * @max_current: max current permitted for hvled instance
+ * @brt_val: brightness value set for hvled
+ * @fade_hi: fadeout time high bits
+ * @fade_lo: fadeout time low bits
+ * @led_on: led is on
+ * @led_cdev: hvled class device
+ * @led_work: work to set the brightness of hvled
+ */
+struct ab5500_led {
+ u8 id;
+ u8 max_current;
+ u16 brt_val;
+ u16 fade_hi;
+ u16 fade_lo;
+ bool led_on;
+ struct led_classdev led_cdev;
+ struct work_struct led_work;
+};

Here max_current is the max current allowed by the platform.

Then in the sysfs interface:

+ if (led_curr > led->max_current)
+ led_curr = led->max_current;

You are only allowed to set a lower value than the max value.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/