Re: [PATCH v4 4/6] leds: class: store the color index in struct led_classdev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 7, 2022 at 6:03 PM Jean-Jacques Hiblot
<jjhiblot@xxxxxxxxxxxxxxx> wrote:
>
> This information might be useful for more than only deriving the led's
> name.
> And since we have this information, we can expose it in the sysfs.

Not sure why you haven't continued a new sentence on the previous line.

...

> +static ssize_t color_show(struct device *dev,
> +               struct device_attribute *attr, char *buf)
> +{
> +       const char *color_text = "invalid";
> +       struct led_classdev *led_cdev = dev_get_drvdata(dev);
> +
> +       if (led_cdev->color < LED_COLOR_ID_MAX)
> +               color_text = led_colors[led_cdev->color];

> +       return sprintf(buf, "%s\n", color_text);

According to the Documentation you must use sysfs_emit() here. It
might be good to update existing code as well (as a separate change).

> +}
> +static DEVICE_ATTR_RO(color);


-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux