From 1bdfe646f03f6a95242406f1f53a0bf5f93f44ed Mon Sep 17 00:00:00 2001 From: Segwon Date: Thu, 21 Sep 2017 16:52:34 +0900 Subject: [PATCH] adc: the adc interface is not supported Signed-off-by: Segwon Change-Id: Ief5428879d64020875d0fb4c281c1e82e5d9cb7a --- CMakeLists.txt | 3 - src/daemon/include/peripheral_bus.h | 4 -- src/daemon/include/peripheral_bus_adc.h | 23 ------- src/daemon/include/peripheral_bus_board.h | 1 - src/daemon/include/peripheral_bus_gdbus_adc.h | 29 --------- src/daemon/peripheral_bus.c | 38 ------------ src/daemon/peripheral_bus_adc.c | 56 ----------------- src/daemon/peripheral_bus_board.c | 7 +-- src/daemon/peripheral_bus_gdbus_adc.c | 51 ---------------- src/daemon/peripheral_io.xml | 8 --- src/interface/adc.c | 87 --------------------------- src/interface/include/adc.h | 42 ------------- 12 files changed, 1 insertion(+), 348 deletions(-) delete mode 100644 src/daemon/include/peripheral_bus_adc.h delete mode 100644 src/daemon/include/peripheral_bus_gdbus_adc.h delete mode 100644 src/daemon/peripheral_bus_adc.c delete mode 100644 src/daemon/peripheral_bus_gdbus_adc.c delete mode 100644 src/interface/adc.c delete mode 100644 src/interface/include/adc.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f9b346d..44333a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,16 +28,13 @@ SET(SRCS src/daemon/peripheral_bus_gdbus_pwm.c src/daemon/peripheral_bus_gdbus_spi.c src/daemon/peripheral_bus_gdbus_uart.c - src/daemon/peripheral_bus_gdbus_adc.c src/daemon/peripheral_bus_pwm.c - src/daemon/peripheral_bus_adc.c src/daemon/peripheral_bus_i2c.c src/daemon/peripheral_bus_gpio.c src/daemon/peripheral_bus_uart.c src/daemon/peripheral_bus_spi.c src/daemon/peripheral_bus_board.c src/daemon/peripheral_io_gdbus.c - src/interface/adc.c src/interface/gpio.c src/interface/i2c.c src/interface/pwm.c diff --git a/src/daemon/include/peripheral_bus.h b/src/daemon/include/peripheral_bus.h index 2844153..5ce24e1 100644 --- a/src/daemon/include/peripheral_bus.h +++ b/src/daemon/include/peripheral_bus.h @@ -26,15 +26,12 @@ typedef enum { PERIPHERAL_BUS_TYPE_GPIO = 0, PERIPHERAL_BUS_TYPE_I2C, PERIPHERAL_BUS_TYPE_PWM, - PERIPHERAL_BUS_TYPE_ADC, PERIPHERAL_BUS_TYPE_UART, PERIPHERAL_BUS_TYPE_SPI, } peripheral_bus_type_e; typedef struct { pb_board_s *board; - /* daemon variable */ - char *adc_path; /* devices */ GList *gpio_list; GList *i2c_list; @@ -47,7 +44,6 @@ typedef struct { PeripheralIoGdbusGpio *gpio_skeleton; PeripheralIoGdbusI2c *i2c_skeleton; PeripheralIoGdbusPwm *pwm_skeleton; - PeripheralIoGdbusAdc *adc_skeleton; PeripheralIoGdbusUart *uart_skeleton; PeripheralIoGdbusSpi *spi_skeleton; } peripheral_bus_s; diff --git a/src/daemon/include/peripheral_bus_adc.h b/src/daemon/include/peripheral_bus_adc.h deleted file mode 100644 index 436214b..0000000 --- a/src/daemon/include/peripheral_bus_adc.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 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_BUS_ADC_H__ -#define __PERIPHERAL_BUS_ADC_H__ - -char *peripheral_bus_adc_get_path(unsigned int device); -int peripheral_bus_adc_read(unsigned int device, unsigned int channel, char *path, int *data); - -#endif /* __PERIPHERAL_BUS_ADC_H__ */ diff --git a/src/daemon/include/peripheral_bus_board.h b/src/daemon/include/peripheral_bus_board.h index 6f1b35e..c84b8b7 100644 --- a/src/daemon/include/peripheral_bus_board.h +++ b/src/daemon/include/peripheral_bus_board.h @@ -33,7 +33,6 @@ typedef enum { PB_BOARD_DEV_GPIO = 0, PB_BOARD_DEV_I2C, PB_BOARD_DEV_PWM, - PB_BOARD_DEV_ADC, PB_BOARD_DEV_UART, PB_BOARD_DEV_SPI, PB_BOARD_DEV_MAX, diff --git a/src/daemon/include/peripheral_bus_gdbus_adc.h b/src/daemon/include/peripheral_bus_gdbus_adc.h deleted file mode 100644 index 07471c8..0000000 --- a/src/daemon/include/peripheral_bus_gdbus_adc.h +++ /dev/null @@ -1,29 +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_BUS_GDBUS_ADC_H__ -#define __PERIPHERAL_BUS_GDBUS_ADC_H__ - -#include "peripheral_io_gdbus.h" - -gboolean handle_adc_read( - PeripheralIoGdbusAdc *adc, - GDBusMethodInvocation *invocation, - guint device, - guint channel, - gpointer user_data); - -#endif /* __PERIPHERAL_BUS_GDBUS_ADC_H__ */ diff --git a/src/daemon/peripheral_bus.c b/src/daemon/peripheral_bus.c index 369974e..bc346a0 100644 --- a/src/daemon/peripheral_bus.c +++ b/src/daemon/peripheral_bus.c @@ -31,7 +31,6 @@ #include "peripheral_bus_gdbus_pwm.h" #include "peripheral_bus_gdbus_spi.h" #include "peripheral_bus_gdbus_uart.h" -#include "peripheral_bus_gdbus_adc.h" static gboolean __gpio_init(peripheral_bus_s *pb_data) { @@ -215,37 +214,6 @@ static gboolean __pwm_init(peripheral_bus_s *pb_data) return true; } -static gboolean __adc_init(peripheral_bus_s *pb_data) -{ - GDBusObjectManagerServer *manager; - gboolean ret = FALSE; - GError *error = NULL; - - /* Add interface to default object path */ - pb_data->adc_skeleton = peripheral_io_gdbus_adc_skeleton_new(); - g_signal_connect(pb_data->adc_skeleton, - "handle-read", - G_CALLBACK(handle_adc_read), - pb_data); - - manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_ADC_PATH); - - /* Set connection to 'manager' */ - 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(pb_data->adc_skeleton), - pb_data->connection, PERIPHERAL_GDBUS_ADC_PATH, &error); - - if (ret == FALSE) { - _E("Can not skeleton_export %s", error->message); - g_error_free(error); - } - - return true; -} - static gboolean __uart_init(peripheral_bus_s *pb_data) { GDBusObjectManagerServer *manager; @@ -400,9 +368,6 @@ static void on_bus_acquired(GDBusConnection *connection, if (__pwm_init(pb_data) == FALSE) _E("Can not signal connect"); - if (__adc_init(pb_data) == FALSE) - _E("Can not signal connect"); - if (__uart_init(pb_data) == FALSE) _E("Can not signal connect"); @@ -441,7 +406,6 @@ int main(int argc, char *argv[]) return -1; } - pb_data->adc_path = NULL; pb_data->board = peripheral_bus_board_init(); if (pb_data->board == NULL) { _E("failed to init board"); @@ -472,8 +436,6 @@ int main(int argc, char *argv[]) if (pb_data) { peripheral_bus_board_deinit(pb_data->board); - if (pb_data->adc_path) - free(pb_data->adc_path); free(pb_data); } diff --git a/src/daemon/peripheral_bus_adc.c b/src/daemon/peripheral_bus_adc.c deleted file mode 100644 index 66044e0..0000000 --- a/src/daemon/peripheral_bus_adc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 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 -#include -#include - -#include - -#include "adc.h" -#include "peripheral_bus.h" -#include "peripheral_common.h" -#include "peripheral_bus_util.h" - -#define SYSFS_ADC_PATH_MAX 128 - -char *peripheral_bus_adc_get_path(unsigned int device) -{ - char *path; - int ret; - - path = calloc(1, SYSFS_ADC_PATH_MAX); - if (path == NULL) { - _E("failed to allocate path buffer"); - return NULL; - } - - ret = adc_get_path(device, path, SYSFS_ADC_PATH_MAX); - if (ret < 0) { - _E("failed to get adc path"); - free(path); - return NULL; - } - - return path; -} - -int peripheral_bus_adc_read(unsigned int device, unsigned int channel, char *path, int *data) -{ - if (path == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER; - - return adc_read(device, channel, path, data); -} diff --git a/src/daemon/peripheral_bus_board.c b/src/daemon/peripheral_bus_board.c index 16655aa..bfc3508 100644 --- a/src/daemon/peripheral_bus_board.c +++ b/src/daemon/peripheral_bus_board.c @@ -51,8 +51,6 @@ static int peripheral_bus_board_get_device_type(char *string) return PB_BOARD_DEV_I2C; else if (0 == strncmp(string, "pwm", strlen("pwm"))) return PB_BOARD_DEV_PWM; - else if (0 == strncmp(string, "adc", strlen("adc"))) - return PB_BOARD_DEV_ADC; else if (0 == strncmp(string, "uart", strlen("uart"))) return PB_BOARD_DEV_UART; else if (0 == strncmp(string, "spi", strlen("spi"))) @@ -73,9 +71,6 @@ static void peripheral_bus_board_ini_parse_key(pb_board_dev_e type, char *string case PB_BOARD_DEV_PWM: sscanf(string, "%*50[^0-9]%d%*50[^0-9]%d", &args[0], &args[1]); break; - case PB_BOARD_DEV_ADC: - sscanf(string, "%*50[^0-9]%d%*50[^0-9]%d", &args[0], &args[1]); - break; case PB_BOARD_DEV_UART: sscanf(string, "%*50[^0-9]%d", &args[0]); break; @@ -236,7 +231,7 @@ pb_board_dev_s *peripheral_bus_board_find_device(pb_board_dev_e dev_type, pb_boa RETV_IF(board == NULL, false); args[0] = arg; - if (dev_type == PB_BOARD_DEV_PWM || dev_type == PB_BOARD_DEV_ADC || dev_type == PB_BOARD_DEV_SPI) { + if (dev_type == PB_BOARD_DEV_PWM || dev_type == PB_BOARD_DEV_SPI) { va_start(ap, arg); args[1] = va_arg(ap, int); va_end(ap); diff --git a/src/daemon/peripheral_bus_gdbus_adc.c b/src/daemon/peripheral_bus_gdbus_adc.c deleted file mode 100644 index 517354b..0000000 --- a/src/daemon/peripheral_bus_gdbus_adc.c +++ /dev/null @@ -1,51 +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 - -#include "peripheral_io_gdbus.h" -#include "peripheral_bus.h" -#include "peripheral_bus_adc.h" -#include "peripheral_common.h" -#include "peripheral_bus_util.h" -#include "peripheral_bus_gdbus_adc.h" - -gboolean handle_adc_read( - PeripheralIoGdbusAdc *adc, - GDBusMethodInvocation *invocation, - guint device, - guint channel, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - int data = 0; - - if (pb_data->adc_path == NULL) { - pb_data->adc_path = peripheral_bus_adc_get_path(device); - if (pb_data->adc_path == NULL) { - ret = PERIPHERAL_ERROR_UNKNOWN; - goto out; - } - } - - ret = peripheral_bus_adc_read(device, channel, pb_data->adc_path, &data); - -out: - peripheral_io_gdbus_adc_complete_read(adc, invocation, data, ret); - - return true; -} diff --git a/src/daemon/peripheral_io.xml b/src/daemon/peripheral_io.xml index 878fb5c..ad80f04 100644 --- a/src/daemon/peripheral_io.xml +++ b/src/daemon/peripheral_io.xml @@ -143,14 +143,6 @@ - - - - - - - - diff --git a/src/interface/adc.c b/src/interface/adc.c deleted file mode 100644 index 508538a..0000000 --- a/src/interface/adc.c +++ /dev/null @@ -1,87 +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 -#include -#include -#include -#include -#include - -#include "adc.h" -#include "peripheral_common.h" - -#define SYSFS_ADC_PATH "/sys/bus/iio/devices/iio:device" -#define SYSFS_ADC_PATH_OLD "/sys/bus/iio/devices/device" - -#define PATH_BUF_MAX 64 -#define ADC_BUF_MAX 16 -#define MAX_ERR_LEN 255 - -int adc_get_path(unsigned int device, char *path, int length) -{ - char adc_dev[PATH_BUF_MAX] = {0}; - - snprintf(adc_dev, PATH_BUF_MAX, "%s%d", SYSFS_ADC_PATH, device); - if (access(adc_dev, F_OK) == 0) { - strncpy(path, SYSFS_ADC_PATH, length); - return 0; - } else { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Can't Open %s, errmsg : %s", adc_dev, errmsg); - } - - snprintf(adc_dev, PATH_BUF_MAX, "%s%d", SYSFS_ADC_PATH_OLD, device); - if (access(adc_dev, F_OK) == 0) { - strncpy(path, SYSFS_ADC_PATH_OLD, length); - return 0; - } else { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Can't Open %s, errmsg : %s", adc_dev, errmsg); - } - - return -ENXIO; -} - -int adc_read(unsigned int device, unsigned int channel, char *path, int *data) -{ - int fd, result, status; - char adc_buf[ADC_BUF_MAX] = {0}; - char adc_dev[PATH_BUF_MAX] = {0}; - - snprintf(adc_dev, PATH_BUF_MAX, "%s%d%s%d%s", path, device, "/in_voltage", channel, "_raw"); - fd = open(adc_dev, O_RDONLY); - if (fd < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Can't Open %s, errmsg : %s", adc_dev, errmsg); - return -ENXIO; - } - - status = read(fd, adc_buf, ADC_BUF_MAX); - if (status < 0) { - close(fd); - _E("Failed to get adc, path : %s", adc_dev); - return -EIO; - } - result = atoi(adc_buf); - *data = result; - close(fd); - - return 0; -} diff --git a/src/interface/include/adc.h b/src/interface/include/adc.h deleted file mode 100644 index 9f39cf7..0000000 --- a/src/interface/include/adc.h +++ /dev/null @@ -1,42 +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 __ADC_H__ -#define __ADC_H__ - -/** -* @brief adc_get_path() get adc device path. -* -* @param[in] device The adc device number -* @param[in] channel The adc channel number -* @param[out] *path The buffer for the adc device path -* @param[in] length The max length of the path buffer -* @return 0 on success, otherwise a negative error value -*/ -int adc_get_path(unsigned int device, char *path, int length); - -/** -* @brief adc_read() get adc data. -* -* @param[in] device The adc device number -* @param[in] channel The adc channel number -* @param[in] *path The adc device path -* @param[in] *data The adc value -* @return 0 on success, otherwise a negative error value -*/ -int adc_read(unsigned int device, unsigned int channel, char *path, int *data); - -#endif /* __ADC_H__ */ -- 2.7.4