Apply next HAL architecture (hal api + backend)
[platform/adaptation/RPI3/device-manager-plugin-RPI3.git] / hw / board / board.c
index 3c6b42d..15654a5 100644 (file)
  */
 
 #define _GNU_SOURCE
-#include <hw/board.h>
+#include <hal/device/hal-board-interface.h>
+#include <hal/hal-common-interface.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 
+#include "common.h"
+
 #define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
 #define LINE_LEN 64
 
@@ -48,44 +51,34 @@ static int get_device_serial(char **out)
        return 0;
 }
 
-static int board_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int board_init(void **data)
 {
-       struct hw_board *b;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_board_funcs *board_funcs;
 
-       b = calloc(1, sizeof(*b));
-       if (!b)
+       board_funcs = calloc(1, sizeof(hal_backend_board_funcs));
+       if (!board_funcs)
                return -ENOMEM;
 
-       b->common.info = info;
-       b->get_device_serial = get_device_serial;
+       board_funcs->get_device_serial = get_device_serial;
+
+       *data = (void *)board_funcs;
 
-       *common = &b->common;
        return 0;
 }
 
-static int board_close(struct hw_common *common)
+static int board_exit(void *data)
 {
-       struct hw_board *b;
-
-       if (!common)
-               return -EINVAL;
-
-       b = container_of(common, struct hw_board, common);
-       free(b);
+       if (!data)
+               return 0;
 
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = BOARD_HARDWARE_DEVICE_VERSION,
-       .id = BOARD_HARDWARE_DEVICE_ID,
-       .name = "device",
-       .open = board_open,
-       .close = board_close,
+hal_backend EXPORT hal_backend_device_board_data = {
+       .name = "board",
+       .vendor = "rpi3",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = board_init,
+       .exit = board_exit,
 };