i2c: completely remove gdbus
authorAdrian Szyndela <adrian.s@samsung.com>
Fri, 11 Jun 2021 08:39:41 +0000 (10:39 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 11 Jun 2021 08:39:41 +0000 (10:39 +0200)
CMakeLists.txt
include/gdbus/peripheral_gdbus_i2c.h [deleted file]
include/peripheral_handle.h
src/gdbus/peripheral_gdbus_i2c.c [deleted file]
src/peripheral_i2c.c

index 8767b29..84dd024 100644 (file)
@@ -69,7 +69,6 @@ SET(SOURCES src/peripheral_gpio.c
                        src/interface/peripheral_interface_spi.c
                        src/interface/peripheral_interface_uart.c
                        src/gdbus/peripheral_gdbus_gpio.c
-                       src/gdbus/peripheral_gdbus_i2c.c
                        src/gdbus/peripheral_gdbus_pwm.c
                        src/gdbus/peripheral_gdbus_adc.c
                        src/gdbus/peripheral_gdbus_uart.c
diff --git a/include/gdbus/peripheral_gdbus_i2c.h b/include/gdbus/peripheral_gdbus_i2c.h
deleted file mode 100644 (file)
index 643d7c8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __PERIPHERAL_GDBUS_I2C_H__
-#define __PERIPHERAL_GDBUS_I2C_H__
-
-#include "peripheral_gdbus_common.h"
-
-int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
-int peripheral_gdbus_i2c_open_flags(peripheral_i2c_h i2c, int bus, int address, int flags);
-int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c);
-
-#endif /* __PERIPHERAL_GDBUS_I2C_H__ */
index b3ca528..b766364 100644 (file)
@@ -54,7 +54,6 @@ struct _peripheral_gpio_s {
  * @brief Internal struct for i2c context
  */
 struct _peripheral_i2c_s {
-       uint handle;
        int fd;
 };
 
diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c
deleted file mode 100644 (file)
index fe3a5f7..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "peripheral_gdbus_i2c.h"
-
-#define I2C_FD_INDEX 0
-
-static PeripheralIoGdbusI2c *i2c_proxy = NULL;
-
-static int __i2c_proxy_init(void)
-{
-       GError *error = NULL;
-
-       if (i2c_proxy != NULL) {
-               _E("I2c proxy is already created");
-               g_object_ref(i2c_proxy);
-               return PERIPHERAL_ERROR_NONE;
-       }
-
-       i2c_proxy = peripheral_io_gdbus_i2c_proxy_new_for_bus_sync(
-               G_BUS_TYPE_SYSTEM,
-               G_DBUS_PROXY_FLAGS_NONE,
-               PERIPHERAL_GDBUS_NAME,
-               PERIPHERAL_GDBUS_I2C_PATH,
-               NULL,
-               &error);
-
-       if (i2c_proxy == NULL) {
-               if (error) {
-                       _E("Failed to create i2c proxy : %s", error->message);
-                       g_error_free(error);
-               }
-               return PERIPHERAL_ERROR_IO_ERROR;
-       }
-
-       return PERIPHERAL_ERROR_NONE;
-}
-
-static int __i2c_proxy_deinit(void)
-{
-       RETVM_IF(i2c_proxy == NULL, PERIPHERAL_ERROR_IO_ERROR, "I2c proxy is NULL");
-
-       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)
-{
-       int ret;
-       GError *error = NULL;
-       GUnixFDList *fd_list = NULL;
-
-       ret = __i2c_proxy_init();
-       if (ret != PERIPHERAL_ERROR_NONE)
-               return ret;
-
-       if (peripheral_io_gdbus_i2c_call_open_sync(
-                       i2c_proxy,
-                       bus,
-                       address,
-                       NULL,
-                       &i2c->handle,
-                       &ret,
-                       &fd_list,
-                       NULL,
-                       &error) == FALSE) {
-               _E("Failed to request daemon to i2c open : %s", error->message);
-               g_error_free(error);
-               return PERIPHERAL_ERROR_IO_ERROR;
-       }
-
-       // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
-       if (ret != PERIPHERAL_ERROR_NONE)
-               return ret;
-
-       i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error);
-       if (i2c->fd < 0) {
-               _E("Failed to get fd for i2c : %s", error->message);
-               g_error_free(error);
-               ret = PERIPHERAL_ERROR_IO_ERROR;
-       }
-
-       g_object_unref(fd_list);
-
-       return ret;
-}
-
-int peripheral_gdbus_i2c_open_flags(peripheral_i2c_h i2c, int bus, int address, int flags)
-{
-       int ret;
-       GError *error = NULL;
-       GUnixFDList *fd_list = NULL;
-
-       ret = __i2c_proxy_init();
-       if (ret != PERIPHERAL_ERROR_NONE)
-               return ret;
-
-       if (peripheral_io_gdbus_i2c_call_open_flags_sync(
-                       i2c_proxy,
-                       bus,
-                       address,
-                       flags,
-                       NULL,
-                       &i2c->handle,
-                       &ret,
-                       &fd_list,
-                       NULL,
-                       &error) == FALSE) {
-               _E("Failed to request daemon to i2c open : %s", error->message);
-               g_error_free(error);
-               return PERIPHERAL_ERROR_IO_ERROR;
-       }
-
-       // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon.
-       if (ret != PERIPHERAL_ERROR_NONE)
-               return ret;
-
-       i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error);
-       if (i2c->fd < 0) {
-               _E("Failed to get fd for i2c : %s", error->message);
-               g_error_free(error);
-               ret = PERIPHERAL_ERROR_IO_ERROR;
-       }
-
-       g_object_unref(fd_list);
-
-       return ret;
-}
-
-int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c)
-{
-       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;
-}
index 324f8bd..c910306 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "peripheral_io.h"
 #include "peripheral_handle.h"
-#include "peripheral_gdbus_i2c.h"
 #include "peripheral_interface_i2c.h"
 #include "peripheral_direct_i2c.h"
 #include "peripheral_log.h"
@@ -98,7 +97,7 @@ int peripheral_i2c_open_flags(int bus, int address, peripheral_open_flags_e flag
                return PERIPHERAL_ERROR_OUT_OF_MEMORY;
        }
 
-       ret = peripheral_gdbus_i2c_open_flags(handle, bus, address, flags);
+       ret = peripheral_direct_i2c_open(bus, address, &handle->fd);
        if (ret != PERIPHERAL_ERROR_NONE) {
                _E("Failed to open i2c communication, ret : %d", ret);
                free(handle);
@@ -117,10 +116,6 @@ int peripheral_i2c_close(peripheral_i2c_h i2c)
        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);
-       // if (ret != PERIPHERAL_ERROR_NONE)
-       //         _E("Failed to close i2c communcation, ret : %d", ret);
-
        peripheral_interface_i2c_close(i2c);
 
        free(i2c);