hwconfig.h 2.37 KB
Newer Older
1 2 3 4
/*
 * An inteface for configuring a hardware via u-boot environment.
 *
 * Copyright (c) 2009  MontaVista Software, Inc.
5
 * Copyright 2011 Freescale Semiconductor, Inc.
6 7 8
 *
 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
 *
9
 * SPDX-License-Identifier:	GPL-2.0+
10 11 12 13 14 15 16 17 18 19
 */

#ifndef _HWCONFIG_H
#define _HWCONFIG_H

#include <linux/types.h>
#include <asm/errno.h>

#ifdef CONFIG_HWCONFIG

20 21 22 23 24 25 26 27
extern int hwconfig_f(const char *opt, char *buf);
extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
				     size_t *subarglen, char *buf);
extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
				 const char *subarg, char *buf);
28 29
#else

30
static inline int hwconfig_f(const char *opt, char *buf)
31 32 33 34
{
	return -ENOSYS;
}

35 36
static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
					 char *buf)
37 38 39 40 41
{
	*arglen = 0;
	return "";
}

42 43
static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
				     char *buf)
44 45 46 47
{
	return -ENOSYS;
}

48
static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
49 50 51 52
{
	return -ENOSYS;
}

53 54
static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
					    size_t *subarglen, char *buf)
55 56 57 58 59
{
	*subarglen = 0;
	return "";
}

60 61
static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
					const char *subarg, char *buf)
62 63 64 65 66 67
{
	return -ENOSYS;
}

#endif /* CONFIG_HWCONFIG */

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
static inline int hwconfig(const char *opt)
{
	return hwconfig_f(opt, NULL);
}

static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
{
	return hwconfig_arg_f(opt, arglen, NULL);
}

static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
{
	return hwconfig_arg_cmp_f(opt, arg, NULL);
}

static inline int hwconfig_sub(const char *opt, const char *subopt)
{
	return hwconfig_sub_f(opt, subopt, NULL);
}

static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
					  size_t *subarglen)
{
	return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
}

static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
				      const char *subarg)
{
	return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
}

100
#endif /* _HWCONFIG_H */