mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] globalvar: add globalvar_add_simple_int/bool/enum/ip support
Date: Mon, 16 Sep 2013 19:49:56 +0200	[thread overview]
Message-ID: <1379353800-28237-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20130916174824.GH21829@ns203013.ovh.net>

so we can types var

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/globalvar.c  |  2 +-
 include/globalvar.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index edb66dd..6ef4a6a 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -6,7 +6,7 @@
 #include <magicvar.h>
 #include <generated/utsrelease.h>
 
-static struct device_d global_device = {
+struct device_d global_device = {
 	.name = "global",
 	.id = DEVICE_ID_SINGLE,
 };
diff --git a/include/globalvar.h b/include/globalvar.h
index c2a13b3..298e8ef 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -2,6 +2,9 @@
 #define __GLOBALVAR_H
 
 #include <param.h>
+#include <driver.h>
+
+extern struct device_d global_device;
 
 #ifdef CONFIG_GLOBALVAR
 int globalvar_add_simple(const char *name, const char *value);
@@ -12,12 +15,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),
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-09-16 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 17:48 [PATCH 0/5 v3] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD
2013-09-16 17:49 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-16 17:49   ` [PATCH 2/5] login: add globalvar timeout support Jean-Christophe PLAGNIOL-VILLARD
2013-09-16 17:49   ` [PATCH 3/5] login: disable input console if password wrong Jean-Christophe PLAGNIOL-VILLARD
2013-09-16 17:49   ` [PATCH 4/5] login/passwd: add default password support Jean-Christophe PLAGNIOL-VILLARD
2013-09-16 17:50   ` [PATCH 5/5] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD
2013-09-18  7:25 ` [PATCH 0/5 v3] " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379353800-28237-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox