diff options
author | Yunmi Ha <yunmi.ha@samsung.com> | 2021-01-19 13:32:25 +0900 |
---|---|---|
committer | Yunmi Ha <yunmi.ha@samsung.com> | 2021-01-19 15:45:53 +0900 |
commit | a32a881d20658fb01c221c09bc1eebf98c0b8b1b (patch) | |
tree | 7347902e6540f4bd1abac17f982c04b1cb9ec454 | |
parent | 9a227e038a8702bf4d2a65aa128e9b01d213e444 (diff) | |
download | device-tm1-a32a881d20658fb01c221c09bc1eebf98c0b8b1b.tar.gz device-tm1-a32a881d20658fb01c221c09bc1eebf98c0b8b1b.tar.bz2 device-tm1-a32a881d20658fb01c221c09bc1eebf98c0b8b1b.zip |
Use file library of libsyscommon
Change-Id: I13de8f2ef701cc559708d65cfce0105beec39239
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r-- | hw/battery/battery.c | 1 | ||||
-rw-r--r-- | hw/common/common.h | 109 | ||||
-rw-r--r-- | hw/display/display.c | 1 | ||||
-rw-r--r-- | hw/ir/ir.c | 1 | ||||
-rw-r--r-- | hw/led/led.c | 1 | ||||
-rw-r--r-- | hw/touchscreen/touchscreen.c | 1 |
6 files changed, 5 insertions, 109 deletions
diff --git a/hw/battery/battery.c b/hw/battery/battery.c index 625360c..7dde825 100644 --- a/hw/battery/battery.c +++ b/hw/battery/battery.c @@ -26,6 +26,7 @@ #include <hal/device/hal-battery-interface.h> #include <hal/hal-common-interface.h> +#include <libsyscommon/file.h> #include "common.h" #include "../udev.h" diff --git a/hw/common/common.h b/hw/common/common.h index ae965d6..37ce972 100644 --- a/hw/common/common.h +++ b/hw/common/common.h @@ -17,13 +17,6 @@ #ifndef __HAL_BACKEND_COMMON_H__ #define __HAL_BACKEND_COMMON_H__ -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - #ifdef FEATURE_DLOG #define LOG_TAG "HAL_BACKEND_DEVICE" #include <dlog.h> @@ -42,106 +35,4 @@ #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) -#define SHARED_H_BUF_MAX 255 - -static inline int sys_read_buf(char *file, char *buf, int len) -{ - int fd, r; - - if (!file || !buf || len < 0) - return -EINVAL; - - fd = open(file, O_RDONLY); - if (fd == -1) - return -ENOENT; - - r = read(fd, buf, len); - close(fd); - if ((r >= 0) && (r < len)) - buf[r] = '\0'; - else - return -EIO; - - return 0; -} - -static inline int sys_write_buf(char *file, char *buf) -{ - int fd, r; - - if (!file || !buf) - return -EINVAL; - - fd = open(file, O_WRONLY); - if (fd == -1) - return -EPERM; - - r = write(fd, buf, strlen(buf)); - close(fd); - if (r < 0) - return -EIO; - - return 0; -} - -static inline int sys_get_int(char *fname, int *val) -{ - char buf[SHARED_H_BUF_MAX]; - int r; - - if (!fname || !val) - return -EINVAL; - - r = sys_read_buf(fname, buf, sizeof(buf)); - if (r < 0) - return r; - - *val = atoi(buf); - return 0; -} - -static inline int sys_get_str(char *fname, char *str, int len) -{ - int r; - - if (!fname || !str || len < 0) - return -EINVAL; - - r = sys_read_buf(fname, str, len); - if (r < 0) - return r; - - return 0; -} - -static inline int sys_set_int(char *fname, int val) -{ - char buf[SHARED_H_BUF_MAX]; - int r; - - if (!fname) - return -EINVAL; - - snprintf(buf, sizeof(buf), "%d", val); - r = sys_write_buf(fname, buf); - if (r < 0) - return r; - - return 0; -} - -static inline int sys_set_str(char *fname, char *val) -{ - int r; - - if (!fname || !val) - return -EINVAL; - - r = sys_write_buf(fname, val); - if (r < 0) - return r; - - return 0; -} - #endif /* __HAL_BACKEND_COMMON_H__ */ diff --git a/hw/display/display.c b/hw/display/display.c index c95b564..2ad1f53 100644 --- a/hw/display/display.c +++ b/hw/display/display.c @@ -25,6 +25,7 @@ #include <hal/device/hal-display-interface.h> #include <hal/hal-common-interface.h> +#include <libsyscommon/file.h> #include "common.h" #ifndef BACKLIGHT_PATH @@ -27,6 +27,7 @@ #include <hal/device/hal-ir-interface.h> #include <hal/hal-common-interface.h> +#include <libsyscommon/file.h> #include "common.h" diff --git a/hw/led/led.c b/hw/led/led.c index 70850ea..e8c6549 100644 --- a/hw/led/led.c +++ b/hw/led/led.c @@ -25,6 +25,7 @@ #include <hal/device/hal-led-interface.h> #include <hal/hal-common-interface.h> +#include <libsyscommon/file.h> #include "common.h" diff --git a/hw/touchscreen/touchscreen.c b/hw/touchscreen/touchscreen.c index 33d1389..af45ab0 100644 --- a/hw/touchscreen/touchscreen.c +++ b/hw/touchscreen/touchscreen.c @@ -26,6 +26,7 @@ #include <hal/device/hal-touchscreen-interface.h> #include <hal/hal-common-interface.h> +#include <libsyscommon/file.h> #include "common.h" |