193f9dcf9SAnton Vorontsov /*
293f9dcf9SAnton Vorontsov * An inteface for configuring a hardware via u-boot environment.
393f9dcf9SAnton Vorontsov *
493f9dcf9SAnton Vorontsov * Copyright (c) 2009 MontaVista Software, Inc.
5dd50af25SKumar Gala * Copyright 2011 Freescale Semiconductor, Inc.
693f9dcf9SAnton Vorontsov *
793f9dcf9SAnton Vorontsov * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
893f9dcf9SAnton Vorontsov *
91a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+
1093f9dcf9SAnton Vorontsov */
1193f9dcf9SAnton Vorontsov
1293f9dcf9SAnton Vorontsov #ifndef _HWCONFIG_H
1393f9dcf9SAnton Vorontsov #define _HWCONFIG_H
1493f9dcf9SAnton Vorontsov
1593f9dcf9SAnton Vorontsov #include <linux/types.h>
16*1221ce45SMasahiro Yamada #include <linux/errno.h>
1793f9dcf9SAnton Vorontsov
1893f9dcf9SAnton Vorontsov #ifdef CONFIG_HWCONFIG
1993f9dcf9SAnton Vorontsov
20dd50af25SKumar Gala extern int hwconfig_f(const char *opt, char *buf);
21dd50af25SKumar Gala extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
22dd50af25SKumar Gala extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
23dd50af25SKumar Gala extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
24dd50af25SKumar Gala extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
25dd50af25SKumar Gala size_t *subarglen, char *buf);
26dd50af25SKumar Gala extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
27dd50af25SKumar Gala const char *subarg, char *buf);
2893f9dcf9SAnton Vorontsov #else
2993f9dcf9SAnton Vorontsov
hwconfig_f(const char * opt,char * buf)30dd50af25SKumar Gala static inline int hwconfig_f(const char *opt, char *buf)
3193f9dcf9SAnton Vorontsov {
3293f9dcf9SAnton Vorontsov return -ENOSYS;
3393f9dcf9SAnton Vorontsov }
3493f9dcf9SAnton Vorontsov
hwconfig_arg_f(const char * opt,size_t * arglen,char * buf)35dd50af25SKumar Gala static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
36dd50af25SKumar Gala char *buf)
3793f9dcf9SAnton Vorontsov {
3893f9dcf9SAnton Vorontsov *arglen = 0;
3993f9dcf9SAnton Vorontsov return "";
4093f9dcf9SAnton Vorontsov }
4193f9dcf9SAnton Vorontsov
hwconfig_arg_cmp_f(const char * opt,const char * arg,char * buf)42dd50af25SKumar Gala static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
43dd50af25SKumar Gala char *buf)
4493f9dcf9SAnton Vorontsov {
4593f9dcf9SAnton Vorontsov return -ENOSYS;
4693f9dcf9SAnton Vorontsov }
4793f9dcf9SAnton Vorontsov
hwconfig_sub_f(const char * opt,const char * subopt,char * buf)48dd50af25SKumar Gala static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
4993f9dcf9SAnton Vorontsov {
5093f9dcf9SAnton Vorontsov return -ENOSYS;
5193f9dcf9SAnton Vorontsov }
5293f9dcf9SAnton Vorontsov
hwconfig_subarg_f(const char * opt,const char * subopt,size_t * subarglen,char * buf)53dd50af25SKumar Gala static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
54dd50af25SKumar Gala size_t *subarglen, char *buf)
5593f9dcf9SAnton Vorontsov {
5693f9dcf9SAnton Vorontsov *subarglen = 0;
5793f9dcf9SAnton Vorontsov return "";
5893f9dcf9SAnton Vorontsov }
5993f9dcf9SAnton Vorontsov
hwconfig_subarg_cmp_f(const char * opt,const char * subopt,const char * subarg,char * buf)60dd50af25SKumar Gala static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
61dd50af25SKumar Gala const char *subarg, char *buf)
6293f9dcf9SAnton Vorontsov {
6393f9dcf9SAnton Vorontsov return -ENOSYS;
6493f9dcf9SAnton Vorontsov }
6593f9dcf9SAnton Vorontsov
6693f9dcf9SAnton Vorontsov #endif /* CONFIG_HWCONFIG */
6793f9dcf9SAnton Vorontsov
hwconfig(const char * opt)68dd50af25SKumar Gala static inline int hwconfig(const char *opt)
69dd50af25SKumar Gala {
70dd50af25SKumar Gala return hwconfig_f(opt, NULL);
71dd50af25SKumar Gala }
72dd50af25SKumar Gala
hwconfig_arg(const char * opt,size_t * arglen)73dd50af25SKumar Gala static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
74dd50af25SKumar Gala {
75dd50af25SKumar Gala return hwconfig_arg_f(opt, arglen, NULL);
76dd50af25SKumar Gala }
77dd50af25SKumar Gala
hwconfig_arg_cmp(const char * opt,const char * arg)78dd50af25SKumar Gala static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
79dd50af25SKumar Gala {
80dd50af25SKumar Gala return hwconfig_arg_cmp_f(opt, arg, NULL);
81dd50af25SKumar Gala }
82dd50af25SKumar Gala
hwconfig_sub(const char * opt,const char * subopt)83dd50af25SKumar Gala static inline int hwconfig_sub(const char *opt, const char *subopt)
84dd50af25SKumar Gala {
85dd50af25SKumar Gala return hwconfig_sub_f(opt, subopt, NULL);
86dd50af25SKumar Gala }
87dd50af25SKumar Gala
hwconfig_subarg(const char * opt,const char * subopt,size_t * subarglen)88dd50af25SKumar Gala static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
89dd50af25SKumar Gala size_t *subarglen)
90dd50af25SKumar Gala {
91dd50af25SKumar Gala return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
92dd50af25SKumar Gala }
93dd50af25SKumar Gala
hwconfig_subarg_cmp(const char * opt,const char * subopt,const char * subarg)94dd50af25SKumar Gala static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
95dd50af25SKumar Gala const char *subarg)
96dd50af25SKumar Gala {
97dd50af25SKumar Gala return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
98dd50af25SKumar Gala }
99dd50af25SKumar Gala
10093f9dcf9SAnton Vorontsov #endif /* _HWCONFIG_H */
101