#include "peripheral_gdbus_common.h"
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio, int pin);
-int peripheral_gdbus_gpio_close(void);
+int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio);
#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(void);
+int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c);
#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(void);
+int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm);
#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(void);
+int peripheral_gdbus_spi_close(peripheral_spi_h spi);
#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(void);
+int peripheral_gdbus_uart_close(peripheral_uart_h uart);
#endif /* __PERIPHERAL_GDBUS_UART_H_ */
static int __gpio_proxy_deinit(void)
{
- if (gpio_proxy == NULL) {
- _E("Gpio proxy is NULL");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
+ RETVM_IF(gpio_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Gpio proxy is NULL");
g_object_unref(gpio_proxy);
if (!G_IS_OBJECT(gpio_proxy))
return ret;
}
-int peripheral_gdbus_gpio_close(void)
+int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio)
{
- int ret = __gpio_proxy_deinit();
+ RETVM_IF(gpio_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Gpio proxy is NULL");
+
+ int ret;
+ GError *error = NULL;
+
+ 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_IO_ERROR;
+ }
+
+ __gpio_proxy_deinit();
+
return ret;
}
\ No newline at end of file
static int __i2c_proxy_deinit(void)
{
- if (i2c_proxy == NULL) {
- _E("I2c proxy is NULL");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
+ RETVM_IF(i2c_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "I2c proxy is NULL");
g_object_unref(i2c_proxy);
if (!G_IS_OBJECT(i2c_proxy))
return ret;
}
-int peripheral_gdbus_i2c_close(void)
+int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c)
{
- int ret = __i2c_proxy_deinit();
+ RETVM_IF(i2c_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "I2c proxy is NULL");
+
+ int ret;
+ GError *error = NULL;
+
+ 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_IO_ERROR;
+ }
+
+ __i2c_proxy_deinit();
+
return ret;
}
static int __pwm_proxy_deinit(void)
{
- if (pwm_proxy == NULL) {
- _E("Pwm proxy is NULL");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
+ RETVM_IF(pwm_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Pwm proxy is NULL");
g_object_unref(pwm_proxy);
if (!G_IS_OBJECT(pwm_proxy))
return ret;
}
-int peripheral_gdbus_pwm_close(void)
+int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm)
{
- int ret = __pwm_proxy_deinit();
+ RETVM_IF(pwm_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Pwm proxy is NULL");
+
+ int ret;
+ GError *error = NULL;
+
+ if (peripheral_io_gdbus_pwm_call_close_sync(
+ pwm_proxy,
+ pwm->handle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Failed to request daemon to gpio pwm : %s", error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ __pwm_proxy_deinit();
+
return ret;
}
static int __spi_proxy_deinit(void)
{
- if (spi_proxy == NULL) {
- _E("Spi proxy is NULL");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
+ RETVM_IF(spi_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Spi proxy is NULL");
g_object_unref(spi_proxy);
if (!G_IS_OBJECT(spi_proxy))
return ret;
}
-int peripheral_gdbus_spi_close(void)
+int peripheral_gdbus_spi_close(peripheral_spi_h spi)
{
- int ret = __spi_proxy_deinit();
+ RETVM_IF(spi_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Spi proxy is NULL");
+
+ int ret;
+ GError *error = NULL;
+
+ if (peripheral_io_gdbus_spi_call_close_sync(
+ spi_proxy,
+ spi->handle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Failed to request daemon to gpio spi : %s", error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ __spi_proxy_deinit();
+
return ret;
}
static int __uart_proxy_deinit(void)
{
- if (uart_proxy == NULL) {
- _E("Uart proxy is NULL");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
+ RETVM_IF(uart_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Uart proxy is NULL");
g_object_unref(uart_proxy);
if (!G_IS_OBJECT(uart_proxy))
return ret;
}
-int peripheral_gdbus_uart_close(void)
+int peripheral_gdbus_uart_close(peripheral_uart_h uart)
{
- int ret = __uart_proxy_deinit();
+ RETVM_IF(uart_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "Uart proxy is NULL");
+
+ int ret;
+ GError *error = NULL;
+
+ if (peripheral_io_gdbus_uart_call_close_sync(
+ uart_proxy,
+ uart->handle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Failed to request daemon to gpio uart : %s", error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ __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();
+ ret = peripheral_gdbus_gpio_close(gpio);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close the gpio pin, ret : %d", ret);
return 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();
+ ret = peripheral_gdbus_i2c_close(i2c);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close i2c communcation, ret : %d", ret);
return 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");
- ret = peripheral_gdbus_pwm_close();
+ ret = peripheral_gdbus_pwm_close(pwm);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close PWM chip, continuing anyway, ret : %d", ret);
return ret;
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();
+ ret = peripheral_gdbus_spi_close(spi);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close SPI device, continuing anyway, ret : %d", ret);
return 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();
+ ret = peripheral_gdbus_uart_close(uart);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close uart communication, continuing anyway, ret : %d", ret);
return ret;