From: Yunmi Ha Date: Tue, 19 Jan 2021 08:54:08 +0000 (+0900) Subject: Use file library of libsyscommon X-Git-Tag: submit/tizen/20210607.045509~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5178ae60007f4433d95555448f13bc6a164cf2e;p=platform%2Fhal%2Fbackend%2Femulator%2Fdevice-emulator.git Use file library of libsyscommon Change-Id: I574682ab013f430f848bcd9dcee466ea848f7109 Signed-off-by: Yunmi Ha --- diff --git a/hw/battery/battery.c b/hw/battery/battery.c index dca5f1f..2b323a9 100644 --- a/hw/battery/battery.c +++ b/hw/battery/battery.c @@ -26,6 +26,7 @@ #include #include +#include #include "../dbus.h" #include "common.h" diff --git a/hw/common/common.h b/hw/common/common.h index 710f67b..413ed8a 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 -#include -#include -#include -#include -#include - #ifdef FEATURE_DLOG #define LOG_TAG "HAL_BACKEND_DEVICE" #include @@ -41,106 +34,4 @@ #define EXPORT __attribute__ ((visibility("default"))) -#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 f4bf894..ee59d19 100644 --- a/hw/display/display.c +++ b/hw/display/display.c @@ -25,6 +25,7 @@ #include #include +#include #include "common.h" diff --git a/hw/external_connection/external_connection.c b/hw/external_connection/external_connection.c index c61a716..1505477 100644 --- a/hw/external_connection/external_connection.c +++ b/hw/external_connection/external_connection.c @@ -27,6 +27,7 @@ #include #include +#include #include "../dbus.h" #include "common.h"