led: Apply HAL ABI versioning 10/310010/1
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 04:13:08 +0000 (13:13 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Fri, 19 Apr 2024 05:58:05 +0000 (14:58 +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-led side and there is no need to be free
hal_backend_module_funcs in backend side.
So, hal_backend_module_funcs free code is removed.
Also, wrong module name is fixed and hal interface inclusion path is changed.
"led" -> "device-led"

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

index b52aa9819af8b5a5d7560dd2dfb30b0f7259cd0b..8773adaa65ef4a866d68aaeefb013cdd7bb72613 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <glib.h>
 
-#include <hal/hal-led-interface.h>
+#include <hal/hal-device-led-interface.h>
 #include <hal/hal-common-interface.h>
 
 #include </hal/include/device/hal-backend-common.h>
@@ -120,7 +120,7 @@ static int gpio_led_close_device(peripheral_i2c_h device_handle)
        return ret;
 }
 
-static int gpio_rgb_set_brightness(struct led_state *state)
+static int gpio_rgb_set_brightness(hal_device_led_state_s *state)
 {
        uint8_t cmd_pkt[4] = { SET_CMD_CODE, };
        peripheral_i2c_h handle;
@@ -150,9 +150,9 @@ static int gpio_rgb_set_brightness(struct led_state *state)
 }
 
 /* turn off led */
-static int gpio_rgb_turn_off(struct led_state *state)
+static int gpio_rgb_turn_off(hal_device_led_state_s *state)
 {
-       struct led_state st = { LED_TYPE_MANUAL, };
+       hal_device_led_state_s st = { HAL_DEVICE_LED_TYPE_MANUAL, };
        return gpio_rgb_set_brightness(&st);
 }
 
@@ -199,7 +199,7 @@ static int gpio_rgb_init_led()
 static gboolean gpio_rgb_timer_expired(gpointer data)
 {
        struct gpio_rgb_play_color_info *color;
-       struct led_state state = {LED_TYPE_MANUAL, };
+       hal_device_led_state_s state = {HAL_DEVICE_LED_TYPE_MANUAL, };
        int ret;
 
        if (play_info.timer) {
@@ -267,7 +267,7 @@ static int gpio_rgb_insert_play_list(unsigned color, int on, int off)
 }
 
 /* insert color info to the play list and start to play */
-static int gpio_rgb_set_brightness_blink(struct led_state *state)
+static int gpio_rgb_set_brightness_blink(hal_device_led_state_s *state)
 {
        unsigned int val;
        int ret;
@@ -298,22 +298,22 @@ static int gpio_rgb_set_brightness_blink(struct led_state *state)
        return 0;
 }
 
-static int gpio_rgb_turn_on(struct led_state *state)
+static int gpio_rgb_turn_on(hal_device_led_state_s *state)
 {
-       if (state->type == LED_TYPE_MANUAL)
+       if (state->type == HAL_DEVICE_LED_TYPE_MANUAL)
                return gpio_rgb_set_brightness(state);
 
        return gpio_rgb_set_brightness_blink(state);
 }
 
-static int gpio_rgb_set_state(enum led_device_type type, struct led_state *state)
+static int gpio_rgb_set_state(hal_device_led_device_type_e type, hal_device_led_state_s *state)
 {
-       if ((type != NOTIFICATION) || !state)
+       if ((type != HAL_DEVICE_LED_NOTIFICATION) || !state)
                return -EINVAL;
 
        switch (state->type) {
-       case LED_TYPE_BLINK:
-       case LED_TYPE_MANUAL:
+       case HAL_DEVICE_LED_TYPE_BLINK:
+       case HAL_DEVICE_LED_TYPE_MANUAL:
                break;
        default:
                _E("Not suppoted type (%d)", state->type);
@@ -329,24 +329,26 @@ static int gpio_rgb_set_state(enum led_device_type type, struct led_state *state
 
 static int led_init(void **data)
 {
-       hal_backend_led_funcs *led_device;
+       hal_backend_device_led_funcs *led_device;
 
-       led_device = calloc(1, sizeof(hal_backend_led_funcs));
+       if (!data) {
+               _E("Invalid parameter");
+               return -EINVAL;
+       }
+
+       led_device = *(hal_backend_device_led_funcs **) data;
        if (!led_device)
-               return -ENOMEM;
+               return -EINVAL;
 
        if (gpio_rgb_init_led()) {
-               free(led_device);
                return -EIO;
        } else {
                led_device->camera_front = NULL;
                led_device->camera_back = NULL;
                led_device->touch_key = NULL;
                led_device->notification = calloc(1, sizeof(struct led_funcs));
-               if (!led_device->notification) {
-                       free(led_device);
+               if (!led_device->notification)
                        return -ENOMEM;
-               }
 
                led_device->notification->set_state = gpio_rgb_set_state;
                led_device->notification->get_state = NULL;
@@ -357,21 +359,18 @@ static int led_init(void **data)
                led_device->notification->keyled_get_state = NULL;
        }
 
-       *data = (void *)led_device;
-
        return 0;
 }
 
 static int led_exit(void *data)
 {
-       hal_backend_led_funcs *led_device;
+       hal_backend_device_led_funcs *led_device;
 
        if (!data)
                return 0;
 
-       led_device = (hal_backend_led_funcs *)data;
+       led_device = (hal_backend_device_led_funcs *)data;
        free(led_device->notification);
-       free(led_device);
 
        return 0;
 }