]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/baylibre-acme/gpio.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / baylibre-acme / gpio.c
index cbabcf7f97e53974e6566eb87ae34e01f75014d0..d86d24113b9b3c7fe647a4f1733f64f4d0f3feee 100644 (file)
@@ -64,6 +64,10 @@ SR_PRIV int sr_gpio_export(unsigned gpio)
        if (exported)
                return 0; /* Already exported. */
 
+       status = sr_gpio_set_direction(gpio, GPIO_DIR_OUT);
+       if (status < 0)
+               return status;
+
        buf = g_string_sized_new(16);
        g_string_printf(buf, "%u\n", gpio);
        status = open_and_write("/sys/class/gpio/export", buf->str);
@@ -143,10 +147,6 @@ SR_PRIV int sr_gpio_setval_export(int gpio, int value)
        if (status < 0)
                return status;
 
-       status = sr_gpio_set_direction(gpio, GPIO_DIR_OUT);
-       if (status < 0)
-               return status;
-
        status = sr_gpio_set_value(gpio, value);
        if (status < 0)
                return status;
@@ -162,9 +162,5 @@ SR_PRIV int sr_gpio_getval_export(int gpio)
        if (status < 0)
                return status;
 
-       status = sr_gpio_set_direction(gpio, GPIO_DIR_IN);
-       if (status < 0)
-               return status;
-
        return sr_gpio_get_value(gpio);
 }