blob: cf472107568ecb33bb25b74d277ceb2140207c63 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Anton Vorontsova73904e2009-06-10 00:25:27 +04002/*
3 * An inteface for configuring a hardware via u-boot environment.
4 *
5 * Copyright (c) 2009 MontaVista Software, Inc.
Kumar Gala72301602011-01-09 11:37:00 -06006 * Copyright 2011 Freescale Semiconductor, Inc.
Anton Vorontsova73904e2009-06-10 00:25:27 +04007 *
8 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
Anton Vorontsova73904e2009-06-10 00:25:27 +04009 */
10
11#ifndef _HWCONFIG_H
12#define _HWCONFIG_H
13
14#include <linux/types.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090015#include <linux/errno.h>
Anton Vorontsova73904e2009-06-10 00:25:27 +040016
17#ifdef CONFIG_HWCONFIG
18
Kumar Gala72301602011-01-09 11:37:00 -060019extern int hwconfig_f(const char *opt, char *buf);
20extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
21extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
22extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
23extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
24 size_t *subarglen, char *buf);
25extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
26 const char *subarg, char *buf);
Anton Vorontsova73904e2009-06-10 00:25:27 +040027#else
28
Kumar Gala72301602011-01-09 11:37:00 -060029static inline int hwconfig_f(const char *opt, char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040030{
31 return -ENOSYS;
32}
33
Kumar Gala72301602011-01-09 11:37:00 -060034static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
35 char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040036{
37 *arglen = 0;
38 return "";
39}
40
Kumar Gala72301602011-01-09 11:37:00 -060041static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
42 char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040043{
44 return -ENOSYS;
45}
46
Kumar Gala72301602011-01-09 11:37:00 -060047static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040048{
49 return -ENOSYS;
50}
51
Kumar Gala72301602011-01-09 11:37:00 -060052static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
53 size_t *subarglen, char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040054{
55 *subarglen = 0;
56 return "";
57}
58
Kumar Gala72301602011-01-09 11:37:00 -060059static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
60 const char *subarg, char *buf)
Anton Vorontsova73904e2009-06-10 00:25:27 +040061{
62 return -ENOSYS;
63}
64
65#endif /* CONFIG_HWCONFIG */
66
Kumar Gala72301602011-01-09 11:37:00 -060067static inline int hwconfig(const char *opt)
68{
69 return hwconfig_f(opt, NULL);
70}
71
72static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
73{
74 return hwconfig_arg_f(opt, arglen, NULL);
75}
76
77static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
78{
79 return hwconfig_arg_cmp_f(opt, arg, NULL);
80}
81
82static inline int hwconfig_sub(const char *opt, const char *subopt)
83{
84 return hwconfig_sub_f(opt, subopt, NULL);
85}
86
87static 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
93static 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
Anton Vorontsova73904e2009-06-10 00:25:27 +040099#endif /* _HWCONFIG_H */