From d039b5348443173f5847dc790d19027b3fb11b7b Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Mon, 7 Sep 2020 20:24:25 +0100 Subject: [PATCH] e sys babcklight - streamline setting bl_power --- src/bin/system/e_system_backlight.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/bin/system/e_system_backlight.c b/src/bin/system/e_system_backlight.c index bb5ee7a56..00d68175e 100644 --- a/src/bin/system/e_system_backlight.c +++ b/src/bin/system/e_system_backlight.c @@ -22,17 +22,6 @@ _light_set(Light *lig, int val) #ifdef HAVE_EEZE char buf[PATH_MAX]; int fd; - if (val == 0) - { - snprintf(buf, sizeof(buf), "%s/bl_power", lig->dev); - fd = open(buf, O_WRONLY); - if (fd >= 0) - { - if (write(fd, "4", 1) <= 0) - ERR("Write failed of [%s] to [%s]\n", "4", buf); - close(fd); - } - } snprintf(buf, sizeof(buf), "%s/brightness", lig->dev); fd = open(buf, O_WRONLY); if (fd >= 0) @@ -43,16 +32,16 @@ _light_set(Light *lig, int val) ERR("Write failed of [%s] to [%s]\n", buf2, buf); close(fd); } - if (val != 0) + snprintf(buf, sizeof(buf), "%s/bl_power", lig->dev); + fd = open(buf, O_WRONLY); + if (fd >= 0) { - snprintf(buf, sizeof(buf), "%s/bl_power", lig->dev); - fd = open(buf, O_WRONLY); - if (fd >= 0) - { - if (write(fd, "0", 1) <= 0) - ERR("Write failed of [%s] to [%s]\n", "0", buf); - close(fd); - } + int ret; + + if (val == 0) ret = write(fd, "4", 1); + else ret = write(fd, "0", 1); + if (ret < 0) ERR("Write failed to [%s]\n", buf); + close(fd); } #elif defined(__FreeBSD_kernel__) sysctlbyname(lig->dev, NULL, NULL, &(lig->val), sizeof(lig->val));