#ifndef __PERIPHERAL_HANDLE_GPIO_H__
#define __PERIPHERAL_HANDLE_GPIO_H__
-int peripheral_handle_gpio_create(int pin, peripheral_h *handle, gpointer user_data);
+int peripheral_handle_gpio_create(gint pin, peripheral_h *handle, gpointer user_data);
int peripheral_handle_gpio_destroy(peripheral_h handle);
#endif /* __PERIPHERAL_HANDLE_GPIO_H__ */
gint pin,
gpointer user_data)
{
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ int ret = PERIPHERAL_ERROR_NONE;
+
peripheral_info_s *info = (peripheral_info_s*)user_data;
peripheral_h gpio_handle = NULL;
-
GUnixFDList *gpio_fd_list = NULL;
ret = peripheral_privilege_check(invocation, info->connection);
goto out;
}
- if ((ret = peripheral_handle_gpio_create(pin, &gpio_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ gpio_fd_list = g_unix_fd_list_new();
+ if (gpio_fd_list == NULL) {
+ _E("Failed to create gpio fd list");
+ ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ ret = peripheral_handle_gpio_create(pin, &gpio_handle, user_data);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to create peripheral gpio handle");
goto out;
+ }
+
+ /* Do not change the order of the fd list */
+ g_unix_fd_list_append(gpio_fd_list, gpio_handle->type.gpio.fd_direction, NULL);
+ g_unix_fd_list_append(gpio_fd_list, gpio_handle->type.gpio.fd_edge, NULL);
+ g_unix_fd_list_append(gpio_fd_list, gpio_handle->type.gpio.fd_value, NULL);
gpio_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
g_dbus_method_invocation_get_sender(invocation),
out:
peripheral_io_gdbus_gpio_complete_open(gpio, invocation, gpio_fd_list, GPOINTER_TO_UINT(gpio_handle), ret);
+ if (gpio_fd_list != NULL)
+ g_object_unref(gpio_fd_list);
+
return true;
}
\ No newline at end of file
*/
#include <peripheral_io.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_log.h"
#include "peripheral_privilege.h"
gint address,
gpointer user_data)
{
+ int ret = PERIPHERAL_ERROR_NONE;
+
peripheral_info_s *info = (peripheral_info_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
peripheral_h i2c_handle = NULL;
-
GUnixFDList *i2c_fd_list = NULL;
ret = peripheral_privilege_check(invocation, info->connection);
goto out;
}
- if ((ret = peripheral_handle_i2c_create(bus, address, &i2c_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ i2c_fd_list = g_unix_fd_list_new();
+ if (i2c_fd_list == NULL) {
+ _E("Failed to create i2c fd list");
+ ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ ret = peripheral_handle_i2c_create(bus, address, &i2c_handle, user_data);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to create periphreal i2c handle");
goto out;
+ }
+
+ /* Do not change the order of the fd list */
+ g_unix_fd_list_append(i2c_fd_list, i2c_handle->type.i2c.fd, NULL);
i2c_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
g_dbus_method_invocation_get_sender(invocation),
out:
peripheral_io_gdbus_i2c_complete_open(i2c, invocation, i2c_fd_list, GPOINTER_TO_UINT(i2c_handle), ret);
+ if (i2c_fd_list != NULL)
+ g_object_unref(i2c_fd_list);
+
return true;
}
*/
#include <peripheral_io.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_log.h"
#include "peripheral_privilege.h"
gint pin,
gpointer user_data)
{
+ int ret = PERIPHERAL_ERROR_NONE;
+
peripheral_info_s *info = (peripheral_info_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
peripheral_h pwm_handle = NULL;
-
GUnixFDList *pwm_fd_list = NULL;
ret = peripheral_privilege_check(invocation, info->connection);
goto out;
}
- if ((ret = peripheral_handle_pwm_create(chip, pin, &pwm_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ pwm_fd_list = g_unix_fd_list_new();
+ if (pwm_fd_list == NULL) {
+ _E("Failed to create pwm fd list");
+ ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ ret = peripheral_handle_pwm_create(chip, pin, &pwm_handle, user_data);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to create peripheral pwm handle");
goto out;
+ }
+
+ /* Do not change the order of the fd list */
+ g_unix_fd_list_append(pwm_fd_list, pwm_handle->type.pwm.fd_period, NULL);
+ g_unix_fd_list_append(pwm_fd_list, pwm_handle->type.pwm.fd_duty_cycle, NULL);
+ g_unix_fd_list_append(pwm_fd_list, pwm_handle->type.pwm.fd_polarity, NULL);
+ g_unix_fd_list_append(pwm_fd_list, pwm_handle->type.pwm.fd_enable, NULL);
pwm_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
g_dbus_method_invocation_get_sender(invocation),
out:
peripheral_io_gdbus_pwm_complete_open(pwm, invocation, pwm_fd_list, GPOINTER_TO_UINT(pwm_handle), ret);
+ if (pwm_fd_list != NULL)
+ g_object_unref(pwm_fd_list);
+
return true;
}
*/
#include <peripheral_io.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_log.h"
#include "peripheral_privilege.h"
gint cs,
gpointer user_data)
{
+ int ret = PERIPHERAL_ERROR_NONE;
+
peripheral_info_s *info = (peripheral_info_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
peripheral_h spi_handle = NULL;
-
GUnixFDList *spi_fd_list = NULL;
ret = peripheral_privilege_check(invocation, info->connection);
goto out;
}
- if ((ret = peripheral_handle_spi_create(bus, cs, &spi_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ spi_fd_list = g_unix_fd_list_new();
+ if (spi_fd_list == NULL) {
+ _E("Failed to create spi fd list");
+ ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ ret = peripheral_handle_spi_create(bus, cs, &spi_handle, user_data);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to create peripheral spi handle");
goto out;
+ }
+
+ /* Do not change the order of the fd list */
+ g_unix_fd_list_append(spi_fd_list, spi_handle->type.spi.fd, NULL);
spi_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
g_dbus_method_invocation_get_sender(invocation),
out:
peripheral_io_gdbus_spi_complete_open(spi, invocation, spi_fd_list, GPOINTER_TO_UINT(spi_handle), ret);
+ if (spi_fd_list != NULL)
+ g_object_unref(spi_fd_list);
+
return true;
}
*/
#include <peripheral_io.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_log.h"
#include "peripheral_privilege.h"
gint port,
gpointer user_data)
{
+ int ret = PERIPHERAL_ERROR_NONE;
+
peripheral_info_s *info = (peripheral_info_s*)user_data;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
peripheral_h uart_handle = NULL;
-
GUnixFDList *uart_fd_list = NULL;
ret = peripheral_privilege_check(invocation, info->connection);
goto out;
}
- if ((ret = peripheral_handle_uart_create(port, &uart_handle, user_data)) < PERIPHERAL_ERROR_NONE)
+ uart_fd_list = g_unix_fd_list_new();
+ if (uart_fd_list == NULL) {
+ _E("Failed to create uart fd list");
+ ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ ret = peripheral_handle_uart_create(port, &uart_handle, user_data);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to create peripheral uart handle");
goto out;
+ }
+
+ /* Do not change the order of the fd list */
+ g_unix_fd_list_append(uart_fd_list, uart_handle->type.uart.fd, NULL);
uart_handle->watch_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
g_dbus_method_invocation_get_sender(invocation),
out:
peripheral_io_gdbus_uart_complete_open(uart, invocation, uart_fd_list, GPOINTER_TO_UINT(uart_handle), ret);
+ if (uart_fd_list != NULL)
+ g_object_unref(uart_fd_list);
+
return true;
}