summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunhee Seo <yuni.seo@samsung.com>2024-07-01 17:15:18 +0900
committerYunhee Seo <yuni.seo@samsung.com>2024-07-02 19:10:40 +0900
commit0bb93d522f4f7aa05fd8f9b81e8654c38bbf4771 (patch)
tree14d4583e623fa643e277a9eff144247c5704b91f
parent7342f959728d1e502ade2b176f10aa277f903c0a (diff)
downloaddevice-vim3-0bb93d522f4f7aa05fd8f9b81e8654c38bbf4771.tar.gz
device-vim3-0bb93d522f4f7aa05fd8f9b81e8654c38bbf4771.tar.bz2
device-vim3-0bb93d522f4f7aa05fd8f9b81e8654c38bbf4771.zip
As support hal-abi-versioning, the hal-backend package should be built using only the hal-rootstrap. Other packages not included in the hal-roostrap have been deleted to remove dependencies. util is added to replace functions of dlog and libsyscommon package. Change-Id: Ie478da1afe4dc6dca876d521ebb2a8e501f732fb Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r--CMakeLists.txt9
-rw-r--r--hw/board/CMakeLists.txt6
-rw-r--r--hw/board/board.c2
-rw-r--r--hw/display/CMakeLists.txt6
-rw-r--r--hw/display/display.c3
-rw-r--r--hw/haptic/CMakeLists.txt10
-rw-r--r--hw/haptic/gpio.c15
-rw-r--r--hw/memory/CMakeLists.txt6
-rw-r--r--hw/memory/memory.c2
-rw-r--r--hw/thermal/CMakeLists.txt6
-rw-r--r--hw/thermal/thermal.c2
-rw-r--r--hw/touchscreen/CMakeLists.txt6
-rw-r--r--hw/touchscreen/touchscreen.c7
-rw-r--r--include/util.h40
-rw-r--r--packaging/hal-backend-device-vim3.spec7
-rw-r--r--src/util.c126
16 files changed, 214 insertions, 39 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c626cb4..54c8c11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,12 +3,21 @@ PROJECT(hal-backend-device-vim3 C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE(FindPkgConfig)
+pkg_check_modules(hal-backend-device-vim3_pkgs REQUIRED hal-rootstrap)
+
+FOREACH(flag ${hal-backend-device-vim3_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
IF(ENABLE_DLOG STREQUAL on)
ADD_DEFINITIONS("-DFEATURE_DLOG")
ENDIF()
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Apache-2.0 DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME})
ADD_SUBDIRECTORY(hw/board)
diff --git a/hw/board/CMakeLists.txt b/hw/board/CMakeLists.txt
index de3acea..358723c 100644
--- a/hw/board/CMakeLists.txt
+++ b/hw/board/CMakeLists.txt
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-board C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-board_pkgs REQUIRED hal-backend-device-common)
+pkg_check_modules(hal-backend-device-board_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-board_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE board.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE board.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-board_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/board/board.c b/hw/board/board.c
index 22d4136..6a9abed 100644
--- a/hw/board/board.c
+++ b/hw/board/board.c
@@ -23,7 +23,7 @@
#include <errno.h>
#include <string.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define DATA_BUFF_MAX 256
#define CPUINFO_PATH "/proc/cpuinfo"
diff --git a/hw/display/CMakeLists.txt b/hw/display/CMakeLists.txt
index 8d73dd5..da3385c 100644
--- a/hw/display/CMakeLists.txt
+++ b/hw/display/CMakeLists.txt
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-display C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-backend-device-common libsyscommon)
+pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-display_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE display.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE display.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-display_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/display/display.c b/hw/display/display.c
index 78f5d39..8c91c84 100644
--- a/hw/display/display.c
+++ b/hw/display/display.c
@@ -25,9 +25,8 @@
#include <hal/hal-device-display-interface.h>
#include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#ifndef BACKLIGHT_PATH
#define BACKLIGHT_PATH "/sys/class/backlight/rpi_backlight"
diff --git a/hw/haptic/CMakeLists.txt b/hw/haptic/CMakeLists.txt
index d3b5d3c..c04a362 100644
--- a/hw/haptic/CMakeLists.txt
+++ b/hw/haptic/CMakeLists.txt
@@ -3,12 +3,10 @@ PROJECT(hal-backend-device-haptic C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(haptic_pkgs REQUIRED
- hal-backend-device-common
- glib-2.0
- libsyscommon
- capi-system-peripheral-io)
+pkg_check_modules(haptic_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${haptic_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -17,7 +15,7 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE gpio.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE gpio.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${haptic_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/haptic/gpio.c b/hw/haptic/gpio.c
index bd9f4ed..7281172 100644
--- a/hw/haptic/gpio.c
+++ b/hw/haptic/gpio.c
@@ -19,10 +19,9 @@
#include <stdlib.h>
#include <glib.h>
#include <peripheral_io.h>
-#include <libsyscommon/list.h>
#include <hal/hal-device-haptic-interface.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define GPIO_I2C_BUS_INDEX 1
#define MAX_HAPIC 1
@@ -85,7 +84,7 @@ static bool find_from_list(int handle)
{
GList *elem;
- elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)handle);
+ elem = g_list_find(handle_list, (gpointer)(long)handle);
if (elem)
return true;
@@ -140,7 +139,7 @@ static int gpio_haptic_open_device(int *handle)
return -EINVAL;
/* if it is the first element */
- n = SYS_G_LIST_LENGTH(handle_list);
+ n = g_list_length(handle_list);
if (n == 0) {
_I("Peripheral Device Open.");
if (device_handle == NULL) {
@@ -156,13 +155,13 @@ static int gpio_haptic_open_device(int *handle)
while (found != true) {
++unique_number;
- elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = g_list_find(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
/* add info to local list */
- SYS_G_LIST_APPEND(handle_list, (gpointer)(long)unique_number);
+ handle_list = g_list_append(handle_list, (gpointer)(long)unique_number);
*handle = unique_number;
return 0;
@@ -190,10 +189,10 @@ static int gpio_haptic_close_device(int handle)
_I("Already stopped or failed to stop effect: %d", r);
_D("Handle(%d) is closed and timer deleted.", handle);
- SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)handle);
+ handle_list = g_list_remove(handle_list, (gpointer)(long)handle);
/* if it is the last element */
- n = SYS_G_LIST_LENGTH(handle_list);
+ n = g_list_length(handle_list);
if (n == 0) {
_I("Peripheral Device Close.");
if (device_handle != NULL) {
diff --git a/hw/memory/CMakeLists.txt b/hw/memory/CMakeLists.txt
index a35248a..77b4f9c 100644
--- a/hw/memory/CMakeLists.txt
+++ b/hw/memory/CMakeLists.txt
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-memory C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED dlog)
+pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-memory_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-memory_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/memory/memory.c b/hw/memory/memory.c
index a096337..ae65cf8 100644
--- a/hw/memory/memory.c
+++ b/hw/memory/memory.c
@@ -21,7 +21,7 @@
#include <hal/hal-device-memory-interface.h>
#include <hal/hal-common-interface.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define GEM_INFO_PATH "/sys/kernel/debug/dri/0/gem_info"
#define BYTES_PER_KBYTE 1024
diff --git a/hw/thermal/CMakeLists.txt b/hw/thermal/CMakeLists.txt
index 197833c..ee95e00 100644
--- a/hw/thermal/CMakeLists.txt
+++ b/hw/thermal/CMakeLists.txt
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-thermal C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED hal-backend-device-common glib-2.0)
+pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-thermal_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE thermal.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE thermal.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-thermal_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c
index 14c9c1d..9c2fc21 100644
--- a/hw/thermal/thermal.c
+++ b/hw/thermal/thermal.c
@@ -26,7 +26,7 @@
#include <hal/hal-device-thermal-interface.h>
#include <hal/hal-common-interface.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define AP_PATH "/sys/class/thermal/thermal_zone0/temp"
diff --git a/hw/touchscreen/CMakeLists.txt b/hw/touchscreen/CMakeLists.txt
index 207d23f..d9b00fa 100644
--- a/hw/touchscreen/CMakeLists.txt
+++ b/hw/touchscreen/CMakeLists.txt
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-touchscreen C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED hal-backend-device-common libsyscommon)
+pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED hal-rootstrap)
FOREACH(flag ${hal-backend-device-touchscreen_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${PROJECT_NAME} MODULE touchscreen.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE touchscreen.c ${CMAKE_SOURCE_DIR}/src/util.c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-touchscreen_pkgs_LDFLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/hw/touchscreen/touchscreen.c b/hw/touchscreen/touchscreen.c
index 6af8754..b79e86e 100644
--- a/hw/touchscreen/touchscreen.c
+++ b/hw/touchscreen/touchscreen.c
@@ -26,9 +26,8 @@
#include <hal/hal-device-touchscreen-interface.h>
#include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
#define TOUCHSCREEN_CON_FILE "/sys/devices/platform/rpi_ft5406/enable"
@@ -43,7 +42,7 @@ static int touchscreen_get_state(hal_device_touchscreen_state_e *state)
if (!state)
return -EINVAL;
- ret = sys_get_int(TOUCHSCREEN_CON_FILE, &val);
+ ret = sysfs_read_int(TOUCHSCREEN_CON_FILE, &val);
if (ret < 0) {
_E("Failed to get touchscreen state (%d)", ret);
return ret;
@@ -81,7 +80,7 @@ static int touchscreen_set_state(hal_device_touchscreen_state_e state)
return -EINVAL;
}
- ret = sys_set_int(TOUCHSCREEN_CON_FILE, val);
+ ret = sysfs_write_int(TOUCHSCREEN_CON_FILE, val);
if (ret < 0)
_E("Failed to change touchscreen state (%d)", ret);
diff --git a/include/util.h b/include/util.h
new file mode 100644
index 0000000..11f4fbe
--- /dev/null
+++ b/include/util.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+
+#ifdef FEATURE_DLOG
+ #define LOG_TAG "HAL_BACKEND_DEVICE_VIM3"
+ #include <dlog.h>
+ #define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
+ #define _I(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
+ #define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
+ #define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
+#else
+ #define _D(x, ...)
+ #define _I(x, ...)
+ #define _W(x, ...)
+ #define _E(x, ...)
+#endif
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define MAX_BUF_SIZE 255
+
+int sysfs_read_int(char *path, int *val);
+int sysfs_read_str(char *path, char *str, int len);
+int sysfs_write_int(char *path, int val);
+int sysfs_write_str(char *path, char *str);
diff --git a/packaging/hal-backend-device-vim3.spec b/packaging/hal-backend-device-vim3.spec
index fa21eb7..413fa69 100644
--- a/packaging/hal-backend-device-vim3.spec
+++ b/packaging/hal-backend-device-vim3.spec
@@ -10,12 +10,7 @@ ExclusiveArch: %{arm} aarch64
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(capi-system-peripheral-io)
-BuildRequires: pkgconfig(hal-api-common)
-BuildRequires: pkgconfig(hal-api-device)
-BuildRequires: pkgconfig(libsyscommon)
-BuildRequires: pkgconfig(hal-backend-device-common)
+BuildRequires: pkgconfig(hal-rootstrap)
%description
Device HAL backend drivers for Amlogic vim3 targets
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..80660b5
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2024 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 <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+static int sysfs_read_buf(char *path, char *buf, int len)
+{
+ int r, fd;
+
+ if ((!path) || (!buf) || (len < 0))
+ return -EINVAL;
+
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
+ return -ENOENT;
+
+ r = read(fd, buf, len);
+ close(fd);
+
+ if ((r < 0) || (r > len))
+ return -EIO;
+
+ /* Replace '\n' with space (ascii code is 32) */
+ buf[strcspn(buf, "\n")] = (char)32;
+ buf[r] = '\0';
+
+ return 0;
+}
+
+static int sysfs_write_buf(char *path, char *buf)
+{
+ int w, fd;
+
+ if ((!path) || (!buf))
+ return -EINVAL;
+
+ fd = open(path, O_WRONLY);
+ if (fd == -1)
+ return -ENOENT;
+
+ w = write(fd, buf, strlen(buf));
+ close(fd);
+
+ if (w < 0)
+ return -EIO;
+
+ return 0;
+}
+
+int sysfs_read_int(char *path, int *val)
+{
+ char buf[MAX_BUF_SIZE + 1];
+ int r;
+
+ if ((!path) || (!val))
+ return -EINVAL;
+
+ r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
+ if (r < 0)
+ return r;
+
+ *val = atoi(buf);
+ return 0;
+}
+
+int sysfs_read_str(char *path, char *str, int len)
+{
+ int r;
+
+ if ((!path) || (!str) || (len <= 0))
+ return -EINVAL;
+
+ r = sysfs_read_buf(path, str, len);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+int sysfs_write_int(char *path, int val)
+{
+ char buf[MAX_BUF_SIZE + 1];
+ int w;
+
+ if (!path)
+ return -EINVAL;
+
+ snprintf(buf, MAX_BUF_SIZE, "%d", val);
+ w = sysfs_write_buf(path, buf);
+ if (w < 0)
+ return w;
+
+ return 0;
+}
+
+int sysfs_write_str(char *path, char *str)
+{
+ int w;
+
+ if ((!path) || (!str))
+ return -EINVAL;
+
+ w = sysfs_write_buf(path, str);
+ if (w < 0)
+ return w;
+
+ return 0;
+}