touchscreen: Apply HAL ABI versioning 22/310022/1
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 07:35:59 +0000 (16:35 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 07:41:21 +0000 (16:41 +0900)
While applying HAL ABI versioning, hal_backend_[module]_funcs is allocated from hal-api-[module] side.
Thus, allocation is moved to hal-api-device-touchscreen side.
Also, wrong module name is fixed and hal interface inclusion path is changed.
"touchscreen" -> "device-touchscreen"

Change-Id: I6776398dcfa8c36c5749e284ba673e0da08b70d9
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
hw/touchscreen/touchscreen.c

index 5c190b9f6a1862fc3baf62cea30d67ddb8d3a8bc..c86bc32e9c3d24c46ff57d9006377f3cc390c8e5 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/limits.h>
 #include <dirent.h>
 
-#include <hal/hal-touchscreen-interface.h>
+#include <hal/hal-device-touchscreen-interface.h>
 #include <hal/hal-common-interface.h>
 #include <libsyscommon/file.h>
 
@@ -35,7 +35,7 @@
 #define TURNON_TOUCHSCREEN     1
 #define TURNOFF_TOUCHSCREEN    0
 
-static int touchscreen_get_state(enum touchscreen_state *state)
+static int touchscreen_get_state(hal_device_touchscreen_state_e *state)
 {
        int ret;
        int val;
@@ -51,10 +51,10 @@ static int touchscreen_get_state(enum touchscreen_state *state)
 
        switch (val) {
        case TURNOFF_TOUCHSCREEN:
-               *state = TOUCHSCREEN_OFF;
+               *state = HAL_DEVICE_TOUCHSCREEN_OFF;
                break;
        case TURNON_TOUCHSCREEN:
-               *state = TOUCHSCREEN_ON;
+               *state = HAL_DEVICE_TOUCHSCREEN_ON;
                break;
        default:
                _E("Failed to get touchscreen state (%d)", val);
@@ -64,16 +64,16 @@ static int touchscreen_get_state(enum touchscreen_state *state)
        return 0;
 }
 
-static int touchscreen_set_state(enum touchscreen_state state)
+static int touchscreen_set_state(hal_device_touchscreen_state_e state)
 {
        int ret;
        int val;
 
        switch (state) {
-       case TOUCHSCREEN_OFF:
+       case HAL_DEVICE_TOUCHSCREEN_OFF:
                val = TURNOFF_TOUCHSCREEN;
                break;
-       case TOUCHSCREEN_ON:
+       case HAL_DEVICE_TOUCHSCREEN_ON:
                val = TURNON_TOUCHSCREEN;
                break;
        default:
@@ -90,16 +90,19 @@ static int touchscreen_set_state(enum touchscreen_state state)
 
 static int touchscreen_init(void **data)
 {
-       hal_backend_touchscreen_funcs *touchscreen_funcs;
+       hal_backend_device_touchscreen_funcs *device_touchscreen_funcs;
 
-       touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs));
-       if (!touchscreen_funcs)
-               return -ENOMEM;
+       if (!data) {
+               _E("Invalid parameter");
+               return -EINVAL;
+       }
 
-       touchscreen_funcs->get_state = touchscreen_get_state;
-       touchscreen_funcs->set_state = touchscreen_set_state;
+       device_touchscreen_funcs = *(hal_backend_device_touchscreen_funcs **) data;
+       if (!device_touchscreen_funcs)
+               return -EINVAL;
 
-       *data = (void *)touchscreen_funcs;
+       device_touchscreen_funcs->get_state = touchscreen_get_state;
+       device_touchscreen_funcs->set_state = touchscreen_set_state;
 
        return 0;
 }