#include "peripheral_gdbus_common.h"
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio);
-int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio);
+int peripheral_gdbus_gpio_close();
#endif /* __PERIPHERAL_GDBUS_GPIO_H__ */
#include "peripheral_gdbus_common.h"
int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
-int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c);
+int peripheral_gdbus_i2c_close();
#endif /* __PERIPHERAL_GDBUS_I2C_H__ */
#include "peripheral_gdbus_common.h"
int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin);
-int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm);
+int peripheral_gdbus_pwm_close();
#endif /* __PERIPHERAL_GDBUS_PWM_H__ */
#include "peripheral_gdbus_common.h"
int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs);
-int peripheral_gdbus_spi_close(peripheral_spi_h spi);
+int peripheral_gdbus_spi_close();
#endif /* __PERIPHERAL_GDBUS_SPI_H_ */
#include "peripheral_gdbus_common.h"
int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port);
-int peripheral_gdbus_uart_close(peripheral_uart_h uart);
+int peripheral_gdbus_uart_close();
#endif /* __PERIPHERAL_GDBUS_UART_H_ */
return PERIPHERAL_ERROR_NONE;
}
-static void __gpio_proxy_deinit()
+static int __gpio_proxy_deinit()
{
- if (gpio_proxy != NULL) {
- g_object_unref(gpio_proxy);
- if (!G_IS_OBJECT(gpio_proxy))
- gpio_proxy = NULL;
+ if (gpio_proxy == NULL) {
+ _E("Gpio proxy is NULL");
+ return PERIPHERAL_ERROR_UNKNOWN;
}
+
+ g_object_unref(gpio_proxy);
+ if (!G_IS_OBJECT(gpio_proxy))
+ gpio_proxy = NULL;
+
+ return PERIPHERAL_ERROR_NONE;
}
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio)
return ret;
}
-int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio)
+int peripheral_gdbus_gpio_close()
{
- int ret;
- GError *error = NULL;
-
- if (gpio_proxy == NULL) {
- _E("Can't try to gpio close because gpio proxy is NULL.");
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (peripheral_io_gdbus_gpio_call_close_sync(
- gpio_proxy,
- gpio->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Failed to request daemon to gpio close : %s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- // 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();
-
+ int ret = __gpio_proxy_deinit();
return ret;
}
\ No newline at end of file
return PERIPHERAL_ERROR_NONE;
}
-static void __i2c_proxy_deinit()
+static int __i2c_proxy_deinit()
{
- if (i2c_proxy) {
- g_object_unref(i2c_proxy);
- if (!G_IS_OBJECT(i2c_proxy))
- i2c_proxy = NULL;
+ if (i2c_proxy == NULL) {
+ _E("I2c proxy is NULL");
+ return PERIPHERAL_ERROR_UNKNOWN;
}
+
+ g_object_unref(i2c_proxy);
+ if (!G_IS_OBJECT(i2c_proxy))
+ i2c_proxy = NULL;
+
+ return PERIPHERAL_ERROR_NONE;
}
int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address)
return ret;
}
-int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c)
+int peripheral_gdbus_i2c_close()
{
- int ret;
- GError *error = NULL;
-
- if (i2c_proxy == NULL) {
- _E("Can't try to i2c close because i2c proxy is NULL.");
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (peripheral_io_gdbus_i2c_call_close_sync(
- i2c_proxy,
- i2c->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Failed to request daemon to i2c close : %s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- // 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();
-
+ int ret = __i2c_proxy_deinit();
return ret;
}
return PERIPHERAL_ERROR_NONE;
}
-static void __pwm_proxy_deinit()
+static int __pwm_proxy_deinit()
{
- if (pwm_proxy) {
- g_object_unref(pwm_proxy);
- if (!G_IS_OBJECT(pwm_proxy))
- pwm_proxy = NULL;
+ if (pwm_proxy == NULL) {
+ _E("Pwm proxy is NULL");
+ return PERIPHERAL_ERROR_UNKNOWN;
}
+
+ g_object_unref(pwm_proxy);
+ if (!G_IS_OBJECT(pwm_proxy))
+ pwm_proxy = NULL;
+
+ return PERIPHERAL_ERROR_NONE;
}
int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin)
return ret;
}
-int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm)
+int peripheral_gdbus_pwm_close()
{
- int ret;
- GError *error = NULL;
-
- if (pwm_proxy == NULL) {
- _E("Can't try to pwm close because pwm proxy is NULL.");
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (peripheral_io_gdbus_pwm_call_close_sync(
- pwm_proxy,
- pwm->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Failed to request daemon to pwm close : %s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- // 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();
-
+ int ret = __pwm_proxy_deinit();
return ret;
}
return PERIPHERAL_ERROR_NONE;
}
-static void __spi_proxy_deinit()
+static int __spi_proxy_deinit()
{
- if (spi_proxy) {
- g_object_unref(spi_proxy);
- if (!G_IS_OBJECT(spi_proxy))
- spi_proxy = NULL;
+ if (spi_proxy == NULL) {
+ _E("Spi proxy is NULL");
+ return PERIPHERAL_ERROR_UNKNOWN;
}
+
+ g_object_unref(spi_proxy);
+ if (!G_IS_OBJECT(spi_proxy))
+ spi_proxy = NULL;
+
+ return PERIPHERAL_ERROR_NONE;
}
int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs)
return ret;
}
-int peripheral_gdbus_spi_close(peripheral_spi_h spi)
+int peripheral_gdbus_spi_close()
{
- int ret;
- GError *error = NULL;
-
- if (spi_proxy == NULL) {
- _E("Can't try to spi close because spi proxy is NULL.");
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (peripheral_io_gdbus_spi_call_close_sync(
- spi_proxy,
- spi->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Failed to request daemon to spi close : %s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- // 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();
-
+ int ret = __spi_proxy_deinit();
return ret;
}
return PERIPHERAL_ERROR_NONE;
}
-static void __uart_proxy_deinit()
+static int __uart_proxy_deinit()
{
- if (uart_proxy) {
- g_object_unref(uart_proxy);
- if (!G_IS_OBJECT(uart_proxy))
- uart_proxy = NULL;
+ if (uart_proxy == NULL) {
+ _E("Uart proxy is NULL");
+ return PERIPHERAL_ERROR_UNKNOWN;
}
+
+ g_object_unref(uart_proxy);
+ if (!G_IS_OBJECT(uart_proxy))
+ uart_proxy = NULL;
+
+ return PERIPHERAL_ERROR_NONE;
}
int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port)
return ret;
}
-int peripheral_gdbus_uart_close(peripheral_uart_h uart)
+int peripheral_gdbus_uart_close()
{
- int ret;
- GError *error = NULL;
-
- 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("Failed to request daemon to uart close : %s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- // 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();
-
+ int ret = __uart_proxy_deinit();
return ret;
}
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Close">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.i2c">
<method name="Open">
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Close">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.pwm">
<method name="Open">
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Close">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.uart">
<method name="Open">
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Close">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.spi">
<method name="Open">
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Close">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
</node>
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
/* call gpio_close */
- ret = peripheral_gdbus_gpio_close(gpio);
+ ret = peripheral_gdbus_gpio_close();
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to close the gpio pin, ret : %d", ret);
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- ret = peripheral_gdbus_i2c_close(i2c);
+ ret = peripheral_gdbus_i2c_close();
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to close i2c communcation, ret : %d", ret);
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- if ((ret = peripheral_gdbus_pwm_close(pwm)) < 0)
+ if ((ret = peripheral_gdbus_pwm_close()) < 0)
_E("Failed to close PWM chip, continuing anyway, ret : %d", ret);
free(pwm);
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_close(spi);
+ ret = peripheral_gdbus_spi_close();
if (ret < PERIPHERAL_ERROR_NONE)
_E("Failed to close SPI device, continuing anyway, ret : %d", ret);
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
- ret = peripheral_gdbus_uart_close(uart);
+ ret = peripheral_gdbus_uart_close();
if (ret < PERIPHERAL_ERROR_NONE)
_E("Failed to close uart communication, continuing anyway, ret : %d", ret);