From c2921845fd350d5fa0e1709a3b4100290bbaf7ef Mon Sep 17 00:00:00 2001 From: Ziyan Date: Fri, 23 Sep 2016 02:01:59 +0200 Subject: libsensors: remove unused functions Change-Id: I4e2021ed23a63f8b890391d68afc544961d800a6 --- libsensors/geomagneticd/input.c | 218 ---------------------------------------- 1 file changed, 218 deletions(-) (limited to 'libsensors/geomagneticd/input.c') 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 #include #include -#include #define LOG_TAG "geomagneticd" #include #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; -} -- cgit v1.1