1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * An inteface for configuring a hardware via u-boot environment.
4 *
5 * Copyright (c) 2009 MontaVista Software, Inc.
6 * Copyright 2011 Freescale Semiconductor, Inc.
7 *
8 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
9 */
10
11 #ifndef _HWCONFIG_H
12 #define _HWCONFIG_H
13
14 #include <linux/types.h>
15 #include <linux/errno.h>
16
17 #ifdef CONFIG_HWCONFIG
18
19 extern int hwconfig_f(const char *opt, char *buf);
20 extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
21 extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
22 extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
23 extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
24 size_t *subarglen, char *buf);
25 extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
26 const char *subarg, char *buf);
27 #else
28
hwconfig_f(const char * opt,char * buf)29 static inline int hwconfig_f(const char *opt, char *buf)
30 {
31 return -ENOSYS;
32 }
33
hwconfig_arg_f(const char * opt,size_t * arglen,char * buf)34 static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
35 char *buf)
36 {
37 *arglen = 0;
38 return "";
39 }
40
hwconfig_arg_cmp_f(const char * opt,const char * arg,char * buf)41 static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
42 char *buf)
43 {
44 return -ENOSYS;
45 }
46
hwconfig_sub_f(const char * opt,const char * subopt,char * buf)47 static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
48 {
49 return -ENOSYS;
50 }
51
hwconfig_subarg_f(const char * opt,const char * subopt,size_t * subarglen,char * buf)52 static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
53 size_t *subarglen, char *buf)
54 {
55 *subarglen = 0;
56 return "";
57 }
58
hwconfig_subarg_cmp_f(const char * opt,const char * subopt,const char * subarg,char * buf)59 static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
60 const char *subarg, char *buf)
61 {
62 return -ENOSYS;
63 }
64
65 #endif /* CONFIG_HWCONFIG */
66
hwconfig(const char * opt)67 static inline int hwconfig(const char *opt)
68 {
69 return hwconfig_f(opt, NULL);
70 }
71
hwconfig_arg(const char * opt,size_t * arglen)72 static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
73 {
74 return hwconfig_arg_f(opt, arglen, NULL);
75 }
76
hwconfig_arg_cmp(const char * opt,const char * arg)77 static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
78 {
79 return hwconfig_arg_cmp_f(opt, arg, NULL);
80 }
81
hwconfig_sub(const char * opt,const char * subopt)82 static inline int hwconfig_sub(const char *opt, const char *subopt)
83 {
84 return hwconfig_sub_f(opt, subopt, NULL);
85 }
86
hwconfig_subarg(const char * opt,const char * subopt,size_t * subarglen)87 static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
88 size_t *subarglen)
89 {
90 return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
91 }
92
hwconfig_subarg_cmp(const char * opt,const char * subopt,const char * subarg)93 static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
94 const char *subarg)
95 {
96 return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
97 }
98
99 #endif /* _HWCONFIG_H */
100