diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-09-16 19:49:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-09-18 09:24:38 +0200 |
commit | 50355554dc17182f80ff582daf9a680200830dcb (patch) | |
tree | a9417da2575aa84074c2ad54c299ce7f0ae173b6 /include/globalvar.h | |
parent | 179ed619f428da8a86ddabe3033f0acdf5159236 (diff) | |
download | barebox-50355554dc17182f80ff582daf9a680200830dcb.tar.gz barebox-50355554dc17182f80ff582daf9a680200830dcb.tar.xz |
globalvar: add globalvar_add_simple_int/bool/enum/ip support
so we can types var
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/globalvar.h')
-rw-r--r-- | include/globalvar.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/include/globalvar.h b/include/globalvar.h index c2a13b3657..456e8cd1f8 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -2,6 +2,10 @@ #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); @@ -12,12 +16,92 @@ int globalvar_add(const char *name, 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), |