handle: change structs name in peripheral_handle.h 44/161344/3
authorSegwon <segwon.han@samsung.com>
Thu, 23 Nov 2017 02:46:58 +0000 (11:46 +0900)
committerSegwon <segwon.han@samsung.com>
Thu, 23 Nov 2017 03:23:36 +0000 (12:23 +0900)
 - remove the unused handle and type
 - peripheral_bus_s -> peripheral_info_s
 - peripheral_bus_gpio_s -> peripheral_handle_gpio_s
 - peripheral_bus_i2c_s  -> peripheral_handle_i2c_s
 - peripheral_bus_pwm_s  -> peripheral_handle_pwm_s
 - peripheral_bus_uart_s -> peripheral_handle_uart_s
 - peripheral_bus_spi_s  -> peripheral_spi_s
 - peripheral_bus_data_s -> peripheral_handle_s

Change-Id: I6605071a201eb6e1b508c7d43ac37c27c1ece7fe
Signed-off-by: Segwon <segwon.han@samsung.com>
19 files changed:
include/handle/peripheral_handle.h
include/handle/peripheral_handle_common.h
include/handle/peripheral_handle_gpio.h
include/handle/peripheral_handle_i2c.h
include/handle/peripheral_handle_pwm.h
include/handle/peripheral_handle_spi.h
include/handle/peripheral_handle_uart.h
src/gdbus/peripheral_gdbus_gpio.c
src/gdbus/peripheral_gdbus_i2c.c
src/gdbus/peripheral_gdbus_pwm.c
src/gdbus/peripheral_gdbus_spi.c
src/gdbus/peripheral_gdbus_uart.c
src/handle/peripheral_handle_common.c
src/handle/peripheral_handle_gpio.c
src/handle/peripheral_handle_i2c.c
src/handle/peripheral_handle_pwm.c
src/handle/peripheral_handle_spi.c
src/handle/peripheral_handle_uart.c
src/peripheral_bus.c

index cae3177a4a0c1de0db89d3c44629e5693f6ac042..90e4d79a3310e73c3cfe178ee1571eab220bc60d 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __PERIPHERAL_BUS_H__
-#define __PERIPHERAL_BUS_H__
+#ifndef __PERIPHERAL_HANDLE_H__
+#define __PERIPHERAL_HANDLE_H__
 
 #include <gio/gio.h>
 
 #include "peripheral_board.h"
 #include "peripheral_io_gdbus.h"
 
-typedef enum {
-       PERIPHERAL_BUS_TYPE_GPIO = 0,
-       PERIPHERAL_BUS_TYPE_I2C,
-       PERIPHERAL_BUS_TYPE_PWM,
-       PERIPHERAL_BUS_TYPE_UART,
-       PERIPHERAL_BUS_TYPE_SPI,
-} peripheral_bus_type_e;
-
 typedef struct {
        pb_board_s *board;
        /* devices */
@@ -39,62 +31,52 @@ typedef struct {
        GList *uart_list;
        GList *spi_list;
        /* gdbus variable */
-       guint reg_id;
        GDBusConnection *connection;
        PeripheralIoGdbusGpio *gpio_skeleton;
        PeripheralIoGdbusI2c *i2c_skeleton;
        PeripheralIoGdbusPwm *pwm_skeleton;
        PeripheralIoGdbusUart *uart_skeleton;
        PeripheralIoGdbusSpi *spi_skeleton;
-} peripheral_bus_s;
-
-typedef struct {
-       char *id;
-       pid_t pid;
-       pid_t pgid;
-} pb_client_info_s;
+} peripheral_info_s;
 
 typedef struct {
        int pin;
-} peripheral_bus_gpio_s;
+} peripheral_handle_gpio_s;
 
 typedef struct {
        int bus;
        int address;
        int fd;
-} peripheral_bus_i2c_s;
+} peripheral_handle_i2c_s;
 
 typedef struct {
        int chip;
        int pin;
-} peripheral_bus_pwm_s;
+} peripheral_handle_pwm_s;
 
 typedef struct {
        int port;
        int fd;
-} peripheral_bus_uart_s;
+} peripheral_handle_uart_s;
 
 typedef struct {
        int bus;
        int cs;
        int fd;
-} peripheral_bus_spi_s;
+} peripheral_handle_spi_s;
 
 typedef struct {
-       peripheral_bus_type_e type;
        uint watch_id;
        GList **list;
-       /* client info */
-       pb_client_info_s client_info;
        union {
-               peripheral_bus_gpio_s gpio;
-               peripheral_bus_i2c_s i2c;
-               peripheral_bus_pwm_s pwm;
-               peripheral_bus_uart_s uart;
-               peripheral_bus_spi_s spi;
-       } dev;
-} peripheral_bus_data_s;
+               peripheral_handle_gpio_s gpio;
+               peripheral_handle_i2c_s i2c;
+               peripheral_handle_pwm_s pwm;
+               peripheral_handle_uart_s uart;
+               peripheral_handle_spi_s spi;
+       } type;
+} peripheral_handle_s;
 
-typedef peripheral_bus_data_s *pb_data_h;
+typedef peripheral_handle_s *peripheral_h;
 
-#endif /* __PERIPHERAL_BUS_H__ */
+#endif /* __PERIPHERAL_HANDLE_H__ */
index 7531888d10bcc420164fa4528f68930c6f3b05c5..9d0c3bf94edef53b3a25cf84887088d4d7293a17 100644 (file)
@@ -22,7 +22,7 @@
 #include "peripheral_handle.h"
 #include "peripheral_log.h"
 
-pb_data_h peripheral_handle_new(GList **plist);
-int peripheral_handle_free(pb_data_h handle);
+peripheral_h peripheral_handle_new(GList **plist);
+int peripheral_handle_free(peripheral_h handle);
 
 #endif /* __PERIPHERAL_HANDLE_COMMON_H__ */
index b5cf53b3bbb73199c82c51a3e321749e04388075..7d2dc48b3f04fc507534ac325001d4b07c2dfbfb 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __PERIPHERAL_HANDLE_GPIO_H__
 #define __PERIPHERAL_HANDLE_GPIO_H__
 
-int peripheral_handle_gpio_create(gint pin, pb_data_h *handle, gpointer user_data);
-int peripheral_handle_gpio_destroy(pb_data_h handle);
+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__ */
index 2073f3d98fc13295a0dc26f19f69cc5967d44a4a..55079e0a2d651591b708188a1ab770b16cfd844c 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __PERIPHERAL_HANDLE_I2C_H__
 #define __PERIPHERAL_HANDLE_I2C_H__
 
-int peripheral_handle_i2c_create(int bus, int address, pb_data_h *handle, gpointer user_data);
-int peripheral_handle_i2c_destroy(pb_data_h handle);
+int peripheral_handle_i2c_create(int bus, int address, peripheral_h *handle, gpointer user_data);
+int peripheral_handle_i2c_destroy(peripheral_h handle);
 
 #endif /* __PERIPHERAL_HANDLE_I2C_H__ */
index 1befc506ff27e905cbbca9adbec51551a3b4d697..98b6928e630bf644d77e859e7742441ab9ba4764 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __PERIPHERAL_HANDLE_PWM_H__
 #define __PERIPHERAL_HANDLE_PWM_H__
 
-int peripheral_handle_pwm_create(int chip, int pin, pb_data_h *handle, gpointer user_data);
-int peripheral_handle_pwm_destroy(pb_data_h handle);
+int peripheral_handle_pwm_create(int chip, int pin, peripheral_h *handle, gpointer user_data);
+int peripheral_handle_pwm_destroy(peripheral_h handle);
 
 #endif /* __PERIPHERAL_HANDLE_PWM_H__ */
index 7d5838610bbbc641fb2fd1aac64d6ac2351a17de..cfd0d9cc36520c89fba064267c04960bcb931842 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __PERIPHERAL_HANDLE_SPI_H__
 #define __PERIPHERAL_HANDLE_SPI_H__
 
-int peripheral_handle_spi_create(int bus, int cs, pb_data_h *handle, gpointer user_data);
-int peripheral_handle_spi_destroy(pb_data_h handle);
+int peripheral_handle_spi_create(int bus, int cs, peripheral_h *handle, gpointer user_data);
+int peripheral_handle_spi_destroy(peripheral_h handle);
 
 #endif /* __PERIPHERAL_HANDLE_SPI_H__ */
index 6cb28710a52d33e93f09a16277812561feaedde5..c72dedcaf5ea8e64ad7acd24552019b209352db0 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __PERIPHERAL_HANDLE_UART_H__
 #define __PERIPHERAL_HANDLE_UART_H__
 
-int peripheral_handle_uart_open(int port, pb_data_h *handle, gpointer user_data);
-int peripheral_handle_uart_destroy(pb_data_h handle);
+int peripheral_handle_uart_open(int port, peripheral_h *handle, gpointer user_data);
+int peripheral_handle_uart_destroy(peripheral_h handle);
 
 #endif /* __PERIPHERAL_HANDLE_UART_H__ */
index 8763ff34c4b5bc1e707ae1f4a38601aa5a73695a..02034116d0a29378263a54ea0bed7941f93d011d 100644 (file)
@@ -28,7 +28,7 @@ static void __gpio_on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       pb_data_h gpio_handle = (pb_data_h)user_data;
+       peripheral_h gpio_handle = (peripheral_h)user_data;
        _D("appid [%s] vanished ", name);
 
        g_bus_unwatch_name(gpio_handle->watch_id);
@@ -43,12 +43,12 @@ gboolean handle_gpio_open(
                gpointer user_data)
 {
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h gpio_handle = NULL;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h gpio_handle = NULL;
 
        GUnixFDList *gpio_fd_list = NULL;
 
-       ret = peripheral_privilege_check(invocation, pb_data->connection);
+       ret = peripheral_privilege_check(invocation, info->connection);
        if (ret != 0) {
                _E("Permission denied.");
                ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
index 9287d6afc97b2d6bf9f7c747d3db4951174e604a..b3b74b17f220f569254824b24fecb265640a3f97 100644 (file)
@@ -27,7 +27,7 @@ static void __i2c_on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       pb_data_h i2c_handle = (pb_data_h)user_data;
+       peripheral_h i2c_handle = (peripheral_h)user_data;
        _D("appid [%s] vanished ", name);
 
        g_bus_unwatch_name(i2c_handle->watch_id);
@@ -42,13 +42,13 @@ gboolean handle_i2c_open(
                gint address,
                gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h i2c_handle = NULL;
+       peripheral_h i2c_handle = NULL;
 
        GUnixFDList *i2c_fd_list = NULL;
 
-       ret = peripheral_privilege_check(invocation, pb_data->connection);
+       ret = peripheral_privilege_check(invocation, info->connection);
        if (ret != 0) {
                _E("Permission denied.");
                ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
index 83197758a81d2f4b17f84cb3dd19635d8eb6d957..488401dfee323b8d4e1c552d1a3edaef41f7d8ab 100644 (file)
@@ -27,7 +27,7 @@ static void __pwm_on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       pb_data_h pwm_handle = (pb_data_h)user_data;
+       peripheral_h pwm_handle = (peripheral_h)user_data;
        _D("appid [%s] vanished ", name);
 
        g_bus_unwatch_name(pwm_handle->watch_id);
@@ -42,13 +42,13 @@ gboolean handle_pwm_open(
                gint pin,
                gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h pwm_handle = NULL;
+       peripheral_h pwm_handle = NULL;
 
        GUnixFDList *pwm_fd_list = NULL;
 
-       ret = peripheral_privilege_check(invocation, pb_data->connection);
+       ret = peripheral_privilege_check(invocation, info->connection);
        if (ret != 0) {
                _E("Permission denied.");
                ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
index 8259536e685db9068ca25bbb56fb10da74d7c988..e675b12837a5444c50ece3a0e72930396d80e0d4 100644 (file)
@@ -27,7 +27,7 @@ static void __spi_on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       pb_data_h spi_handle = (pb_data_h)user_data;
+       peripheral_h spi_handle = (peripheral_h)user_data;
        _D("appid [%s] vanished ", name);
 
        g_bus_unwatch_name(spi_handle->watch_id);
@@ -42,13 +42,13 @@ gboolean handle_spi_open(
                gint cs,
                gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h spi_handle = NULL;
+       peripheral_h spi_handle = NULL;
 
        GUnixFDList *spi_fd_list = NULL;
 
-       ret = peripheral_privilege_check(invocation, pb_data->connection);
+       ret = peripheral_privilege_check(invocation, info->connection);
        if (ret != 0) {
                _E("Permission denied.");
                ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
index 2876b796cecda117ec3209e1a8ce37bcf9c65b6d..cb9b89734d25324ffd2f1850787fe051b0b6c6a2 100644 (file)
@@ -27,7 +27,7 @@ static void __uart_on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       pb_data_h uart_handle = (pb_data_h)user_data;
+       peripheral_h uart_handle = (peripheral_h)user_data;
        _D("appid [%s] vanished ", name);
 
        g_bus_unwatch_name(uart_handle->watch_id);
@@ -41,13 +41,13 @@ gboolean handle_uart_open(
                gint port,
                gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
        peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-       pb_data_h uart_handle = NULL;
+       peripheral_h uart_handle = NULL;
 
        GUnixFDList *uart_fd_list = NULL;
 
-       ret = peripheral_privilege_check(invocation, pb_data->connection);
+       ret = peripheral_privilege_check(invocation, info->connection);
        if (ret != 0) {
                _E("Permission denied.");
                ret = PERIPHERAL_ERROR_PERMISSION_DENIED;
index 67a2ef34614a3ef3a3e9dd3df08fd8796bc95441..4bb3b5eca1354350dd932b3520985f2af52b1817 100644 (file)
 
 #include "peripheral_handle_common.h"
 
-pb_data_h peripheral_handle_new(GList **plist)
+peripheral_h peripheral_handle_new(GList **plist)
 {
        GList *list = *plist;
-       pb_data_h handle;
+       peripheral_h handle;
 
-       handle = (pb_data_h)calloc(1, sizeof(peripheral_bus_data_s));
+       handle = (peripheral_h)calloc(1, sizeof(peripheral_handle_s));
        if (handle == NULL) {
-               _E("failed to allocate peripheral_bus_data_s");
+               _E("failed to allocate peripheral_handle_s");
                return NULL;
        }
 
@@ -34,7 +34,7 @@ pb_data_h peripheral_handle_new(GList **plist)
        return handle;
 }
 
-int peripheral_handle_free(pb_data_h handle)
+int peripheral_handle_free(peripheral_h handle)
 {
        GList *list = *handle->list;
        GList *link;
index 7e115e690fc6e228ddf87febf9cff065ff406fb0..6faafc2fcef7959193e9ba6e7a84310b1f9839cf 100644 (file)
 #include "peripheral_interface_gpio.h"
 #include "peripheral_handle_common.h"
 
-static bool __peripheral_handle_gpio_is_creatable(int pin, peripheral_bus_s *pb_data)
+static bool __peripheral_handle_gpio_is_creatable(int pin, peripheral_info_s *info)
 {
        pb_board_dev_s *gpio = NULL;
-       pb_data_h handle;
+       peripheral_h handle;
        GList *link;
 
-       RETV_IF(pb_data == NULL, false);
-       RETV_IF(pb_data->board == NULL, false);
+       RETV_IF(info == NULL, false);
+       RETV_IF(info->board == NULL, false);
 
-       gpio = peripheral_bus_board_find_device(PB_BOARD_DEV_GPIO, pb_data->board, pin);
+       gpio = peripheral_bus_board_find_device(PB_BOARD_DEV_GPIO, info->board, pin);
        if (gpio == NULL) {
                _E("Not supported GPIO pin : %d", pin);
                return false;
        }
 
-       link = pb_data->gpio_list;
+       link = info->gpio_list;
        while (link) {
-               handle = (pb_data_h)link->data;
-               if (handle->dev.gpio.pin == pin) {
+               handle = (peripheral_h)link->data;
+               if (handle->type.gpio.pin == pin) {
                        _E("gpio %d is busy", pin);
                        return false;
                }
@@ -50,29 +50,28 @@ static bool __peripheral_handle_gpio_is_creatable(int pin, peripheral_bus_s *pb_
        return true;
 }
 
-int peripheral_handle_gpio_create(gint pin, pb_data_h *handle, gpointer user_data)
+int peripheral_handle_gpio_create(gint pin, peripheral_h *handle, gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h gpio_handle;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h gpio_handle;
        int ret;
 
-       if (!__peripheral_handle_gpio_is_creatable(pin, pb_data)) {
+       if (!__peripheral_handle_gpio_is_creatable(pin, info)) {
                _E("gpio %d is not available", pin);
                return PERIPHERAL_ERROR_RESOURCE_BUSY;
        }
 
        // TODO : make fd list using the interface function
 
-       gpio_handle = peripheral_handle_new(&pb_data->gpio_list);
+       gpio_handle = peripheral_handle_new(&info->gpio_list);
        if (!gpio_handle) {
                _E("peripheral_handle_new error");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err;
        }
 
-       gpio_handle->type = PERIPHERAL_BUS_TYPE_GPIO;
-       gpio_handle->list = &pb_data->gpio_list;
-       gpio_handle->dev.gpio.pin = pin;
+       gpio_handle->list = &info->gpio_list;
+       gpio_handle->type.gpio.pin = pin;
 
        *handle = gpio_handle;
 
@@ -82,7 +81,7 @@ err:
        return ret;
 }
 
-int peripheral_handle_gpio_destroy(pb_data_h handle)
+int peripheral_handle_gpio_destroy(peripheral_h handle)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
index 0f089a58f018df42365fe30d4cac8c0c3a2f4505..ba97cda591f8f76c5489f0188dfcb886ba5d978f 100644 (file)
 #define INITIAL_BUFFER_SIZE 128
 #define MAX_BUFFER_SIZE 8192
 
-static bool __peripheral_handle_i2c_is_creatable(int bus, int address, peripheral_bus_s *pb_data)
+static bool __peripheral_handle_i2c_is_creatable(int bus, int address, peripheral_info_s *info)
 {
        pb_board_dev_s *i2c = NULL;
-       pb_data_h handle;
+       peripheral_h handle;
        GList *link;
 
-       RETV_IF(pb_data == NULL, false);
-       RETV_IF(pb_data->board == NULL, false);
+       RETV_IF(info == NULL, false);
+       RETV_IF(info->board == NULL, false);
 
-       i2c = peripheral_bus_board_find_device(PB_BOARD_DEV_I2C, pb_data->board, bus);
+       i2c = peripheral_bus_board_find_device(PB_BOARD_DEV_I2C, info->board, bus);
        if (i2c == NULL) {
                _E("Not supported I2C bus : %d", bus);
                return false;
        }
 
-       link = pb_data->i2c_list;
+       link = info->i2c_list;
        while (link) {
-               handle = (pb_data_h)link->data;
-               if (handle->dev.i2c.bus == bus && handle->dev.i2c.address == address) {
+               handle = (peripheral_h)link->data;
+               if (handle->type.i2c.bus == bus && handle->type.i2c.address == address) {
                        _E("Resource is in use, bus : %d, address : %d", bus, address);
                        return false;
                }
@@ -54,30 +54,29 @@ static bool __peripheral_handle_i2c_is_creatable(int bus, int address, periphera
        return true;
 }
 
-int peripheral_handle_i2c_create(int bus, int address, pb_data_h *handle, gpointer user_data)
+int peripheral_handle_i2c_create(int bus, int address, peripheral_h *handle, gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h i2c_handle;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h i2c_handle;
        int ret;
 
-       if (!__peripheral_handle_i2c_is_creatable(bus, address, pb_data)) {
+       if (!__peripheral_handle_i2c_is_creatable(bus, address, info)) {
                _E("bus : %d, address : 0x%x is not available", bus, address);
                return PERIPHERAL_ERROR_RESOURCE_BUSY;
        }
 
        // TODO : make fd list using the interface function
 
-       i2c_handle = peripheral_handle_new(&pb_data->i2c_list);
+       i2c_handle = peripheral_handle_new(&info->i2c_list);
        if (!i2c_handle) {
                _E("peripheral_handle_new error");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err;
        }
 
-       i2c_handle->type = PERIPHERAL_BUS_TYPE_I2C;
-       i2c_handle->list = &pb_data->i2c_list;
-       i2c_handle->dev.i2c.bus = bus;
-       i2c_handle->dev.i2c.address = address;
+       i2c_handle->list = &info->i2c_list;
+       i2c_handle->type.i2c.bus = bus;
+       i2c_handle->type.i2c.address = address;
 
        *handle = i2c_handle;
 
@@ -87,7 +86,7 @@ err:
        return ret;
 }
 
-int peripheral_handle_i2c_destroy(pb_data_h handle)
+int peripheral_handle_i2c_destroy(peripheral_h handle)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
index 0b0cd4de9eabc0b35a1249cf4b1056a338db2e36..0cc71c567b63a655d0c4fb3b7e60abca77ab1193 100644 (file)
 #include "peripheral_interface_pwm.h"
 #include "peripheral_handle_common.h"
 
-static bool __peripheral_handle_pwm_is_creatable(int chip, int pin, peripheral_bus_s *pb_data)
+static bool __peripheral_handle_pwm_is_creatable(int chip, int pin, peripheral_info_s *info)
 {
        pb_board_dev_s *pwm = NULL;
-       pb_data_h handle;
+       peripheral_h handle;
        GList *link;
 
-       RETV_IF(pb_data == NULL, false);
-       RETV_IF(pb_data->board == NULL, false);
+       RETV_IF(info == NULL, false);
+       RETV_IF(info->board == NULL, false);
 
-       pwm = peripheral_bus_board_find_device(PB_BOARD_DEV_PWM, pb_data->board, chip, pin);
+       pwm = peripheral_bus_board_find_device(PB_BOARD_DEV_PWM, info->board, chip, pin);
        if (pwm == NULL) {
                _E("Not supported PWM chip : %d, pin : %d", chip, pin);
                return false;
        }
 
-       link = pb_data->pwm_list;
+       link = info->pwm_list;
        while (link) {
-               handle = (pb_data_h)link->data;
-               if (handle->dev.pwm.chip == chip && handle->dev.pwm.pin == pin) {
+               handle = (peripheral_h)link->data;
+               if (handle->type.pwm.chip == chip && handle->type.pwm.pin == pin) {
                        _E("Resource is in use, chip : %d, pin : %d", chip, pin);
                        return false;
                }
@@ -51,30 +51,29 @@ static bool __peripheral_handle_pwm_is_creatable(int chip, int pin, peripheral_b
        return true;
 }
 
-int peripheral_handle_pwm_create(int chip, int pin, pb_data_h *handle, gpointer user_data)
+int peripheral_handle_pwm_create(int chip, int pin, peripheral_h *handle, gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h pwm_handle;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h pwm_handle;
        int ret;
 
-       if (!__peripheral_handle_pwm_is_creatable(chip, pin, pb_data)) {
+       if (!__peripheral_handle_pwm_is_creatable(chip, pin, info)) {
                _E("pwm %d.%d is not available", chip, pin);
                return PERIPHERAL_ERROR_RESOURCE_BUSY;
        }
 
        // TODO : make fd list using the interface function
 
-       pwm_handle = peripheral_handle_new(&pb_data->pwm_list);
+       pwm_handle = peripheral_handle_new(&info->pwm_list);
        if (!pwm_handle) {
                _E("peripheral_handle_new error");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err;
        }
 
-       pwm_handle->type = PERIPHERAL_BUS_TYPE_PWM;
-       pwm_handle->list = &pb_data->pwm_list;
-       pwm_handle->dev.pwm.chip = chip;
-       pwm_handle->dev.pwm.pin = pin;
+       pwm_handle->list = &info->pwm_list;
+       pwm_handle->type.pwm.chip = chip;
+       pwm_handle->type.pwm.pin = pin;
        *handle = pwm_handle;
 
        return PERIPHERAL_ERROR_NONE;
@@ -83,7 +82,7 @@ err:
        return ret;
 }
 
-int peripheral_handle_pwm_destroy(pb_data_h handle)
+int peripheral_handle_pwm_destroy(peripheral_h handle)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
index 93243ffe3dce8b3a2ee038cb8499ada20ef890b1..fe7a2b6c9bb7a375dd1365084c5587c23baef560 100644 (file)
 #include "peripheral_interface_spi.h"
 #include "peripheral_handle_common.h"
 
-static bool __peripheral_handle_spi_is_creatable(int bus, int cs, peripheral_bus_s *pb_data)
+static bool __peripheral_handle_spi_is_creatable(int bus, int cs, peripheral_info_s *info)
 {
        pb_board_dev_s *spi = NULL;
-       pb_data_h handle;
+       peripheral_h handle;
        GList *link;
 
-       RETV_IF(pb_data == NULL, false);
-       RETV_IF(pb_data->board == NULL, false);
+       RETV_IF(info == NULL, false);
+       RETV_IF(info->board == NULL, false);
 
-       spi = peripheral_bus_board_find_device(PB_BOARD_DEV_SPI, pb_data->board, bus, cs);
+       spi = peripheral_bus_board_find_device(PB_BOARD_DEV_SPI, info->board, bus, cs);
        if (spi == NULL) {
                _E("Not supported SPI bus : %d, cs : %d", bus, cs);
                return false;
        }
 
-       link = pb_data->spi_list;
+       link = info->spi_list;
        while (link) {
-               handle = (pb_data_h)link->data;
-               if (handle->dev.spi.bus == bus && handle->dev.spi.cs == cs) {
+               handle = (peripheral_h)link->data;
+               if (handle->type.spi.bus == bus && handle->type.spi.cs == cs) {
                        _E("Resource is in use, bus : %d, cs : %d", bus, cs);
                        return false;
                }
@@ -51,30 +51,29 @@ static bool __peripheral_handle_spi_is_creatable(int bus, int cs, peripheral_bus
        return true;
 }
 
-int peripheral_handle_spi_create(int bus, int cs, pb_data_h *handle, gpointer user_data)
+int peripheral_handle_spi_create(int bus, int cs, peripheral_h *handle, gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h spi_handle;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h spi_handle;
        int ret = PERIPHERAL_ERROR_NONE;
 
-       if (!__peripheral_handle_spi_is_creatable(bus, cs, pb_data)) {
+       if (!__peripheral_handle_spi_is_creatable(bus, cs, info)) {
                _E("spi %d.%d is not available", bus, cs);
                return PERIPHERAL_ERROR_RESOURCE_BUSY;
        }
 
        // TODO : make fd list using the interface function
 
-       spi_handle = peripheral_handle_new(&pb_data->spi_list);
+       spi_handle = peripheral_handle_new(&info->spi_list);
        if (!spi_handle) {
                _E("peripheral_handle_new error");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err_spi_data;
        }
 
-       spi_handle->type = PERIPHERAL_BUS_TYPE_SPI;
-       spi_handle->list = &pb_data->spi_list;
-       spi_handle->dev.spi.bus = bus;
-       spi_handle->dev.spi.cs = cs;
+       spi_handle->list = &info->spi_list;
+       spi_handle->type.spi.bus = bus;
+       spi_handle->type.spi.cs = cs;
 
        *handle = spi_handle;
 
@@ -84,7 +83,7 @@ err_spi_data:
        return ret;
 }
 
-int peripheral_handle_spi_destroy(pb_data_h handle)
+int peripheral_handle_spi_destroy(peripheral_h handle)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
index 38b9fbb43793571bdd866ae41fd3c38cf8af9818..ae92440a6a9482a270a26d1255b0085128d8157e 100644 (file)
 #define INITIAL_BUFFER_SIZE 128
 #define MAX_BUFFER_SIZE 8192
 
-static bool __peripheral_handle_uart_is_creatable(int port, peripheral_bus_s *pb_data)
+static bool __peripheral_handle_uart_is_creatable(int port, peripheral_info_s *info)
 {
        pb_board_dev_s *uart = NULL;
-       pb_data_h handle;
+       peripheral_h handle;
        GList *link;
 
-       RETV_IF(pb_data == NULL, false);
-       RETV_IF(pb_data->board == NULL, false);
+       RETV_IF(info == NULL, false);
+       RETV_IF(info->board == NULL, false);
 
-       uart = peripheral_bus_board_find_device(PB_BOARD_DEV_UART, pb_data->board, port);
+       uart = peripheral_bus_board_find_device(PB_BOARD_DEV_UART, info->board, port);
        if (uart == NULL) {
                _E("Not supported UART port : %d", port);
                return false;
        }
 
-       link = pb_data->uart_list;
+       link = info->uart_list;
        while (link) {
-               handle = (pb_data_h)link->data;
-               if (handle->dev.uart.port == port) {
+               handle = (peripheral_h)link->data;
+               if (handle->type.uart.port == port) {
                        _E("Resource is in use, port : %d", port);
                        return false;
                }
@@ -54,29 +54,28 @@ static bool __peripheral_handle_uart_is_creatable(int port, peripheral_bus_s *pb
        return true;
 }
 
-int peripheral_handle_uart_open(int port, pb_data_h *handle, gpointer user_data)
+int peripheral_handle_uart_open(int port, peripheral_h *handle, gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
-       pb_data_h uart_handle;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
+       peripheral_h uart_handle;
        int ret = PERIPHERAL_ERROR_NONE;
 
-       if (!__peripheral_handle_uart_is_creatable(port, pb_data)) {
+       if (!__peripheral_handle_uart_is_creatable(port, info)) {
                _E("uart %d is not available", port);
                return PERIPHERAL_ERROR_RESOURCE_BUSY;
        }
 
        // TODO : make fd list using the interface function
 
-       uart_handle = peripheral_handle_new(&pb_data->uart_list);
+       uart_handle = peripheral_handle_new(&info->uart_list);
        if (!uart_handle) {
                _E("peripheral_handle_new error");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err;
        }
 
-       uart_handle->type = PERIPHERAL_BUS_TYPE_UART;
-       uart_handle->list = &pb_data->uart_list;
-       uart_handle->dev.uart.port = port;
+       uart_handle->list = &info->uart_list;
+       uart_handle->type.uart.port = port;
 
        *handle = uart_handle;
 
@@ -86,7 +85,7 @@ err:
        return ret;
 }
 
-int peripheral_handle_uart_destroy(pb_data_h handle)
+int peripheral_handle_uart_destroy(peripheral_h handle)
 {
        int ret = PERIPHERAL_ERROR_NONE;
 
index ffda8746af93ebbca27918a76c80deaaffc7726c..ec9ce4d1d705d6386561b688930142fa3c53c348 100644 (file)
 #define PERIPHERAL_GDBUS_SPI_PATH      "/Org/Tizen/Peripheral_io/Spi"
 #define PERIPHERAL_GDBUS_NAME          "org.tizen.peripheral_io"
 
-static gboolean __gpio_init(peripheral_bus_s *pb_data)
+static gboolean __gpio_init(peripheral_info_s *info)
 {
        GDBusObjectManagerServer *manager;
        gboolean ret = FALSE;
        GError *error = NULL;
 
        /* Add interface to default object path */
-       pb_data->gpio_skeleton = peripheral_io_gdbus_gpio_skeleton_new();
+       info->gpio_skeleton = peripheral_io_gdbus_gpio_skeleton_new();
        /* Register for method callbacks as signal callbacks */
-       g_signal_connect(pb_data->gpio_skeleton,
+       g_signal_connect(info->gpio_skeleton,
                        "handle-open",
                        G_CALLBACK(handle_gpio_open),
-                       pb_data);
+                       info);
 
        manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_GPIO_PATH);
 
        /* Set connection to 'manager' */
-       g_dbus_object_manager_server_set_connection(manager, pb_data->connection);
+       g_dbus_object_manager_server_set_connection(manager, info->connection);
 
        /* Export 'manager' interface on peripheral-io DBUS */
        ret = g_dbus_interface_skeleton_export(
-               G_DBUS_INTERFACE_SKELETON(pb_data->gpio_skeleton),
-               pb_data->connection, PERIPHERAL_GDBUS_GPIO_PATH, &error);
+               G_DBUS_INTERFACE_SKELETON(info->gpio_skeleton),
+               info->connection, PERIPHERAL_GDBUS_GPIO_PATH, &error);
 
        if (ret == FALSE) {
                _E("Can not skeleton_export %s", error->message);
@@ -71,28 +71,28 @@ static gboolean __gpio_init(peripheral_bus_s *pb_data)
        return true;
 }
 
-static gboolean __i2c_init(peripheral_bus_s *pb_data)
+static gboolean __i2c_init(peripheral_info_s *info)
 {
        GDBusObjectManagerServer *manager;
        gboolean ret = FALSE;
        GError *error = NULL;
 
        /* Add interface to default object path */
-       pb_data->i2c_skeleton = peripheral_io_gdbus_i2c_skeleton_new();
-       g_signal_connect(pb_data->i2c_skeleton,
+       info->i2c_skeleton = peripheral_io_gdbus_i2c_skeleton_new();
+       g_signal_connect(info->i2c_skeleton,
                        "handle-open",
                        G_CALLBACK(handle_i2c_open),
-                       pb_data);
+                       info);
 
        manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_I2C_PATH);
 
        /* Set connection to 'manager' */
-       g_dbus_object_manager_server_set_connection(manager, pb_data->connection);
+       g_dbus_object_manager_server_set_connection(manager, info->connection);
 
        /* Export 'manager' interface on peripheral-io DBUS */
        ret = g_dbus_interface_skeleton_export(
-               G_DBUS_INTERFACE_SKELETON(pb_data->i2c_skeleton),
-               pb_data->connection, PERIPHERAL_GDBUS_I2C_PATH, &error);
+               G_DBUS_INTERFACE_SKELETON(info->i2c_skeleton),
+               info->connection, PERIPHERAL_GDBUS_I2C_PATH, &error);
 
        if (ret == FALSE) {
                _E("Can not skeleton_export %s", error->message);
@@ -102,28 +102,28 @@ static gboolean __i2c_init(peripheral_bus_s *pb_data)
        return true;
 }
 
-static gboolean __pwm_init(peripheral_bus_s *pb_data)
+static gboolean __pwm_init(peripheral_info_s *info)
 {
        GDBusObjectManagerServer *manager;
        gboolean ret = FALSE;
        GError *error = NULL;
 
        /* Add interface to default object path */
-       pb_data->pwm_skeleton = peripheral_io_gdbus_pwm_skeleton_new();
-       g_signal_connect(pb_data->pwm_skeleton,
+       info->pwm_skeleton = peripheral_io_gdbus_pwm_skeleton_new();
+       g_signal_connect(info->pwm_skeleton,
                        "handle-open",
                        G_CALLBACK(handle_pwm_open),
-                       pb_data);
+                       info);
 
        manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_PWM_PATH);
 
        /* Set connection to 'manager' */
-       g_dbus_object_manager_server_set_connection(manager, pb_data->connection);
+       g_dbus_object_manager_server_set_connection(manager, info->connection);
 
        /* Export 'manager' interface on peripheral-io DBUS */
        ret = g_dbus_interface_skeleton_export(
-               G_DBUS_INTERFACE_SKELETON(pb_data->pwm_skeleton),
-               pb_data->connection, PERIPHERAL_GDBUS_PWM_PATH, &error);
+               G_DBUS_INTERFACE_SKELETON(info->pwm_skeleton),
+               info->connection, PERIPHERAL_GDBUS_PWM_PATH, &error);
 
        if (ret == FALSE) {
                _E("Can not skeleton_export %s", error->message);
@@ -133,28 +133,28 @@ static gboolean __pwm_init(peripheral_bus_s *pb_data)
        return true;
 }
 
-static gboolean __uart_init(peripheral_bus_s *pb_data)
+static gboolean __uart_init(peripheral_info_s *info)
 {
        GDBusObjectManagerServer *manager;
        gboolean ret = FALSE;
        GError *error = NULL;
 
        /* Add interface to default object path */
-       pb_data->uart_skeleton = peripheral_io_gdbus_uart_skeleton_new();
-       g_signal_connect(pb_data->uart_skeleton,
+       info->uart_skeleton = peripheral_io_gdbus_uart_skeleton_new();
+       g_signal_connect(info->uart_skeleton,
                        "handle-open",
                        G_CALLBACK(handle_uart_open),
-                       pb_data);
+                       info);
 
        manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_UART_PATH);
 
        /* Set connection to 'manager' */
-       g_dbus_object_manager_server_set_connection(manager, pb_data->connection);
+       g_dbus_object_manager_server_set_connection(manager, info->connection);
 
        /* Export 'manager' interface on peripheral-io DBUS */
        ret = g_dbus_interface_skeleton_export(
-               G_DBUS_INTERFACE_SKELETON(pb_data->uart_skeleton),
-               pb_data->connection, PERIPHERAL_GDBUS_UART_PATH, &error);
+               G_DBUS_INTERFACE_SKELETON(info->uart_skeleton),
+               info->connection, PERIPHERAL_GDBUS_UART_PATH, &error);
 
        if (ret == FALSE) {
                _E("Can not skeleton_export %s", error->message);
@@ -164,28 +164,28 @@ static gboolean __uart_init(peripheral_bus_s *pb_data)
        return true;
 }
 
-static gboolean __spi_init(peripheral_bus_s *pb_data)
+static gboolean __spi_init(peripheral_info_s *info)
 {
        GDBusObjectManagerServer *manager;
        gboolean ret = FALSE;
        GError *error = NULL;
 
        /* Add interface to default object path */
-       pb_data->spi_skeleton = peripheral_io_gdbus_spi_skeleton_new();
-       g_signal_connect(pb_data->spi_skeleton,
+       info->spi_skeleton = peripheral_io_gdbus_spi_skeleton_new();
+       g_signal_connect(info->spi_skeleton,
                        "handle-open",
                        G_CALLBACK(handle_spi_open),
-                       pb_data);
+                       info);
 
        manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_SPI_PATH);
 
        /* Set connection to 'manager' */
-       g_dbus_object_manager_server_set_connection(manager, pb_data->connection);
+       g_dbus_object_manager_server_set_connection(manager, info->connection);
 
        /* Export 'manager' interface on peripheral-io DBUS */
        ret = g_dbus_interface_skeleton_export(
-               G_DBUS_INTERFACE_SKELETON(pb_data->spi_skeleton),
-               pb_data->connection, PERIPHERAL_GDBUS_SPI_PATH, &error);
+               G_DBUS_INTERFACE_SKELETON(info->spi_skeleton),
+               info->connection, PERIPHERAL_GDBUS_SPI_PATH, &error);
 
        if (ret == FALSE) {
                _E("Can not skeleton_export %s", error->message);
@@ -199,23 +199,23 @@ static void on_bus_acquired(GDBusConnection *connection,
                                                        const gchar *name,
                                                        gpointer user_data)
 {
-       peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data;
+       peripheral_info_s *info = (peripheral_info_s*)user_data;
 
-       pb_data->connection = connection;
+       info->connection = connection;
 
-       if (__gpio_init(pb_data) == FALSE)
+       if (__gpio_init(info) == FALSE)
                _E("Can not signal connect");
 
-       if (__i2c_init(pb_data) == FALSE)
+       if (__i2c_init(info) == FALSE)
                _E("Can not signal connect");
 
-       if (__pwm_init(pb_data) == FALSE)
+       if (__pwm_init(info) == FALSE)
                _E("Can not signal connect");
 
-       if (__uart_init(pb_data) == FALSE)
+       if (__uart_init(info) == FALSE)
                _E("Can not signal connect");
 
-       if (__spi_init(pb_data) == FALSE)
+       if (__spi_init(info) == FALSE)
                _E("Can not signal connect");
 }
 
@@ -242,16 +242,16 @@ int main(int argc, char *argv[])
 {
        GMainLoop *loop;
        guint owner_id = 0;
-       peripheral_bus_s *pb_data;
+       peripheral_info_s *info;
 
-       pb_data = (peripheral_bus_s*)calloc(1, sizeof(peripheral_bus_s));
-       if (pb_data == NULL) {
-               _E("failed to allocate peripheral_bus_s");
+       info = (peripheral_info_s*)calloc(1, sizeof(peripheral_info_s));
+       if (info == NULL) {
+               _E("failed to allocate peripheral_info_s");
                return -1;
        }
 
-       pb_data->board = peripheral_bus_board_init();
-       if (pb_data->board == NULL) {
+       info->board = peripheral_bus_board_init();
+       if (info->board == NULL) {
                _E("failed to init board");
                return -1;
        }
@@ -263,11 +263,11 @@ int main(int argc, char *argv[])
                                                          on_bus_acquired,
                                                          on_name_acquired,
                                                          on_name_lost,
-                                                         pb_data,
+                                                         info,
                                                          NULL);
        if (!owner_id) {
                _E("g_bus_own_name_error");
-               free(pb_data);
+               free(info);
                return -1;
        }
 
@@ -282,9 +282,9 @@ int main(int argc, char *argv[])
 
        peripheral_privilege_deinit();
 
-       if (pb_data) {
-               peripheral_bus_board_deinit(pb_data->board);
-               free(pb_data);
+       if (info) {
+               peripheral_bus_board_deinit(info->board);
+               free(info);
        }
 
        if (loop != NULL)