From 2ecb6e654e324d168649877a8349185004fd8b72 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 20 Jul 2020 20:22:13 +0200 Subject: [PATCH] Cleanups --- led/drivers/led_overlay.c | 12 +----------- led/drivers/led_rpi.c | 39 ++++++++------------------------------- led/led_driver.c | 4 ---- 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/led/drivers/led_overlay.c b/led/drivers/led_overlay.c index 4c22e3b177..6f6c0ffce4 100644 --- a/led/drivers/led_overlay.c +++ b/led/drivers/led_overlay.c @@ -6,8 +6,6 @@ #include "../../configuration.h" #include "../../retroarch.h" -#include "../../verbosity.h" - typedef struct { @@ -15,6 +13,7 @@ typedef struct int map[MAX_LEDS]; } overlayled_t; +/* TODO/FIXME - static globals */ static overlayled_t curins; static overlayled_t *cur = &curins; @@ -23,13 +22,10 @@ static void overlay_init(void) int i; settings_t *settings = config_get_ptr(); - RARCH_LOG("[LED]: overlay LED driver init\n"); - for (i = 0; i < MAX_LEDS; i++) { cur->setup[i] = 0; cur->map[i] = settings->uints.led_map[i]; - RARCH_LOG("[LED]: overlay map[%d]=%d\n",i,cur->map[i]); if (cur->map[i] >= 0) input_overlay_set_visibility(cur->map[i], @@ -39,17 +35,13 @@ static void overlay_init(void) static void overlay_free(void) { - RARCH_LOG("[LED]: overlay LED driver free\n"); } static void overlay_set(int led, int state) { int gpio = 0; if ((led < 0) || (led >= MAX_LEDS)) - { - RARCH_WARN("[LED]: invalid led %d\n", led); return; - } gpio = cur->map[led]; @@ -59,8 +51,6 @@ static void overlay_set(int led, int state) input_overlay_set_visibility(gpio, state ? OVERLAY_VISIBILITY_VISIBLE : OVERLAY_VISIBILITY_HIDDEN); - - RARCH_LOG("[LED]: set visibility %d %d\n", gpio, state); } const led_driver_t overlay_led_driver = { diff --git a/led/drivers/led_rpi.c b/led/drivers/led_rpi.c index 481e07a94c..3b5e1bdf04 100644 --- a/led/drivers/led_rpi.c +++ b/led/drivers/led_rpi.c @@ -18,7 +18,6 @@ #include "../led_defines.h" #include "../../configuration.h" -#include "../../verbosity.h" typedef struct { @@ -26,6 +25,7 @@ typedef struct int map[MAX_LEDS]; } rpiled_t; +/* TODO/FIXME - static globals */ static rpiled_t curins; static rpiled_t *cur = &curins; @@ -41,7 +41,6 @@ static void rpi_init(void) { cur->setup[i] = 0; cur->map[i] = settings->uints.led_map[i]; - RARCH_LOG("[LED]: rpi map[%d]=%d\n", i, cur->map[i]); } } @@ -56,11 +55,9 @@ static int set_gpio(int gpio, int value) snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/value", gpio); fp = fopen(buf, "w"); - if(!fp) - { - RARCH_WARN("[LED]: failed to set GPIO %d\n", gpio); + /* Failed to set GPIO? */ + if (!fp) return -1; - } fprintf(fp, "%d\n", value ? 1 : 0); fclose(fp); @@ -79,11 +76,9 @@ static int setup_gpio(int gpio) snprintf(buf, sizeof(buf), "/sys/class/gpio/export"); fp = fopen(buf, "w"); - if(!fp) - { - RARCH_WARN("[LED]: failed to export GPIO %d\n", gpio); + /* Failed to export GPIO? */ + if (!fp) return -1; - } fprintf(fp,"%d\n", gpio); fclose(fp); @@ -92,12 +87,9 @@ static int setup_gpio(int gpio) fp = fopen(buf, "w"); } - if(!fp) - { - RARCH_WARN("[LED]: failed to set direction GPIO %d\n", - gpio); + /* Failed to set direction GPIO? */ + if (!fp) return -1; - } fprintf(fp, "out\n"); fclose(fp); @@ -108,33 +100,18 @@ static void rpi_set(int led, int state) { int gpio = 0; + /* Invalid LED? */ if((led < 0) || (led >= MAX_LEDS)) - { - RARCH_WARN("[LED]: invalid led %d\n", led); return; - } gpio = cur->map[led]; if(gpio <= 0) return; if(cur->setup[led] == 0) - { - RARCH_LOG("[LED]: rpi setup led %d gpio %d\n", - led, gpio, state); cur->setup[led] = setup_gpio(gpio); - if(cur->setup[led] <= 0) - { - RARCH_WARN("[LED]: failed to setup led %d gpio %d\n", - led, gpio); - } - } if(cur->setup[led] > 0) - { - RARCH_LOG("[LED]: rpi LED driver set led %d gpio %d = %d\n", - led, gpio, state); set_gpio(gpio, state); - } } const led_driver_t rpi_led_driver = { diff --git a/led/led_driver.c b/led/led_driver.c index bfc84c6585..3cd4b61fb7 100644 --- a/led/led_driver.c +++ b/led/led_driver.c @@ -16,7 +16,6 @@ #include #include "led_driver.h" -#include "../verbosity.h" static const led_driver_t *current_led_driver = NULL; @@ -50,9 +49,6 @@ void led_driver_init(const char *led_driver) current_led_driver = &rpi_led_driver; #endif - RARCH_LOG("[LED]: LED driver = '%s' %p\n", - drivername, current_led_driver); - if (current_led_driver) (*current_led_driver->init)(); }