1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef __GLOBALVAR_H
#define __GLOBALVAR_H
#include <param.h>
#include <driver.h>
#include <linux/err.h>
extern struct device_d global_device;
#ifdef CONFIG_GLOBALVAR
int globalvar_add_simple(const char *name, const char *value);
int globalvar_add(const char *name,
int (*set)(struct device_d *dev, struct param_d *p, const char *val),
const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags);
char *globalvar_get_match(const char *match, const char *separator);
void globalvar_set_match(const char *match, const char *val);
static inline int globalvar_add_simple_int(const char *name,
int *value, const char *format)
{
struct param_d *p;
p = dev_add_param_int(&global_device, name, NULL, NULL,
value, format, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
return 0;
}
static inline int globalvar_add_simple_bool(const char *name,
int *value)
{
struct param_d *p;
p = dev_add_param_bool(&global_device, name, NULL, NULL,
value, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
return 0;
}
static inline int globalvar_add_simple_enum(const char *name,
int *value, const char **names, int max)
{
struct param_d *p;
p = dev_add_param_enum(&global_device, name, NULL, NULL,
value, names, max, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
return 0;
}
static inline int globalvar_add_simple_ip(const char *name,
IPaddr_t *ip)
{
struct param_d *p;
p = dev_add_param_ip(&global_device, name, NULL, NULL,
ip, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
return 0;
}
#else
static inline int globalvar_add_simple(const char *name, const char *value)
{
return 0;
}
static inline int globalvar_add_simple_int(const char *name,
int *value, const char *format)
{
return 0;
}
static inline int globalvar_add_simple_bool(const char *name,
int *value)
{
return 0;
}
static inline int globalvar_add_simple_enum(const char *name,
int *value, const char **names, int max)
{
return 0;
}
static inline int globalvar_add_simple_ip(const char *name,
IPaddr_t *ip)
{
return 0;
}
static inline int globalvar_add(const char *name,
int (*set)(struct device_d *dev, struct param_d *p, const char *val),
const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags)
{
return 0;
}
static inline char *globalvar_get_match(const char *match, const char *separator)
{
return NULL;
}
static inline void globalvar_set_match(const char *match, const char *val) {}
#endif
#endif /* __GLOBALVAR_H */
|