2012-04-29 18:21:16 +00:00
|
|
|
#ifndef __GLOBALVAR_H
|
|
|
|
#define __GLOBALVAR_H
|
|
|
|
|
2013-08-14 10:29:06 +00:00
|
|
|
#include <param.h>
|
2013-09-16 17:49:56 +00:00
|
|
|
#include <driver.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
extern struct device_d global_device;
|
2013-08-14 10:29:06 +00:00
|
|
|
|
2012-09-11 10:19:21 +00:00
|
|
|
#ifdef CONFIG_GLOBALVAR
|
2013-08-14 19:16:21 +00:00
|
|
|
int globalvar_add_simple(const char *name, const char *value);
|
2012-04-29 18:21:16 +00:00
|
|
|
|
|
|
|
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);
|
2013-04-04 13:23:22 +00:00
|
|
|
char *globalvar_get_match(const char *match, const char *separator);
|
2012-08-24 03:17:43 +00:00
|
|
|
void globalvar_set_match(const char *match, const char *val);
|
2013-09-16 17:49:56 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2014-06-18 13:12:05 +00:00
|
|
|
|
|
|
|
int nvvar_load(void);
|
|
|
|
void nvvar_print(void);
|
|
|
|
int nvvar_add(const char *name, const char *value);
|
|
|
|
int nvvar_remove(const char *name);
|
2014-11-06 08:07:28 +00:00
|
|
|
void globalvar_print(void);
|
2014-06-18 13:12:05 +00:00
|
|
|
|
2012-09-11 10:19:21 +00:00
|
|
|
#else
|
2013-08-14 19:16:21 +00:00
|
|
|
static inline int globalvar_add_simple(const char *name, const char *value)
|
2012-09-11 10:19:21 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-16 17:49:56 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-11 10:19:21 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-04 13:23:22 +00:00
|
|
|
static inline char *globalvar_get_match(const char *match, const char *separator)
|
2012-09-11 10:19:21 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-08-24 03:17:43 +00:00
|
|
|
|
|
|
|
static inline void globalvar_set_match(const char *match, const char *val) {}
|
2014-06-18 13:12:05 +00:00
|
|
|
|
|
|
|
static inline int nvvar_load(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 10:19:21 +00:00
|
|
|
#endif
|
2012-04-29 18:21:16 +00:00
|
|
|
|
|
|
|
#endif /* __GLOBALVAR_H */
|