4 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
30 static int get_device_serial(char **out)
35 fp = fopen(SERIAL_FILE_PATH, "r");
39 line = malloc(LINE_LEN);
40 p = fgets(line, LINE_LEN, fp);
51 static int board_open(struct hw_info *info,
52 const char *id, struct hw_common **common)
59 b = calloc(1, sizeof(*b));
63 b->common.info = info;
64 b->get_device_serial = get_device_serial;
70 static int board_close(struct hw_common *common)
77 b = container_of(common, struct hw_board, common);
83 HARDWARE_MODULE_STRUCTURE = {
84 .magic = HARDWARE_INFO_TAG,
85 .hal_version = HARDWARE_INFO_VERSION,
86 .device_version = BOARD_HARDWARE_DEVICE_VERSION,
87 .id = BOARD_HARDWARE_DEVICE_ID,