lkml.org 
[lkml]   [2022]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4 4/6] leds: class: store the color index in struct led_classdev
On Fri, Oct 7, 2022 at 6:03 PM Jean-Jacques Hiblot
<jjhiblot@traphandler.com> 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

\
 
 \ /
  Last update: 2022-10-07 18:27    [W:0.062 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site