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