Print log messages in case of wrong write access 13/140113/1
authorHyeongsik Min <hyeongsik.min@samsung.com>
Mon, 24 Jul 2017 02:15:12 +0000 (11:15 +0900)
committerHyeongsik Min <hyeongsik.min@samsung.com>
Mon, 24 Jul 2017 02:25:25 +0000 (11:25 +0900)
Writing value is not permitted when the pin is in input direction mode.
Just in case, this patch fixes error number and adds log message to let user
know the cause.

Change-Id: Ie40fabeba06b832eaa0585130af8702ba8fcb8b5
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
src/daemon/peripheral_bus_gpio.c

index c6854ce..c1011e9 100644 (file)
@@ -253,9 +253,11 @@ int peripheral_bus_gpio_write(pb_data_h handle, gint value)
        peripheral_bus_gpio_s *gpio = &handle->dev.gpio;
        int ret;
 
-       /* Return error if direction is input mode */
-       if (gpio->direction == GPIO_DIRECTION_IN)
-               return PERIPHERAL_ERROR_IO_ERROR;
+       /* Return error if direction of the pin is input mode */
+       if (gpio->direction == GPIO_DIRECTION_IN) {
+               _E("The direction of the pin is INPUT mode, Cannot write");
+               return PERIPHERAL_ERROR_INVALID_OPERATION;
+       }
 
        if ((ret = gpio_write(gpio->pin, value)) < 0) {
                _E("gpio_write error (%d)", ret);