Anton Vorontsov | a73904e | 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 | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 5 | * Copyright 2011 Freescale Semiconductor, Inc. |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 6 | * |
| 7 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #ifndef _HWCONFIG_H |
| 16 | #define _HWCONFIG_H |
| 17 | |
| 18 | #include <linux/types.h> |
| 19 | #include <asm/errno.h> |
| 20 | |
| 21 | #ifdef CONFIG_HWCONFIG |
| 22 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 23 | extern int hwconfig_f(const char *opt, char *buf); |
| 24 | extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf); |
| 25 | extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf); |
| 26 | extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf); |
| 27 | extern const char *hwconfig_subarg_f(const char *opt, const char *subopt, |
| 28 | size_t *subarglen, char *buf); |
| 29 | extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt, |
| 30 | const char *subarg, char *buf); |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 31 | #else |
| 32 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 33 | static inline int hwconfig_f(const char *opt, char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 34 | { |
| 35 | return -ENOSYS; |
| 36 | } |
| 37 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 38 | static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen, |
| 39 | char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 40 | { |
| 41 | *arglen = 0; |
| 42 | return ""; |
| 43 | } |
| 44 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 45 | static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg, |
| 46 | char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 47 | { |
| 48 | return -ENOSYS; |
| 49 | } |
| 50 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 51 | static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 52 | { |
| 53 | return -ENOSYS; |
| 54 | } |
| 55 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 56 | static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt, |
| 57 | size_t *subarglen, char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 58 | { |
| 59 | *subarglen = 0; |
| 60 | return ""; |
| 61 | } |
| 62 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 63 | static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt, |
| 64 | const char *subarg, char *buf) |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 65 | { |
| 66 | return -ENOSYS; |
| 67 | } |
| 68 | |
| 69 | #endif /* CONFIG_HWCONFIG */ |
| 70 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 71 | static inline int hwconfig(const char *opt) |
| 72 | { |
| 73 | return hwconfig_f(opt, NULL); |
| 74 | } |
| 75 | |
| 76 | static inline const char *hwconfig_arg(const char *opt, size_t *arglen) |
| 77 | { |
| 78 | return hwconfig_arg_f(opt, arglen, NULL); |
| 79 | } |
| 80 | |
| 81 | static inline int hwconfig_arg_cmp(const char *opt, const char *arg) |
| 82 | { |
| 83 | return hwconfig_arg_cmp_f(opt, arg, NULL); |
| 84 | } |
| 85 | |
| 86 | static inline int hwconfig_sub(const char *opt, const char *subopt) |
| 87 | { |
| 88 | return hwconfig_sub_f(opt, subopt, NULL); |
| 89 | } |
| 90 | |
| 91 | static inline const char *hwconfig_subarg(const char *opt, const char *subopt, |
| 92 | size_t *subarglen) |
| 93 | { |
| 94 | return hwconfig_subarg_f(opt, subopt, subarglen, NULL); |
| 95 | } |
| 96 | |
| 97 | static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt, |
| 98 | const char *subarg) |
| 99 | { |
| 100 | return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL); |
| 101 | } |
| 102 | |
Anton Vorontsov | a73904e | 2009-06-10 00:25:27 +0400 | [diff] [blame] | 103 | #endif /* _HWCONFIG_H */ |