when gdbus request to daemon for open/close, it can receive return value TRUE with ret that it is not PERIPEHRAL_ERROR_NONE.
In the case of requesting open to daemon, getting fd from list is meaningless.
In the case of requesting close to daemon, proxy deinit function must not be run.
Change-Id: I6ca7b1c98a15ca17159123903cd9d8ebe57c353c
Signed-off-by: Segwon <segwon.han@samsung.com>
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio)
{
+ int ret;
GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
GUnixFDList *fd_list = NULL;
ret = __gpio_proxy_init();
&fd_list,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to gpio open : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
+ if (ret != PERIPHERAL_ERROR_NONE)
+ return ret;
+
gpio->fd_direction = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_DIRECTION, &error);
if (gpio->fd_direction < 0) {
_E("Failed to get fd for gpio direction : %s", error->message);
int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (gpio_proxy == NULL) {
_E("Can't try to gpio close because gpio proxy is NULL.");
&ret,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to gpio close : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
- __gpio_proxy_deinit();
+ // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request.
+ if (ret == PERIPHERAL_ERROR_NONE)
+ __gpio_proxy_deinit();
return ret;
}
\ No newline at end of file
int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
GUnixFDList *fd_list = NULL;
ret = __i2c_proxy_init();
&fd_list,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to i2c open : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
+ if (ret != PERIPHERAL_ERROR_NONE)
+ return ret;
+
i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error);
if (i2c->fd < 0) {
_E("Failed to get fd for i2c : %s", error->message);
g_error_free(error);
- ret = PERIPHERAL_ERROR_UNKNOWN;
}
g_object_unref(fd_list);
int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (i2c_proxy == NULL) {
_E("Can't try to i2c close because i2c proxy is NULL.");
&ret,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to i2c close : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
- __i2c_proxy_deinit();
+ // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request.
+ if (ret == PERIPHERAL_ERROR_NONE)
+ __i2c_proxy_deinit();
return ret;
-}
\ No newline at end of file
+}
int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
GUnixFDList *fd_list = NULL;
ret = __pwm_proxy_init();
&fd_list,
NULL,
&error) == FALSE) {
- _E("%s", error->message);
+ _E("Failed to request daemon to pwm open : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
+ if (ret != PERIPHERAL_ERROR_NONE)
+ return ret;
+
pwm->fd_period = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_PERIOD, &error);
if (pwm->fd_period < 0) {
_E("Failed to get fd for pwm period : %s", error->message);
int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (pwm_proxy == NULL) {
_E("Can't try to pwm close because pwm proxy is NULL.");
&ret,
NULL,
&error) == FALSE) {
- _E("%s", error->message);
+ _E("Failed to request daemon to pwm close : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
- __pwm_proxy_deinit();
+ // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request.
+ if (ret == PERIPHERAL_ERROR_NONE)
+ __pwm_proxy_deinit();
return ret;
-}
\ No newline at end of file
+}
int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
GUnixFDList *fd_list = NULL;
ret = __spi_proxy_init();
&fd_list,
NULL,
&error) == FALSE) {
- _E("%s", error->message);
+ _E("Failed to request daemon to spi open : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
+ if (ret != PERIPHERAL_ERROR_NONE)
+ return ret;
+
spi->fd = g_unix_fd_list_get(fd_list, SPI_FD_INDEX, &error);
if (spi->fd < 0) {
_E("Failed to get fd for spi : %s", error->message);
int peripheral_gdbus_spi_close(peripheral_spi_h spi)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (spi_proxy == NULL) {
_E("Can't try to spi close because spi proxy is NULL.");
&ret,
NULL,
&error) == FALSE) {
- _E("%s", error->message);
+ _E("Failed to request daemon to spi close : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
- __spi_proxy_deinit();
+ // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request.
+ if (ret == PERIPHERAL_ERROR_NONE)
+ __spi_proxy_deinit();
return ret;
-}
\ No newline at end of file
+}
int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
GUnixFDList *fd_list = NULL;
ret = __uart_proxy_init();
&fd_list,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to uart open : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
+ if (ret != PERIPHERAL_ERROR_NONE)
+ return ret;
+
uart->fd = g_unix_fd_list_get(fd_list, UART_FD_INDEX, &error);
if (uart->fd < 0) {
_E("Failed to get fd for uart : %s", error->message);
int peripheral_gdbus_uart_close(peripheral_uart_h uart)
{
+ int ret;
GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (uart_proxy == NULL) {
_E("Can't try to uart close because uart proxy is NULL.");
return PERIPHERAL_ERROR_UNKNOWN;
}
+
if (peripheral_io_gdbus_uart_call_close_sync(
uart_proxy,
uart->handle,
&ret,
NULL,
&error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
+ _E("Failed to request daemon to uart close : %s", error->message);
g_error_free(error);
return PERIPHERAL_ERROR_UNKNOWN;
}
- __uart_proxy_deinit();
+ // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request.
+ if (ret == PERIPHERAL_ERROR_NONE)
+ __uart_proxy_deinit();
return ret;
-}
\ No newline at end of file
+}