Hi Marek,

On 3/24/21 5:34 PM, Marek Behun wrote:
>> +#include <linux/err.h>
>> +#include <linux/gpio.h>
>> +#include <linux/gpio/consumer.h>
>> +#include <linux/kernel.h>
>> +#include <linux/leds.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_gpio.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/property.h>
>> +#include <linux/slab.h>
> Why do you include slab.h?
Yeah, I will clean it in next commit.
>> +
>> +
>> +static void multi_gpio_led_set(struct led_classdev *led_cdev,
>> +    enum led_brightness value)
>> +{
>> +    struct multi_gpio_led_priv *priv;
>> +    int idx;
>> +
>> +    DECLARE_BITMAP(values, MAX_GPIO_NUM);
>> +
>> +    priv = container_of(led_cdev, struct multi_gpio_led_priv, cdev);
>> +
>> +    idx = (value - LED_OFF) * priv->nr_states / (LED_FULL + 1);
> LED_FULL / LED_OFF are deprecated, don't use them.

Then could I use just 0 (instead LED_OFF) and led_cdev->max_brightness

(instead of LED_FULL) here? The idea here is map the states defined in dts

to the full brightness range.

> +
> +     priv->nr_states = ret;
> +     priv->states = devm_kzalloc(dev, sizeof(*priv->states) * 
> priv->nr_states, GFP_KERNEL);
> +     if (!priv->states)
> +             return -ENOMEM;
> +
> +     ret = of_property_read_u8_array(node, "led-states", priv->states, 
> priv->nr_states);
> +     if (ret)
> +             return ret;
> +
> +     priv->cdev.max_brightness = LED_FULL;
> ???? max_brightness is not 255 (= LED_FULL). max_brightness must be
> derived from the led-states property.

Yeah, I will fix this. the max-brightness should for the whole LED,
right? So

it will at same level with led-states.



Reply via email to