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 * 9*1a459660SWolfgang 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> 1693f9dcf9SAnton Vorontsov #include <asm/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 30dd50af25SKumar Gala static inline int hwconfig_f(const char *opt, char *buf) 3193f9dcf9SAnton Vorontsov { 3293f9dcf9SAnton Vorontsov return -ENOSYS; 3393f9dcf9SAnton Vorontsov } 3493f9dcf9SAnton Vorontsov 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 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 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 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 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 68dd50af25SKumar Gala static inline int hwconfig(const char *opt) 69dd50af25SKumar Gala { 70dd50af25SKumar Gala return hwconfig_f(opt, NULL); 71dd50af25SKumar Gala } 72dd50af25SKumar Gala 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 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 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 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 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