interface: close the fd before call CHECK_ERROR if it need to close fd 80/160980/3
authorSegwon <segwon.han@samsung.com>
Tue, 21 Nov 2017 04:06:56 +0000 (13:06 +0900)
committerSegwon <segwon.han@samsung.com>
Tue, 21 Nov 2017 06:22:14 +0000 (15:22 +0900)
Change-Id: I791e969c63da3c114f08ecdb3dbb303f9239dfb1
Signed-off-by: Segwon <segwon.han@samsung.com>
src/interface/peripheral_interface_gpio.c
src/interface/peripheral_interface_pwm.c

index 245b0ff..3d7da22 100644 (file)
@@ -31,9 +31,8 @@ int gpio_open(int gpiopin)
 
        len = snprintf(gpio_export, MAX_BUF_LEN, "%d", gpiopin);
        status = write(fd, gpio_export, len);
-       CHECK_ERROR(status != len);
-
        close(fd);
+       CHECK_ERROR(status != len);
 
        return 0;
 }
@@ -50,9 +49,8 @@ int gpio_close(int gpiopin)
 
        len = snprintf(gpio_unexport, MAX_BUF_LEN, "%d", gpiopin);
        status = write(fd, gpio_unexport, len);
-       CHECK_ERROR(status != len);
-
        close(fd);
+       CHECK_ERROR(status != len);
 
        return 0;
 }
index 5eaab96..b66c4d8 100644 (file)
@@ -33,9 +33,8 @@ int pwm_open(int chip, int pin)
 
        len = snprintf(pwm_buf, MAX_BUF_LEN, "%d", pin);
        status = write(fd, pwm_buf, len);
-       CHECK_ERROR(status != len);
-
        close(fd);
+       CHECK_ERROR(status != len);
 
        return 0;
 }
@@ -54,9 +53,8 @@ int pwm_close(int chip, int pin)
 
        len = snprintf(pwm_buf, MAX_BUF_LEN, "%d", pin);
        status = write(fd, pwm_buf, len);
-       CHECK_ERROR(status != len);
-
        close(fd);
+       CHECK_ERROR(status != len);
 
        return 0;
 }