move and remove private headers 55/260355/6
authorAdrian Szyndela <adrian.s@samsung.com>
Wed, 23 Jun 2021 15:17:50 +0000 (17:17 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 25 Jun 2021 14:55:39 +0000 (16:55 +0200)
Leave only public header in include/.
Remove peripheral_handle.h by moving struct definitions into
respective source files.

Change-Id: I7a5042fbf68667499a1247bc8efcf704447e1d4d

include/interface/peripheral_interface_common.h [deleted file]
include/peripheral_handle.h [deleted file]
include/peripheral_log.h [deleted file]
src/common.h [new file with mode: 0644]
src/log.h [new file with mode: 0644]
src/peripheral_adc.c
src/peripheral_gpio.c
src/peripheral_i2c.c
src/peripheral_pwm.c
src/peripheral_spi.c
src/peripheral_uart.c

diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h
deleted file mode 100644 (file)
index 675c3fb..0000000
+++ /dev/null
@@ -1,49 +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_INTERFACE_COMMON_H__
-#define __PERIPHERAL_INTERFACE_COMMON_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "peripheral_io.h"
-#include "peripheral_handle.h"
-#include "peripheral_log.h"
-
-#define MAX_ERR_LEN 255
-
-#define CHECK_ERROR(expr) \
-       do { \
-               if (expr) { \
-                       if (errno == EAGAIN) \
-                               return PERIPHERAL_ERROR_TRY_AGAIN; \
-                       if (errno == EINVAL) \
-                               return PERIPHERAL_ERROR_INVALID_PARAMETER; \
-                       char errmsg[MAX_ERR_LEN]; \
-                       strerror_r(errno, errmsg, sizeof(errmsg)); \
-                       _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
-                       return PERIPHERAL_ERROR_IO_ERROR; \
-               } \
-       } while (0)
-
-typedef struct predefined_type {
-       char *type;
-       int len;
-} predefined_type_s;
-
-#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/
diff --git a/include/peripheral_handle.h b/include/peripheral_handle.h
deleted file mode 100644 (file)
index 4585021..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2017-2018 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_HANDLE_H__
-#define __PERIPHERAL_HANDLE_H__
-
-#include <gio/gio.h>
-#include "peripheral_io.h"
-
-typedef struct _peripheral_gpio_interrupted_cb_info_s {
-       // vermagic value is used to verify structure inside csapi
-       // do not move it and value field to different place inside structure
-       // otherwise update csapi accordingly
-       int vermagic;
-       int value;
-       GThread *thread;
-       peripheral_gpio_interrupted_cb cb;
-       peripheral_error_e error;
-       void *user_data;
-       gint status;
-} interrupted_cb_info_s;
-
-/**
- * @brief Internal struct for gpio context
- */
-struct _peripheral_gpio_s {
-       // vermagic value is used to verify structure inside csapi
-       // do not move it and callback info field to different place inside structure
-       // otherwise update csapi accordingly
-       int vermagic;
-       interrupted_cb_info_s cb_info;
-       int pin;
-       int fd_direction;
-       int fd_edge;
-       int fd_value;
-       peripheral_gpio_direction_e direction;
-       peripheral_gpio_edge_e edge;
-};
-
-/**
- * @brief Internal struct for i2c context
- */
-struct _peripheral_i2c_s {
-       int fd;
-};
-
-/**
- * @brief Internal struct for pwm context
- */
-struct _peripheral_pwm_s {
-       int chip;
-       int pin;
-       int fd_period;
-       int fd_duty_cycle;
-       int fd_polarity;
-       int fd_enable;
-};
-
-/**
- * @brief Internal struct for adc context
- */
-struct _peripheral_adc_s {
-       int fd;
-};
-
-/**
- * @brief Internal struct for uart context
- */
-struct _peripheral_uart_s {
-       int fd;
-};
-
-/**
- * @brief Internal struct for spi context
- */
-struct _peripheral_spi_s {
-       int fd;
-};
-
-#endif /* __PERIPHERAL_HANDLE_H__ */
diff --git a/include/peripheral_log.h b/include/peripheral_log.h
deleted file mode 100644 (file)
index c5702d3..0000000
+++ /dev/null
@@ -1,58 +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_COMMON_H__
-#define __PERIPHERAL_COMMON_H__
-
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "PERIPHERAL-IO"
-
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
-#define _W(fmt, arg...) LOGW(fmt, ##arg)
-
-#define RET_IF(expr) \
-       do { \
-               if (expr) { \
-                       _E("(%s)", #expr); \
-                       return; \
-               } \
-       } while (0)
-#define RETV_IF(expr, val) \
-       do {\
-               if (expr) { \
-                       _E("(%s)", #expr); \
-                       return (val); \
-               } \
-       } while (0)
-#define RETM_IF(expr, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       _E(fmt, ##arg); \
-                       return; \
-               } \
-       } while (0)
-#define RETVM_IF(expr, val, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       _E(fmt, ##arg); \
-                       return (val); \
-               } \
-       } while (0)
-
-#endif /* __PERIPHERAL_COMMON_H__ */
diff --git a/src/common.h b/src/common.h
new file mode 100644 (file)
index 0000000..77ff0f7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_INTERFACE_COMMON_H__
+#define __PERIPHERAL_INTERFACE_COMMON_H__
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "log.h"
+
+#define MAX_ERR_LEN 255
+
+#define CHECK_ERROR(expr) \
+       do { \
+               if (expr) { \
+                       if (errno == EAGAIN) \
+                               return PERIPHERAL_ERROR_TRY_AGAIN; \
+                       if (errno == EINVAL) \
+                               return PERIPHERAL_ERROR_INVALID_PARAMETER; \
+                       char errmsg[MAX_ERR_LEN]; \
+                       strerror_r(errno, errmsg, sizeof(errmsg)); \
+                       _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
+                       return PERIPHERAL_ERROR_IO_ERROR; \
+               } \
+       } while (0)
+
+typedef struct predefined_type {
+       char *type;
+       int len;
+} predefined_type_s;
+
+#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/
diff --git a/src/log.h b/src/log.h
new file mode 100644 (file)
index 0000000..c5702d3
--- /dev/null
+++ b/src/log.h
@@ -0,0 +1,58 @@
+/*
+ * 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_COMMON_H__
+#define __PERIPHERAL_COMMON_H__
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "PERIPHERAL-IO"
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+
+#define RET_IF(expr) \
+       do { \
+               if (expr) { \
+                       _E("(%s)", #expr); \
+                       return; \
+               } \
+       } while (0)
+#define RETV_IF(expr, val) \
+       do {\
+               if (expr) { \
+                       _E("(%s)", #expr); \
+                       return (val); \
+               } \
+       } while (0)
+#define RETM_IF(expr, fmt, arg...) \
+       do {\
+               if (expr) { \
+                       _E(fmt, ##arg); \
+                       return; \
+               } \
+       } while (0)
+#define RETVM_IF(expr, val, fmt, arg...) \
+       do {\
+               if (expr) { \
+                       _E(fmt, ##arg); \
+                       return (val); \
+               } \
+       } while (0)
+
+#endif /* __PERIPHERAL_COMMON_H__ */
index 9aa81c6d820f6e6bfa2d324ae34908686e6d3bad..79a9fc4fcddb99f6c48e3879229003053f28f790 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <fcntl.h>
 #include <inttypes.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <sys/stat.h>
@@ -23,8 +24,8 @@
 #include <system_info.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_ADC_FEATURE "http://tizen.org/feature/peripheral_io.adc"
 
 
 #define ADC_BUFFER_MAX 64
 
+/**
+ * @brief Internal struct for adc context
+ */
+struct _peripheral_adc_s {
+       int fd;
+};
+
 static int adc_feature = ADC_FEATURE_UNKNOWN;
 
 static bool __is_feature_supported(void)
index 86da48948be61591aaa05ab91566d085890227f5..d700aaf8abe3be0e02b6f3e00f1c27b3185fb0fd 100644 (file)
  * limitations under the License.
  */
 
+#include <gio/gio.h>
 #include <libudev.h>
 #include <poll.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <system_info.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio"
 
 
 #define GPIO_BUFFER_MAX 64
 
+typedef struct _peripheral_gpio_interrupted_cb_info_s {
+       // vermagic value is used to verify structure inside csapi
+       // do not move it and value field to different place inside structure
+       // otherwise update csapi accordingly
+       int vermagic;
+       int value;
+       GThread *thread;
+       peripheral_gpio_interrupted_cb cb;
+       peripheral_error_e error;
+       void *user_data;
+       gint status;
+} interrupted_cb_info_s;
+
+/**
+ * @brief Internal struct for gpio context
+ */
+struct _peripheral_gpio_s {
+       // vermagic value is used to verify structure inside csapi
+       // do not move it and callback info field to different place inside structure
+       // otherwise update csapi accordingly
+       int vermagic;
+       interrupted_cb_info_s cb_info;
+       int pin;
+       int fd_direction;
+       int fd_edge;
+       int fd_value;
+       peripheral_gpio_direction_e direction;
+       peripheral_gpio_edge_e edge;
+};
+
 static int gpio_feature = GPIO_FEATURE_UNKNOWN;
 
 static bool __is_feature_supported(void)
index 4076094afa7eda08bb3035b36c1eb21257e262a1..b36ffab731bbe57a1e587a5ec1d45a04ff49cf51 100644 (file)
  * limitations under the License.
  */
 #include <errno.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <system_info.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c"
 
  */
 #define I2C_SMBUS_BLOCK_MAX    32      /* As specified in SMBus standard */
 
+/**
+ * @brief Internal struct for i2c context
+ */
+struct _peripheral_i2c_s {
+       int fd;
+};
+
 union i2c_smbus_data {
        uint8_t byte;
        uint16_t word;
index 51b447c014643bdbfb48ae5bb3a065ce3803fdcf..0eaf94bf3c1bcd7a9f77032433caf0cf1d623d60 100644 (file)
 
 #include <libudev.h>
 #include <poll.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <system_info.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm"
 
 
 #define PWM_BUF_MAX 16
 
+/**
+ * @brief Internal struct for pwm context
+ */
+struct _peripheral_pwm_s {
+       int chip;
+       int pin;
+       int fd_period;
+       int fd_duty_cycle;
+       int fd_polarity;
+       int fd_enable;
+};
+
 static int pwm_feature = PWM_FEATURE_UNKNOWN;
 
 static bool __is_feature_supported(void)
index 9381d007dd16146ef87f7cbb5d5ca45df32134e2..6e5096856b32a40963f00d00e02d97864d8fd837 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <fcntl.h>
 #include <linux/spi/spidev.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
@@ -24,8 +25,8 @@
 #include <system_info.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi"
 
 #define SPI_FEATURE_FALSE    0
 #define SPI_FEATURE_TRUE     1
 
+/**
+ * @brief Internal struct for spi context
+ */
+struct _peripheral_spi_s {
+       int fd;
+};
+
 static int spi_feature = SPI_FEATURE_UNKNOWN;
 
 static bool __is_feature_supported(void)
index daeb2e070cb4045a906d7cd4b74722f0ded2e43e..a2e10ee5d7368b6104bf90e9105e9286aae31e47 100644 (file)
@@ -15,6 +15,8 @@
  */
 
 #include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <sys/stat.h>
@@ -23,8 +25,8 @@
 #include <termios.h>
 
 #include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
 
 #define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart"
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
 #endif
 
+/**
+ * @brief Internal struct for uart context
+ */
+struct _peripheral_uart_s {
+       int fd;
+};
+
 static const int peripheral_uart_br[] = {
        B0,         B50,        B75,        B110,       B134,
        B150,       B200,       B300,       B600,       B1200,