From 7c55af228094240f6f1632410b9b40ca511adb2d Mon Sep 17 00:00:00 2001 From: Hyeongsik Min Date: Mon, 1 May 2017 20:21:09 +0900 Subject: [PATCH] Put i2c/pwm_skeleton variable to pb_data Change-Id: I7f55e22e159e705cafc2a952b8877ea0d5b8b3b7 Signed-off-by: Hyeongsik Min --- src/daemon/peripheral_bus.c | 48 ++++++++++++++++++++++----------------------- src/daemon/peripheral_bus.h | 2 ++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/daemon/peripheral_bus.c b/src/daemon/peripheral_bus.c index bb2db5d..f138ae4 100644 --- a/src/daemon/peripheral_bus.c +++ b/src/daemon/peripheral_bus.c @@ -487,28 +487,27 @@ static gboolean __gpio_init(peripheral_bus_s *pb_data) return true; } -static gboolean __i2c_init(GDBusConnection *connection) +static gboolean __i2c_init(peripheral_bus_s *pb_data) { GDBusObjectManagerServer *manager; - PeripheralIoGdbusI2c *i2c_skeleton; gboolean ret = FALSE; GError *error = NULL; /* Add interface to default object path */ - i2c_skeleton = peripheral_io_gdbus_i2c_skeleton_new(); - g_signal_connect(i2c_skeleton, + pb_data->i2c_skeleton = peripheral_io_gdbus_i2c_skeleton_new(); + g_signal_connect(pb_data->i2c_skeleton, "handle-open", G_CALLBACK(handle_i2c_open), NULL); - g_signal_connect(i2c_skeleton, + g_signal_connect(pb_data->i2c_skeleton, "handle-close", G_CALLBACK(handle_i2c_close), NULL); - g_signal_connect(i2c_skeleton, + g_signal_connect(pb_data->i2c_skeleton, "handle-read", G_CALLBACK(handle_i2c_read), NULL); - g_signal_connect(i2c_skeleton, + g_signal_connect(pb_data->i2c_skeleton, "handle-write", G_CALLBACK(handle_i2c_write), NULL); @@ -516,12 +515,12 @@ static gboolean __i2c_init(GDBusConnection *connection) manager = g_dbus_object_manager_server_new(PERIPHERAL_DBUS_I2C_PATH); /* Set connection to 'manager' */ - g_dbus_object_manager_server_set_connection(manager, connection); + g_dbus_object_manager_server_set_connection(manager, pb_data->connection); /* Export 'manager' interface on peripheral-io DBUS */ ret = g_dbus_interface_skeleton_export( - G_DBUS_INTERFACE_SKELETON(i2c_skeleton), - connection, PERIPHERAL_DBUS_I2C_PATH, &error); + G_DBUS_INTERFACE_SKELETON(pb_data->i2c_skeleton), + pb_data->connection, PERIPHERAL_DBUS_I2C_PATH, &error); if (ret == FALSE) { _E("Can not skeleton_export %s", error->message); @@ -531,40 +530,39 @@ static gboolean __i2c_init(GDBusConnection *connection) return true; } -static gboolean __pwm_init(GDBusConnection *connection) +static gboolean __pwm_init(peripheral_bus_s *pb_data) { GDBusObjectManagerServer *manager; - PeripheralIoGdbusPwm *pwm_skeleton; gboolean ret = FALSE; GError *error = NULL; /* Add interface to default object path */ - pwm_skeleton = peripheral_io_gdbus_pwm_skeleton_new(); - g_signal_connect(pwm_skeleton, + pb_data->pwm_skeleton = peripheral_io_gdbus_pwm_skeleton_new(); + g_signal_connect(pb_data->pwm_skeleton, "handle-open", G_CALLBACK(handle_pwm_open), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-close", G_CALLBACK(handle_pwm_close), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-set-duty-cycle", G_CALLBACK(handle_pwm_set_duty_cycle), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-set-period", G_CALLBACK(handle_pwm_set_period), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-set-enable", G_CALLBACK(handle_pwm_set_enable), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-get-duty", G_CALLBACK(handle_pwm_get_duty_cycle), NULL); - g_signal_connect(pwm_skeleton, + g_signal_connect(pb_data->pwm_skeleton, "handle-get-period", G_CALLBACK(handle_pwm_get_period), NULL); @@ -572,12 +570,12 @@ static gboolean __pwm_init(GDBusConnection *connection) manager = g_dbus_object_manager_server_new(PERIPHERAL_DBUS_PWM_PATH); /* Set connection to 'manager' */ - g_dbus_object_manager_server_set_connection(manager, connection); + g_dbus_object_manager_server_set_connection(manager, pb_data->connection); /* Export 'manager' interface on peripheral-io DBUS */ ret = g_dbus_interface_skeleton_export( - G_DBUS_INTERFACE_SKELETON(pwm_skeleton), - connection, PERIPHERAL_DBUS_PWM_PATH, &error); + G_DBUS_INTERFACE_SKELETON(pb_data->pwm_skeleton), + pb_data->connection, PERIPHERAL_DBUS_PWM_PATH, &error); if (ret == FALSE) { _E("Can not skeleton_export %s", error->message); @@ -597,10 +595,10 @@ static void on_bus_acquired(GDBusConnection *connection, if (__gpio_init(pb_data) == FALSE) _E("Can not signal connect"); - if (__i2c_init(connection) == FALSE) + if (__i2c_init(pb_data) == FALSE) _E("Can not signal connect"); - if (__pwm_init(connection) == FALSE) + if (__pwm_init(pb_data) == FALSE) _E("Can not signal connect"); } diff --git a/src/daemon/peripheral_bus.h b/src/daemon/peripheral_bus.h index a79c7d7..c8f1af0 100644 --- a/src/daemon/peripheral_bus.h +++ b/src/daemon/peripheral_bus.h @@ -27,6 +27,8 @@ typedef struct { guint reg_id; GDBusConnection *connection; PeripheralIoGdbusGpio *gpio_skeleton; + PeripheralIoGdbusI2c *i2c_skeleton; + PeripheralIoGdbusPwm *pwm_skeleton; } peripheral_bus_s; typedef struct { -- 2.7.4