summaryrefslogtreecommitdiff
path: root/include/util.h
blob: 7e89de038c2aa859586c5ac0e95c3e0ad3ff5eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifdef FEATURE_DLOG
	#define LOG_TAG "HAL_BACKEND_DEVICE_VISIONFIVE2"
	#include <dlog.h>
	#define _D(fmt, args...)	dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
	#define _I(fmt, args...)	dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
	#define _W(fmt, args...)	dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
	#define _E(fmt, args...)	dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
#else
	#define _D(x, ...)
	#define _I(x, ...)
	#define _W(x, ...)
	#define _E(x, ...)
#endif

#define EXPORT __attribute__ ((visibility("default")))

#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
#define MAX_BUF_SIZE	255

int sysfs_read_int(char *path, int *val);
int sysfs_read_str(char *path, char *str, int len);
int sysfs_write_buf(char *path, char *buf);
int sysfs_write_int(char *path, int val);
int sysfs_write_str(char *path, char *str);

/**
 * @brief Parse format from /proc/cmdline
 *
 * @param[in] format Format string
 * @param[out] ... Variable argument
 *
 * @return zero if cannot read else the number of matched and assigned items
 */
int parse_cmdline_scanf(const char *format, ...);