diff options
author | Ziyan <jaraidaniel@gmail.com> | 2016-09-23 02:01:59 +0200 |
---|---|---|
committer | Andreas Blaesius <skate4life@gmx.de> | 2016-09-26 19:54:44 +0200 |
commit | c2921845fd350d5fa0e1709a3b4100290bbaf7ef (patch) | |
tree | ff9e241a5bb28f881de0832efddd65c9dc328194 /libsensors | |
parent | 2b99edd8aa47e00870d9043e0d1f93b6348e21fc (diff) | |
download | device_samsung_espressowifi-c2921845fd350d5fa0e1709a3b4100290bbaf7ef.zip device_samsung_espressowifi-c2921845fd350d5fa0e1709a3b4100290bbaf7ef.tar.gz device_samsung_espressowifi-c2921845fd350d5fa0e1709a3b4100290bbaf7ef.tar.bz2 |
libsensors: remove unused functions
Change-Id: I4e2021ed23a63f8b890391d68afc544961d800a6
Diffstat (limited to 'libsensors')
-rw-r--r-- | libsensors/geomagneticd/geomagneticd.h | 9 | ||||
-rw-r--r-- | libsensors/geomagneticd/input.c | 218 | ||||
-rw-r--r-- | libsensors/input.c | 172 | ||||
-rw-r--r-- | libsensors/orientationd/input.c | 239 | ||||
-rw-r--r-- | libsensors/orientationd/orientationd.h | 8 | ||||
-rw-r--r-- | libsensors/piranha_sensors.h | 7 |
6 files changed, 1 insertions, 652 deletions
diff --git a/libsensors/geomagneticd/geomagneticd.h b/libsensors/geomagneticd/geomagneticd.h index 71f9dcb..10ad3ef 100644 --- a/libsensors/geomagneticd/geomagneticd.h +++ b/libsensors/geomagneticd/geomagneticd.h @@ -46,16 +46,7 @@ struct geomagneticd_data { * Input */ -void input_event_set(struct input_event *event, int type, int code, int value); -int64_t timestamp(struct timeval *time); -int64_t input_timestamp(struct input_event *event); -int uinput_rel_create(const char *name); -void uinput_destroy(int uinput_fd); int input_open(char *name); int sysfs_path_prefix(char *name, char *path_prefix); -int64_t sysfs_value_read(char *path); -int sysfs_value_write(char *path, int64_t value); -int sysfs_string_read(char *path, char *buffer, size_t length); -int sysfs_string_write(char *path, char *buffer, size_t length); #endif diff --git a/libsensors/geomagneticd/input.c b/libsensors/geomagneticd/input.c index 360dc59..1a9270e 100644 --- a/libsensors/geomagneticd/input.c +++ b/libsensors/geomagneticd/input.c @@ -24,109 +24,12 @@ #include <dirent.h> #include <linux/ioctl.h> #include <linux/input.h> -#include <linux/uinput.h> #define LOG_TAG "geomagneticd" #include <utils/Log.h> #include "geomagneticd.h" -void input_event_set(struct input_event *event, int type, int code, int value) -{ - if (event == NULL) - return; - - memset(event, 0, sizeof(struct input_event)); - - event->type = type, - event->code = code; - event->value = value; - - gettimeofday(&event->time, NULL); -} - -int64_t timestamp(struct timeval *time) -{ - if (time == NULL) - return -1; - - return (int64_t) (time->tv_sec * 1000000000LL + time->tv_usec * 1000); -} - -int64_t input_timestamp(struct input_event *event) -{ - if (event == NULL) - return -1; - - return timestamp(&event->time); -} - -int uinput_rel_create(const char *name) -{ - struct uinput_user_dev uinput_dev; - int uinput_fd; - int rc; - - if (name == NULL) - return -1; - - uinput_fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); - if (uinput_fd < 0) { - ALOGE("%s: Unable to open uinput device", __func__); - goto error; - } - - memset(&uinput_dev, 0, sizeof(uinput_dev)); - - strncpy(uinput_dev.name, name, sizeof(uinput_dev.name)); - uinput_dev.id.bustype = BUS_I2C; - uinput_dev.id.vendor = 0; - uinput_dev.id.product = 0; - uinput_dev.id.version = 0; - - rc = 0; - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_REL); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z); - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN); - - if (rc < 0) { - ALOGE("%s: Unable to set uinput bits", __func__); - goto error; - } - - rc = write(uinput_fd, &uinput_dev, sizeof(uinput_dev)); - if (rc < 0) { - ALOGE("%s: Unable to write uinput device", __func__); - goto error; - } - - rc = ioctl(uinput_fd, UI_DEV_CREATE); - if (rc < 0) { - ALOGE("%s: Unable to create uinput device", __func__); - goto error; - } - - usleep(3000); - - return uinput_fd; - -error: - if (uinput_fd >= 0) - close(uinput_fd); - - return -1; -} - -void uinput_destroy(int uinput_fd) -{ - if (uinput_fd < 0) - return; - - ioctl(uinput_fd, UI_DEV_DESTROY); -} - int input_open(char *name) { DIR *d; @@ -213,124 +116,3 @@ int sysfs_path_prefix(char *name, char *path_prefix) return -1; } - -int64_t sysfs_value_read(char *path) -{ - char buffer[100]; - int64_t value; - int fd = -1; - int rc; - - if (path == NULL) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, &buffer, sizeof(buffer)); - if (rc <= 0) - goto error; - - value = (int64_t)strtoimax(buffer, NULL, 10); - goto complete; - -error: - value = -1; - -complete: - if (fd >= 0) - close(fd); - - return value; -} - -int sysfs_value_write(char *path, int64_t value) -{ - char buffer[100]; - int fd = -1; - int rc; - - if (path == NULL) - return -1; - - fd = open(path, O_WRONLY); - if (fd < 0) - goto error; - - snprintf((char *) &buffer, sizeof(buffer), "%" PRId64 "\n", value); - - rc = write(fd, buffer, strlen(buffer)); - if (rc < (int) strlen(buffer)) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} - -int sysfs_string_read(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} - -int sysfs_string_write(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_WRONLY); - if (fd < 0) - goto error; - - rc = write(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} diff --git a/libsensors/input.c b/libsensors/input.c index 33166d3..f5fc32b 100644 --- a/libsensors/input.c +++ b/libsensors/input.c @@ -24,28 +24,13 @@ #include <dirent.h> #include <linux/ioctl.h> #include <linux/input.h> -#include <linux/uinput.h> #define LOG_TAG "piranha_sensors" #include <utils/Log.h> #include "piranha_sensors.h" -void input_event_set(struct input_event *event, int type, int code, int value) -{ - if (event == NULL) - return; - - memset(event, 0, sizeof(struct input_event)); - - event->type = type, - event->code = code; - event->value = value; - - gettimeofday(&event->time, NULL); -} - -int64_t timestamp(struct timeval *time) +static int64_t timestamp(struct timeval *time) { if (time == NULL) return -1; @@ -61,72 +46,6 @@ int64_t input_timestamp(struct input_event *event) return timestamp(&event->time); } -int uinput_rel_create(const char *name) -{ - struct uinput_user_dev uinput_dev; - int uinput_fd; - int rc; - - if (name == NULL) - return -1; - - uinput_fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); - if (uinput_fd < 0) { - ALOGE("%s: Unable to open uinput device", __func__); - goto error; - } - - memset(&uinput_dev, 0, sizeof(uinput_dev)); - - strncpy(uinput_dev.name, name, sizeof(uinput_dev.name)); - uinput_dev.id.bustype = BUS_I2C; - uinput_dev.id.vendor = 0; - uinput_dev.id.product = 0; - uinput_dev.id.version = 0; - - rc = 0; - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_REL); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z); - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN); - - if (rc < 0) { - ALOGE("%s: Unable to set uinput bits", __func__); - goto error; - } - - rc = write(uinput_fd, &uinput_dev, sizeof(uinput_dev)); - if (rc < 0) { - ALOGE("%s: Unable to write uinput device", __func__); - goto error; - } - - rc = ioctl(uinput_fd, UI_DEV_CREATE); - if (rc < 0) { - ALOGE("%s: Unable to create uinput device", __func__); - goto error; - } - - usleep(3000); - - return uinput_fd; - -error: - if (uinput_fd >= 0) - close(uinput_fd); - - return -1; -} - -void uinput_destroy(int uinput_fd) -{ - if (uinput_fd < 0) - return; - - ioctl(uinput_fd, UI_DEV_DESTROY); -} - int input_open(char *name) { DIR *d; @@ -214,37 +133,6 @@ int sysfs_path_prefix(char *name, char *path_prefix) return -1; } -int64_t sysfs_value_read(char *path) -{ - char buffer[100]; - int64_t value; - int fd = -1; - int rc; - - if (path == NULL) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, &buffer, sizeof(buffer)); - if (rc <= 0) - goto error; - - value = (int64_t)strtoimax(buffer, NULL, 10); - goto complete; - -error: - value = -1; - -complete: - if (fd >= 0) - close(fd); - - return value; -} - int sysfs_value_write(char *path, int64_t value) { char buffer[100]; @@ -276,61 +164,3 @@ complete: return rc; } - -int sysfs_string_read(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} - -int sysfs_string_write(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_WRONLY); - if (fd < 0) - goto error; - - rc = write(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} diff --git a/libsensors/orientationd/input.c b/libsensors/orientationd/input.c index 990c8a2..32cabb0 100644 --- a/libsensors/orientationd/input.c +++ b/libsensors/orientationd/input.c @@ -24,7 +24,6 @@ #include <dirent.h> #include <linux/ioctl.h> #include <linux/input.h> -#include <linux/uinput.h> #define LOG_TAG "orientationd" #include <utils/Log.h> @@ -53,80 +52,6 @@ int64_t timestamp(struct timeval *time) return (int64_t) (time->tv_sec * 1000000000LL + time->tv_usec * 1000); } -int64_t input_timestamp(struct input_event *event) -{ - if (event == NULL) - return -1; - - return timestamp(&event->time); -} - -int uinput_rel_create(const char *name) -{ - struct uinput_user_dev uinput_dev; - int uinput_fd; - int rc; - - if (name == NULL) - return -1; - - uinput_fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); - if (uinput_fd < 0) { - ALOGE("%s: Unable to open uinput device", __func__); - goto error; - } - - memset(&uinput_dev, 0, sizeof(uinput_dev)); - - strncpy(uinput_dev.name, name, sizeof(uinput_dev.name)); - uinput_dev.id.bustype = BUS_I2C; - uinput_dev.id.vendor = 0; - uinput_dev.id.product = 0; - uinput_dev.id.version = 0; - - rc = 0; - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_REL); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y); - rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z); - rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN); - - if (rc < 0) { - ALOGE("%s: Unable to set uinput bits", __func__); - goto error; - } - - rc = write(uinput_fd, &uinput_dev, sizeof(uinput_dev)); - if (rc < 0) { - ALOGE("%s: Unable to write uinput device", __func__); - goto error; - } - - rc = ioctl(uinput_fd, UI_DEV_CREATE); - if (rc < 0) { - ALOGE("%s: Unable to create uinput device", __func__); - goto error; - } - - usleep(3000); - - return uinput_fd; - -error: - if (uinput_fd >= 0) - close(uinput_fd); - - return -1; -} - -void uinput_destroy(int uinput_fd) -{ - if (uinput_fd < 0) - return; - - ioctl(uinput_fd, UI_DEV_DESTROY); -} - int input_open(char *name) { DIR *d; @@ -170,167 +95,3 @@ int input_open(char *name) return -1; } - -int sysfs_path_prefix(char *name, char *path_prefix) -{ - DIR *d; - struct dirent *di; - - char input_name[80] = { 0 }; - char path[PATH_MAX]; - char *c; - int fd; - - if (name == NULL || path_prefix == NULL) - return -EINVAL; - - d = opendir("/sys/class/input"); - if (d == NULL) - return -1; - - while ((di = readdir(d))) { - if (di == NULL || strcmp(di->d_name, ".") == 0 || strcmp(di->d_name, "..") == 0) - continue; - - snprintf(path, PATH_MAX, "/sys/class/input/%s/name", di->d_name); - - fd = open(path, O_RDONLY); - if (fd < 0) - continue; - - read(fd, &input_name, sizeof(input_name)); - close(fd); - - c = strstr((char *) &input_name, "\n"); - if (c != NULL) - *c = '\0'; - - if (strcmp(input_name, name) == 0) { - snprintf(path_prefix, PATH_MAX, "/sys/class/input/%s", di->d_name); - return 0; - } - } - - return -1; -} - -int64_t sysfs_value_read(char *path) -{ - char buffer[100]; - int64_t value; - int fd = -1; - int rc; - - if (path == NULL) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, &buffer, sizeof(buffer)); - if (rc <= 0) - goto error; - - value = (int64_t)strtoimax(buffer, NULL, 10); - goto complete; - -error: - value = -1; - -complete: - if (fd >= 0) - close(fd); - - return value; -} - -int sysfs_value_write(char *path, int64_t value) -{ - char buffer[100]; - int fd = -1; - int rc; - - if (path == NULL) - return -1; - - fd = open(path, O_WRONLY); - if (fd < 0) - goto error; - - snprintf((char *) &buffer, sizeof(buffer), "%" PRId64 "\n", value); - - rc = write(fd, buffer, strlen(buffer)); - if (rc < (int) strlen(buffer)) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} - -int sysfs_string_read(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto error; - - rc = read(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} - -int sysfs_string_write(char *path, char *buffer, size_t length) -{ - int fd = -1; - int rc; - - if (path == NULL || buffer == NULL || length == 0) - return -1; - - fd = open(path, O_WRONLY); - if (fd < 0) - goto error; - - rc = write(fd, buffer, length); - if (rc <= 0) - goto error; - - rc = 0; - goto complete; - -error: - rc = -1; - -complete: - if (fd >= 0) - close(fd); - - return rc; -} diff --git a/libsensors/orientationd/orientationd.h b/libsensors/orientationd/orientationd.h index 1eebd90..22227ce 100644 --- a/libsensors/orientationd/orientationd.h +++ b/libsensors/orientationd/orientationd.h @@ -68,15 +68,7 @@ extern int orientationd_handlers_count; void input_event_set(struct input_event *event, int type, int code, int value); int64_t timestamp(struct timeval *time); -int64_t input_timestamp(struct input_event *event); -int uinput_rel_create(const char *name); -void uinput_destroy(int uinput_fd); int input_open(char *name); -int sysfs_path_prefix(char *name, char *path_prefix); -int64_t sysfs_value_read(char *path); -int sysfs_value_write(char *path, int64_t value); -int sysfs_string_read(char *path, char *buffer, size_t length); -int sysfs_string_write(char *path, char *buffer, size_t length); /* * Sensors diff --git a/libsensors/piranha_sensors.h b/libsensors/piranha_sensors.h index 1741945..6a2679f 100644 --- a/libsensors/piranha_sensors.h +++ b/libsensors/piranha_sensors.h @@ -79,17 +79,10 @@ int piranha_sensors_poll(struct sensors_poll_device_t *dev, * Input */ -void input_event_set(struct input_event *event, int type, int code, int value); -int64_t timestamp(struct timeval *time); int64_t input_timestamp(struct input_event *event); -int uinput_rel_create(const char *name); -void uinput_destroy(int uinput_fd); int input_open(char *name); int sysfs_path_prefix(char *name, char *path_prefix); -int64_t sysfs_value_read(char *path); int sysfs_value_write(char *path, int64_t value); -int sysfs_string_read(char *path, char *buffer, size_t length); -int sysfs_string_write(char *path, char *buffer, size_t length); /* * Sensors |