xref: /openbmc/u-boot/include/hwconfig.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
293f9dcf9SAnton Vorontsov /*
393f9dcf9SAnton Vorontsov  * An inteface for configuring a hardware via u-boot environment.
493f9dcf9SAnton Vorontsov  *
593f9dcf9SAnton Vorontsov  * Copyright (c) 2009  MontaVista Software, Inc.
6dd50af25SKumar Gala  * Copyright 2011 Freescale Semiconductor, Inc.
793f9dcf9SAnton Vorontsov  *
893f9dcf9SAnton Vorontsov  * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
993f9dcf9SAnton Vorontsov  */
1093f9dcf9SAnton Vorontsov 
1193f9dcf9SAnton Vorontsov #ifndef _HWCONFIG_H
1293f9dcf9SAnton Vorontsov #define _HWCONFIG_H
1393f9dcf9SAnton Vorontsov 
1493f9dcf9SAnton Vorontsov #include <linux/types.h>
151221ce45SMasahiro Yamada #include <linux/errno.h>
1693f9dcf9SAnton Vorontsov 
1793f9dcf9SAnton Vorontsov #ifdef CONFIG_HWCONFIG
1893f9dcf9SAnton Vorontsov 
19dd50af25SKumar Gala extern int hwconfig_f(const char *opt, char *buf);
20dd50af25SKumar Gala extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
21dd50af25SKumar Gala extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
22dd50af25SKumar Gala extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
23dd50af25SKumar Gala extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
24dd50af25SKumar Gala 				     size_t *subarglen, char *buf);
25dd50af25SKumar Gala extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
26dd50af25SKumar Gala 				 const char *subarg, char *buf);
2793f9dcf9SAnton Vorontsov #else
2893f9dcf9SAnton Vorontsov 
hwconfig_f(const char * opt,char * buf)29dd50af25SKumar Gala static inline int hwconfig_f(const char *opt, char *buf)
3093f9dcf9SAnton Vorontsov {
3193f9dcf9SAnton Vorontsov 	return -ENOSYS;
3293f9dcf9SAnton Vorontsov }
3393f9dcf9SAnton Vorontsov 
hwconfig_arg_f(const char * opt,size_t * arglen,char * buf)34dd50af25SKumar Gala static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
35dd50af25SKumar Gala 					 char *buf)
3693f9dcf9SAnton Vorontsov {
3793f9dcf9SAnton Vorontsov 	*arglen = 0;
3893f9dcf9SAnton Vorontsov 	return "";
3993f9dcf9SAnton Vorontsov }
4093f9dcf9SAnton Vorontsov 
hwconfig_arg_cmp_f(const char * opt,const char * arg,char * buf)41dd50af25SKumar Gala static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
42dd50af25SKumar Gala 				     char *buf)
4393f9dcf9SAnton Vorontsov {
4493f9dcf9SAnton Vorontsov 	return -ENOSYS;
4593f9dcf9SAnton Vorontsov }
4693f9dcf9SAnton Vorontsov 
hwconfig_sub_f(const char * opt,const char * subopt,char * buf)47dd50af25SKumar Gala static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
4893f9dcf9SAnton Vorontsov {
4993f9dcf9SAnton Vorontsov 	return -ENOSYS;
5093f9dcf9SAnton Vorontsov }
5193f9dcf9SAnton Vorontsov 
hwconfig_subarg_f(const char * opt,const char * subopt,size_t * subarglen,char * buf)52dd50af25SKumar Gala static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
53dd50af25SKumar Gala 					    size_t *subarglen, char *buf)
5493f9dcf9SAnton Vorontsov {
5593f9dcf9SAnton Vorontsov 	*subarglen = 0;
5693f9dcf9SAnton Vorontsov 	return "";
5793f9dcf9SAnton Vorontsov }
5893f9dcf9SAnton Vorontsov 
hwconfig_subarg_cmp_f(const char * opt,const char * subopt,const char * subarg,char * buf)59dd50af25SKumar Gala static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
60dd50af25SKumar Gala 					const char *subarg, char *buf)
6193f9dcf9SAnton Vorontsov {
6293f9dcf9SAnton Vorontsov 	return -ENOSYS;
6393f9dcf9SAnton Vorontsov }
6493f9dcf9SAnton Vorontsov 
6593f9dcf9SAnton Vorontsov #endif /* CONFIG_HWCONFIG */
6693f9dcf9SAnton Vorontsov 
hwconfig(const char * opt)67dd50af25SKumar Gala static inline int hwconfig(const char *opt)
68dd50af25SKumar Gala {
69dd50af25SKumar Gala 	return hwconfig_f(opt, NULL);
70dd50af25SKumar Gala }
71dd50af25SKumar Gala 
hwconfig_arg(const char * opt,size_t * arglen)72dd50af25SKumar Gala static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
73dd50af25SKumar Gala {
74dd50af25SKumar Gala 	return hwconfig_arg_f(opt, arglen, NULL);
75dd50af25SKumar Gala }
76dd50af25SKumar Gala 
hwconfig_arg_cmp(const char * opt,const char * arg)77dd50af25SKumar Gala static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
78dd50af25SKumar Gala {
79dd50af25SKumar Gala 	return hwconfig_arg_cmp_f(opt, arg, NULL);
80dd50af25SKumar Gala }
81dd50af25SKumar Gala 
hwconfig_sub(const char * opt,const char * subopt)82dd50af25SKumar Gala static inline int hwconfig_sub(const char *opt, const char *subopt)
83dd50af25SKumar Gala {
84dd50af25SKumar Gala 	return hwconfig_sub_f(opt, subopt, NULL);
85dd50af25SKumar Gala }
86dd50af25SKumar Gala 
hwconfig_subarg(const char * opt,const char * subopt,size_t * subarglen)87dd50af25SKumar Gala static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
88dd50af25SKumar Gala 					  size_t *subarglen)
89dd50af25SKumar Gala {
90dd50af25SKumar Gala 	return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
91dd50af25SKumar Gala }
92dd50af25SKumar Gala 
hwconfig_subarg_cmp(const char * opt,const char * subopt,const char * subarg)93dd50af25SKumar Gala static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
94dd50af25SKumar Gala 				      const char *subarg)
95dd50af25SKumar Gala {
96dd50af25SKumar Gala 	return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
97dd50af25SKumar Gala }
98dd50af25SKumar Gala 
9993f9dcf9SAnton Vorontsov #endif /* _HWCONFIG_H */
100