2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <hal/hal-common.h>
20 #include "hal-board-interface.h"
23 static hal_backend_board_funcs *hal_board_funcs = NULL;
25 -1 : failed to initialize
27 1 : succeeded to initialize
29 static int hal_initialized = 0;
31 int hal_device_board_get_backend(void)
38 ret = hal_common_get_backend(HAL_MODULE_DEVICE_BOARD, (void **)&hal_board_funcs);
40 _E("Failed to get board backend");
49 int hal_device_board_put_backend(void)
54 hal_common_put_backend(HAL_MODULE_DEVICE_BOARD, (void *)hal_board_funcs);
55 hal_board_funcs = NULL;
61 int hal_device_board_get_device_serial_number(char *buffer, int len)
65 if (!hal_board_funcs && !hal_initialized) {
66 if ((ret = hal_device_board_get_backend()) < 0)
70 if (!hal_board_funcs ||
71 !hal_board_funcs->get_device_serial_number)
74 return hal_board_funcs->get_device_serial_number(buffer, len);
77 int hal_device_board_get_device_revision(int *revision)
81 if (!hal_board_funcs && !hal_initialized) {
82 if ((ret = hal_device_board_get_backend()) < 0)
86 if (!hal_board_funcs ||
87 !hal_board_funcs->get_device_revision)
90 return hal_board_funcs->get_device_revision(revision);
93 int hal_device_board_switch_partition(int argc, char *argv[])
97 if (!hal_board_funcs && !hal_initialized) {
98 if ((ret = hal_device_board_get_backend()) < 0)
102 if (!hal_board_funcs ||
103 !hal_board_funcs->switch_partition)
106 return hal_board_funcs->switch_partition(argc, argv);