Private
Public Access
2
0

led: Fix and cleanup initialization

The structure returned by readdir is may be statically allocated.
Keeping a pointer to it is broken.

The LED path is generally not a directory, it's a link to a directory.
And even if it were a directory, that would tell nothing about the
caller's access permissions.

And then there is a lot of duplication between mraa_led_init and
mraa_led_init_raw.

This addresses that all.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka
2021-02-04 18:12:42 +01:00
committed by Tom Ingleby
parent 13ce6ea446
commit 954b17ded4
2 changed files with 25 additions and 38 deletions

View File

@@ -273,8 +273,7 @@ struct _iio {
struct _led {
/*@{*/
int count; /**< total LED count in a platform */
char *led_name; /**< LED name */
char led_path[64]; /**< sysfs path of the LED */
const char *led_path; /**< sysfs path of the LED */
int trig_fd; /**< trigger file descriptor */
int bright_fd; /**< brightness file descriptor */
int max_bright_fd; /**< maximum brightness file descriptor */