Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 2 | /* |
| 3 | * An inteface for configuring a hardware via u-boot environment. |
| 4 | * |
| 5 | * Copyright (c) 2009 MontaVista Software, Inc. |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 6 | * Copyright 2011 Freescale Semiconductor, Inc. |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 7 | * |
| 8 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef _HWCONFIG_H |
| 12 | #define _HWCONFIG_H |
| 13 | |
| 14 | #include <linux/types.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 15 | #include <linux/errno.h> |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 16 | |
| 17 | #ifdef CONFIG_HWCONFIG |
| 18 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 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); |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 27 | #else |
| 28 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 29 | static inline int hwconfig_f(const char *opt, char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 30 | { |
| 31 | return -ENOSYS; |
| 32 | } |
| 33 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 34 | static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen, |
| 35 | char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 36 | { |
| 37 | *arglen = 0; |
| 38 | return ""; |
| 39 | } |
| 40 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 41 | static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg, |
| 42 | char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 43 | { |
| 44 | return -ENOSYS; |
| 45 | } |
| 46 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 47 | static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 48 | { |
| 49 | return -ENOSYS; |
| 50 | } |
| 51 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 52 | static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt, |
| 53 | size_t *subarglen, char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 54 | { |
| 55 | *subarglen = 0; |
| 56 | return ""; |
| 57 | } |
| 58 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 59 | static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt, |
| 60 | const char *subarg, char *buf) |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 61 | { |
| 62 | return -ENOSYS; |
| 63 | } |
| 64 | |
| 65 | #endif /* CONFIG_HWCONFIG */ |
| 66 | |
Kumar Gala | dd50af2 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 67 | static inline int hwconfig(const char *opt) |
| 68 | { |
| 69 | return hwconfig_f(opt, NULL); |
| 70 | } |
| 71 | |
| 72 | static inline const char *hwconfig_arg(const char *opt, size_t *arglen) |
| 73 | { |
| 74 | return hwconfig_arg_f(opt, arglen, NULL); |
| 75 | } |
| 76 | |
| 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 | |
| 82 | static inline int hwconfig_sub(const char *opt, const char *subopt) |
| 83 | { |
| 84 | return hwconfig_sub_f(opt, subopt, NULL); |
| 85 | } |
| 86 | |
| 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 | |
| 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 | |
Anton Vorontsov | 93f9dcf | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 99 | #endif /* _HWCONFIG_H */ |