mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] switch globalvar to it's own bus
@ 2012-09-24 15:27 Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:27 UTC (permalink / raw)
  To: barebox

HI,

	The folowing patch serie switch the globalvar to it's onw bus and set
	of device. This will allow to reduce the time spend to search the
	right parameter especially when we have quite a lot's of globalvar.

	In this patch serie not all of the globalvar are converted but some fo
	them

	The one missingis the linux one

The following changes since commit 6392955f283389fa4fecb0e2d5d1837bcb83f480:

  Merge branch 'for-next/testing-menu' into next (2012-09-20 23:11:42 +0200)

are available in the git repository at:


  git://git.jcrosoft.org/barebox.git delivery/globalvar

for you to fetch changes up to b17dcadf3ca3e8ffaa2cfcff69f7a2efef563e31:

  bootm: switch globalvar to it's own device (2012-09-24 11:13:02 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (5):
      globalvar: add it's own bus
      globalvar: allow to register multiple device
      net: switch to global device
      dhcp: switch globalvar to it's own device
      bootm: switch globalvar to it's own device

 arch/arm/boards/at91rm9200ek/env/config                 |    2 +-
 arch/arm/boards/at91sam9260ek/env/config                |    4 ++--
 arch/arm/boards/at91sam9261ek/env/config                |    4 ++--
 arch/arm/boards/at91sam9263ek/env/config                |    2 +-
 arch/arm/boards/at91sam9m10g45ek/env/config             |    2 +-
 arch/arm/boards/at91sam9x5ek/env/config                 |    2 +-
 arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 |    4 ++--
 arch/arm/boards/freescale-mx53-loco/env/config          |    2 +-
 arch/arm/boards/pcm038/env/boot/nand-ubi                |    4 ++--
 arch/arm/boards/qil-a9260/env/config                    |    2 +-
 arch/arm/boards/tny-a926x/env/config                    |    6 +++---
 arch/arm/boards/usb-a926x/env/config                    |    6 +++---
 commands/bootm.c                                        |   24 +++++++++++++++---------
 common/globalvar.c                                      |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
 defaultenv-2/base/boot/initrd                           |    6 +++---
 defaultenv-2/base/boot/net                              |    4 ++--
 defaultenv-2/base/data/boot-template                    |    6 +++---
 defaultenv-2/base/network/eth0                          |    2 +-
 defaultenv/bin/boot                                     |   12 ++++++------
 defaultenv/config                                       |    2 +-
 include/globalvar.h                                     |   26 ++++++++++++++++++++++++++
 net/dhcp.c                                              |   58 +++++++++++++++++-----------------------------------------
 net/net.c                                               |   15 +++++++--------
 23 files changed, 171 insertions(+), 110 deletions(-)

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] globalvar: add it's own bus
  2012-09-24 15:27 [RFC PATCH 0/5] switch globalvar to it's own bus Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-24 15:40 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 2/5] globalvar: allow to register multiple device Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/globalvar.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/common/globalvar.c b/common/globalvar.c
index a8aaa72..6bf2332 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -66,8 +66,21 @@ int globalvar_add_simple(const char *name)
 	return globalvar_add(name, NULL, NULL, 0);
 }
 
+static int global_match(struct device_d *dev, struct driver_d *drv)
+{
+	return 1;
+}
+
+static struct bus_type global_bus = {
+	.name = "global",
+	.match = global_match,
+	.probe = dummy_probe,
+};
+
 static int globalvar_init(void)
 {
+	bus_register(&global_bus);
+	global_device.bus = &global_bus;
 	register_device(&global_device);
 
 	return 0;
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/5] globalvar: allow to register multiple device
  2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-24 15:40   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 3/5] net: switch to global device Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/globalvar.c  |   77 +++++++++++++++++++++++++++++++++++++++------------
 include/globalvar.h |   26 +++++++++++++++++
 2 files changed, 85 insertions(+), 18 deletions(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index 6bf2332..19e4a17 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -3,33 +3,30 @@
 #include <globalvar.h>
 #include <init.h>
 
-static struct device_d global_device = {
-	.name = "global",
-	.id = DEVICE_ID_SINGLE,
-};
+static struct device_d *global_device;
 
 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 dev_add_param(&global_device, name, set, get, flags);
+	return dev_add_param(global_device, name, set, get, flags);
 }
 
 /*
- * globalvar_get_match
+ * global_get_match
  *
- * get a concatenated string of all globalvars beginning with 'match'.
- * This adds whitespaces between the different globalvars
+ * get a concatenated string of all global vars beginning with 'match'.
+ * This adds whitespaces between the different global vars
  */
-char *globalvar_get_match(const char *match, const char *seperator)
+char *global_get_match(struct device_d *dev, const char *match, const char *seperator)
 {
 	char *val = NULL;
 	struct param_d *param;
 
-	list_for_each_entry(param, &global_device.parameters, list) {
+	list_for_each_entry(param, &dev->parameters, list) {
 		if (!strncmp(match, param->name, strlen(match))) {
-			const char *p = dev_get_param(&global_device, param->name);
+			const char *p = dev_get_param(dev, param->name);
 			if (val) {
 				char *new = asprintf("%s%s%s", val, seperator, p);
 				free(val);
@@ -46,16 +43,42 @@ char *globalvar_get_match(const char *match, const char *seperator)
 	return val;
 }
 
-void globalvar_set_match(const char *match, const char *val)
+/*
+ * globalvar_get_match
+ *
+ * get a concatenated string of all globalvars beginning with 'match'.
+ * This adds whitespaces between the different globalvars
+ */
+char *globalvar_get_match(const char *match, const char *seperator)
+{
+	return global_get_match(global_device, match, seperator);
+}
+
+void global_set_match(struct device_d *dev, const char *match, const char *val)
 {
 	struct param_d *param;
 
-	list_for_each_entry(param, &global_device.parameters, list) {
+	list_for_each_entry(param, &dev->parameters, list) {
 		if (!strncmp(match, param->name, strlen(match)))
-			dev_set_param(&global_device, param->name, val);
+			dev_set_param(dev, param->name, val);
 	}
 }
 
+void globalvar_set_match(const char *match, const char *val)
+{
+	global_set_match(global_device, match, val);
+}
+
+/*
+ * global_add_simple
+ *
+ * add a new global named 'name'
+ */
+int global_add_simple(struct device_d *dev, const char *name)
+{
+	return dev_add_param(dev, name, NULL, NULL, 0);
+}
+
 /*
  * globalvar_add_simple
  *
@@ -63,7 +86,7 @@ void globalvar_set_match(const char *match, const char *val)
  */
 int globalvar_add_simple(const char *name)
 {
-	return globalvar_add(name, NULL, NULL, 0);
+	return global_add_simple(global_device, name);
 }
 
 static int global_match(struct device_d *dev, struct driver_d *drv)
@@ -77,12 +100,30 @@ static struct bus_type global_bus = {
 	.probe = dummy_probe,
 };
 
+struct device_d *global_add_device(const char *name)
+{
+	struct device_d *dev;
+
+	dev = xzalloc(sizeof(*dev));
+	strcpy(dev->name, name);
+	dev->id = DEVICE_ID_SINGLE;
+	dev->bus = &global_bus;
+
+	register_device(dev);
+
+	return dev;
+}
+
 static int globalvar_init(void)
 {
-	bus_register(&global_bus);
-	global_device.bus = &global_bus;
-	register_device(&global_device);
+	global_device = global_add_device("global");
 
 	return 0;
 }
 postconsole_initcall(globalvar_init);
+
+static int global_bus_init(void)
+{
+	return bus_register(&global_bus);
+}
+pure_initcall(global_bus_init);
diff --git a/include/globalvar.h b/include/globalvar.h
index ddf885f..c1d73c4 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -2,6 +2,7 @@
 #define __GLOBALVAR_H
 
 #ifdef CONFIG_GLOBALVAR
+struct device_d *global_add_device(const char *name);
 int globalvar_add_simple(const char *name);
 
 int globalvar_add(const char *name,
@@ -10,6 +11,13 @@ int globalvar_add(const char *name,
 		unsigned long flags);
 char *globalvar_get_match(const char *match, const char *seperator);
 void globalvar_set_match(const char *match, const char *val);
+
+struct device_d *global_add_device(const char *name);
+int global_add_simple(struct device_d *dev, const char *name);
+void global_set_match(struct device_d *dev, const char *match,
+			const char *val);
+char *global_get_match(struct device_d *dev, const char *match,
+			const char *seperator);
 #else
 static inline int globalvar_add_simple(const char *name)
 {
@@ -30,6 +38,24 @@ static inline char *globalvar_get_match(const char *match, const char *seperator
 }
 
 static inline void globalvar_set_match(const char *match, const char *val) {}
+
+struct device_d *global_add_device(const char *name)
+{
+	return NULL;
+}
+
+int global_add_simple(struct device_d *dev, const char *name)
+{
+	return 0;
+}
+
+void global_set_match(struct device_d *dev, const char *match,
+			const char *val) {}
+char *global_get_match(struct device_d *dev, const char *match,
+			const char *seperator)
+{
+	return NULL;
+}
 #endif
 
 #endif /* __GLOBALVAR_H */
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/5] net: switch to global device
  2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 2/5] globalvar: allow to register multiple device Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-24 15:40   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 4/5] dhcp: switch globalvar to it's own device Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 5/5] bootm: " Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 net/net.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/net/net.c b/net/net.c
index 3ac098f..6455b18 100644
--- a/net/net.c
+++ b/net/net.c
@@ -35,6 +35,7 @@
 #include <init.h>
 #include <linux/ctype.h>
 #include <linux/err.h>
+#include <globalvar.h>
 
 static IPaddr_t	net_netmask;		/* Our subnet mask (0=unknown)	*/
 static IPaddr_t	net_gateway;		/* Our gateways IP address	*/
@@ -664,21 +665,19 @@ out:
 	return ret;
 }
 
-static struct device_d net_device = {
-	.name = "net",
-	.id = DEVICE_ID_SINGLE,
-};
-
 static int net_init(void)
 {
+	struct device_d *dev;
 	int i;
 
 	for (i = 0; i < PKTBUFSRX; i++)
 		NetRxPackets[i] = net_alloc_packet();
 
-	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
-	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
+	dev = global_add_device("net");
+	if (dev) {
+		global_add_simple(dev, "nameserver");
+		global_add_simple(dev, "domainname");
+	}
 
 	return 0;
 }
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/5] dhcp: switch globalvar to it's own device
  2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 2/5] globalvar: allow to register multiple device Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 3/5] net: switch to global device Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-24 15:40   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-24 15:40   ` [PATCH 5/5] bootm: " Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91rm9200ek/env/config        |    2 +-
 arch/arm/boards/at91sam9260ek/env/config       |    4 +-
 arch/arm/boards/at91sam9261ek/env/config       |    4 +-
 arch/arm/boards/at91sam9263ek/env/config       |    2 +-
 arch/arm/boards/at91sam9m10g45ek/env/config    |    2 +-
 arch/arm/boards/at91sam9x5ek/env/config        |    2 +-
 arch/arm/boards/freescale-mx53-loco/env/config |    2 +-
 arch/arm/boards/qil-a9260/env/config           |    2 +-
 arch/arm/boards/tny-a926x/env/config           |    6 +--
 arch/arm/boards/usb-a926x/env/config           |    6 +--
 defaultenv-2/base/network/eth0                 |    2 +-
 defaultenv/bin/boot                            |   12 ++---
 defaultenv/config                              |    2 +-
 net/dhcp.c                                     |   58 +++++++-----------------
 14 files changed, 41 insertions(+), 65 deletions(-)

diff --git a/arch/arm/boards/at91rm9200ek/env/config b/arch/arm/boards/at91rm9200ek/env/config
index a3830cb..8ef28f5 100644
--- a/arch/arm/boards/at91rm9200ek/env/config
+++ b/arch/arm/boards/at91rm9200ek/env/config
@@ -3,7 +3,7 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-global.dhcp.vendor_id=barebox-at91rm9200ek
+dhcp.vendor_id=barebox-at91rm9200ek
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/at91sam9260ek/env/config b/arch/arm/boards/at91sam9260ek/env/config
index 8e88186..53720ae 100644
--- a/arch/arm/boards/at91sam9260ek/env/config
+++ b/arch/arm/boards/at91sam9260ek/env/config
@@ -6,9 +6,9 @@ ip=dhcp-barebox
 
 if [ x$armlinux_architecture = x1099 ]
 then
-	global.dhcp.vendor_id=barebox-at91sam9260ek
+	dhcp.vendor_id=barebox-at91sam9260ek
 else
-	global.dhcp.vendor_id=barebox-at91sam9g20ek
+	dhcp.vendor_id=barebox-at91sam9g20ek
 fi
 
 # or set your networking parameters here
diff --git a/arch/arm/boards/at91sam9261ek/env/config b/arch/arm/boards/at91sam9261ek/env/config
index 7d85577..bc7626e 100644
--- a/arch/arm/boards/at91sam9261ek/env/config
+++ b/arch/arm/boards/at91sam9261ek/env/config
@@ -6,9 +6,9 @@ ip=dhcp-barebox
 
 if [ x$armlinux_architecture = x848 ]
 then
-	global.dhcp.vendor_id=barebox-at91sam9261ek
+	dhcp.vendor_id=barebox-at91sam9261ek
 else
-	global.dhcp.vendor_id=barebox-at91sam9g10ek
+	dhcp.vendor_id=barebox-at91sam9g10ek
 fi
 
 # or set your networking parameters here
diff --git a/arch/arm/boards/at91sam9263ek/env/config b/arch/arm/boards/at91sam9263ek/env/config
index 5125020..60e38e5 100644
--- a/arch/arm/boards/at91sam9263ek/env/config
+++ b/arch/arm/boards/at91sam9263ek/env/config
@@ -3,7 +3,7 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-global.dhcp.vendor_id=barebox-at91sam9263ek
+dhcp.vendor_id=barebox-at91sam9263ek
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/at91sam9m10g45ek/env/config b/arch/arm/boards/at91sam9m10g45ek/env/config
index 54ed2cb..a112a1a 100644
--- a/arch/arm/boards/at91sam9m10g45ek/env/config
+++ b/arch/arm/boards/at91sam9m10g45ek/env/config
@@ -3,7 +3,7 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-global.dhcp.vendor_id=barebox-at91sam9m10g45ek
+dhcp.vendor_id=barebox-at91sam9m10g45ek
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/at91sam9x5ek/env/config b/arch/arm/boards/at91sam9x5ek/env/config
index 6a985ce..3e024ed 100644
--- a/arch/arm/boards/at91sam9x5ek/env/config
+++ b/arch/arm/boards/at91sam9x5ek/env/config
@@ -3,7 +3,7 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-global.dhcp.vendor_id=barebox-at91sam9x5ek
+dhcp.vendor_id=barebox-at91sam9x5ek
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/freescale-mx53-loco/env/config b/arch/arm/boards/freescale-mx53-loco/env/config
index 2ab1268..43979a3 100644
--- a/arch/arm/boards/freescale-mx53-loco/env/config
+++ b/arch/arm/boards/freescale-mx53-loco/env/config
@@ -7,7 +7,7 @@ user=
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
-global.dhcp.vendor_id=barebox-mx53-loco
+dhcp.vendor_id=barebox-mx53-loco
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/qil-a9260/env/config b/arch/arm/boards/qil-a9260/env/config
index 9971106..e0e2a9f 100644
--- a/arch/arm/boards/qil-a9260/env/config
+++ b/arch/arm/boards/qil-a9260/env/config
@@ -3,7 +3,7 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-global.dhcp.vendor_id=barebox-qil-a9260
+dhcp.vendor_id=barebox-qil-a9260
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/tny-a926x/env/config b/arch/arm/boards/tny-a926x/env/config
index c19ec4f..dd5219f 100644
--- a/arch/arm/boards/tny-a926x/env/config
+++ b/arch/arm/boards/tny-a926x/env/config
@@ -3,9 +3,9 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-[ x$armlinux_architecture = x2058 ] && global.dhcp.vendor_id=barebox-tny-a9260
-[ x$armlinux_architecture = x2059 ] && global.dhcp.vendor_id=barebox-tny-a9g20
-[ x$armlinux_architecture = x2140 ] && global.dhcp.vendor_id=barebox-tny-a9263
+[ x$armlinux_architecture = x2058 ] && dhcp.vendor_id=barebox-tny-a9260
+[ x$armlinux_architecture = x2059 ] && dhcp.vendor_id=barebox-tny-a9g20
+[ x$armlinux_architecture = x2140 ] && dhcp.vendor_id=barebox-tny-a9263
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/arch/arm/boards/usb-a926x/env/config b/arch/arm/boards/usb-a926x/env/config
index 49199ba..6f6e823 100644
--- a/arch/arm/boards/usb-a926x/env/config
+++ b/arch/arm/boards/usb-a926x/env/config
@@ -3,9 +3,9 @@
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp-barebox
-[ x$armlinux_architecture = x1709 ] && global.dhcp.vendor_id=barebox-usb-a9260
-[ x$armlinux_architecture = x1710 ] && global.dhcp.vendor_id=barebox-usb-a9263
-[ x$armlinux_architecture = x1841 ] && global.dhcp.vendor_id=barebox-usb-a9g20
+[ x$armlinux_architecture = x1709 ] && dhcp.vendor_id=barebox-usb-a9260
+[ x$armlinux_architecture = x1710 ] && dhcp.vendor_id=barebox-usb-a9263
+[ x$armlinux_architecture = x1841 ] && dhcp.vendor_id=barebox-usb-a9g20
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/defaultenv-2/base/network/eth0 b/defaultenv-2/base/network/eth0
index 7e731ca..59c1e6d 100644
--- a/defaultenv-2/base/network/eth0
+++ b/defaultenv-2/base/network/eth0
@@ -2,7 +2,7 @@
 
 # ip setting (static/dhcp)
 ip=dhcp
-global.dhcp.vendor_id=barebox-${global.hostname}
+dhcp.vendor_id=barebox-${global.hostname}
 
 # static setup used if ip=static
 ipaddr=
diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 4e2056e..7fb37a8 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -44,14 +44,14 @@ fi
 if [ x$ip = xdhcp -o x$ip = "xdhcp-barebox" ]; then
 	if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
 		dhcp
-		if [ x${global.dhcp.rootpath} != x ]; then
-			nfsroot=${global.dhcp.rootpath}
+		if [ x${dhcp.rootpath} != x ]; then
+			nfsroot=${dhcp.rootpath}
 		fi
-		if [ x${global.dhcp.bootfile} != x ]; then
-			kernelimage=${global.dhcp.bootfile}
+		if [ x${dhcp.bootfile} != x ]; then
+			kernelimage=${dhcp.bootfile}
 		fi
-		if [ x$global.dhcp.oftree_file} != x ]; then
-			oftreeimage=${global.dhcp_oftree_file}
+		if [ x$dhcp.oftree_file} != x ]; then
+			oftreeimage=${dhcp.oftree_file}
 		fi
 	fi
 fi
diff --git a/defaultenv/config b/defaultenv/config
index 391ba47..2a7b610 100644
--- a/defaultenv/config
+++ b/defaultenv/config
@@ -11,7 +11,7 @@ fi
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
-global.dhcp.vendor_id=barebox
+dhcp.vendor_id=barebox
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
diff --git a/net/dhcp.c b/net/dhcp.c
index 768255e..673784e 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -81,31 +81,16 @@ static uint32_t dhcp_leasetime;
 static IPaddr_t net_dhcp_server_ip;
 static uint64_t dhcp_start;
 static char dhcp_tftpname[256];
+static struct device_d *dhcp_dev;
 
 static const char* dhcp_get_barebox_global(const char * var)
 {
-	char * var_global = asprintf("global.dhcp.%s", var);
-	const char *val;
-
-	if (!var_global)
-		return NULL;
-
-	val = getenv(var_global);
-	free(var_global);
-	return val;
+	return dev_get_param(dhcp_dev, var);
 }
 
 static int dhcp_set_barebox_global(const char * var, char *val)
 {
-	char * var_global = asprintf("global.dhcp.%s", var);
-	int ret;
-
-	if (!var_global)
-		return -ENOMEM;
-
-	ret = setenv(var_global, val);
-	free(var_global);
-	return ret;
+	return dev_set_param(dhcp_dev, var, val);
 }
 
 struct dhcp_opt {
@@ -663,30 +648,21 @@ static void dhcp_reset_env(void)
 	}
 }
 
-static void dhcp_global_add(const char *var)
-{
-	char * var_global = asprintf("dhcp.%s", var);
-
-	if (!var_global)
-		return;
-
-	globalvar_add_simple(var_global);
-	free(var_global);
-}
-
 static int dhcp_global_init(void)
 {
 	struct dhcp_opt *opt;
 	struct dhcp_param *param;
 	int i;
 
+	dhcp_dev = global_add_device("dhcp");
+
 	for (i = 0; i < ARRAY_SIZE(dhcp_options); i++) {
 		opt = &dhcp_options[i];
 
 		if (!opt->barebox_dhcp_global)
 			continue;
 
-		dhcp_global_add(opt->barebox_dhcp_global);
+		global_add_simple(dhcp_dev, opt->barebox_dhcp_global);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(dhcp_params); i++) {
@@ -695,7 +671,7 @@ static int dhcp_global_init(void)
 		if (!param->barebox_dhcp_global)
 			continue;
 
-		dhcp_global_add(param->barebox_dhcp_global);
+		global_add_simple(dhcp_dev, param->barebox_dhcp_global);
 	}
 
 	return 0;
@@ -719,7 +695,7 @@ static int do_dhcp(int argc, char *argv[])
 
 	dhcp_reset_env();
 
-	dhcp_getenv_int("global.dhcp.retries", &retries);
+	dhcp_getenv_int("dhcp.retries", &retries);
 
 	while((opt = getopt(argc, argv, "H:v:c:u:U:r:")) > 0) {
 		switch(opt) {
@@ -826,12 +802,12 @@ BAREBOX_CMD_START(dhcp)
 BAREBOX_CMD_END
 
 BAREBOX_MAGICVAR_NAMED(global_hostname, global.hostname, "hostname to send or returned from DHCP request");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_bootfile, global.dhcp.bootfile, "bootfile returned from DHCP request");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_rootpath, global.dhcp.rootpath, "rootpath returned from DHCP request");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_vendor_id, global.dhcp.vendor_id, "vendor id to send to the DHCP server");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_client_uuid, global.dhcp.client_uuid, "cliend uuid to send to the DHCP server");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_client_id, global.dhcp.client_id, "cliend id to send to the DHCP server");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_user_class, global.dhcp.user_class, "user class to send to the DHCP server");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_tftp_server_name, global.dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_oftree_file, global.dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
-BAREBOX_MAGICVAR_NAMED(global_dhcp_retries, global.dhcp.retries, "retry limit");
+BAREBOX_MAGICVAR_NAMED(dhcp_bootfile, dhcp.bootfile, "bootfile returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(dhcp_rootpath, dhcp.rootpath, "rootpath returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(dhcp_vendor_id, dhcp.vendor_id, "vendor id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(dhcp_client_uuid, dhcp.client_uuid, "cliend uuid to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(dhcp_client_id, dhcp.client_id, "cliend id to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(dhcp_user_class, dhcp.user_class, "user class to send to the DHCP server");
+BAREBOX_MAGICVAR_NAMED(dhcp_tftp_server_name, dhcp.tftp_server_name, "TFTP server Name returned from DHCP request");
+BAREBOX_MAGICVAR_NAMED(dhcp_oftree_file, dhcp.oftree_file, "OF tree returned from DHCP request (option 224)");
+BAREBOX_MAGICVAR_NAMED(dhcp_retries, dhcp.retries, "retry limit");
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/5] bootm: switch globalvar to it's own device
  2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 preceding siblings ...)
  2012-09-24 15:40   ` [PATCH 4/5] dhcp: switch globalvar to it's own device Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-24 15:40   ` Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-24 15:40 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 .../boards/crystalfontz-cfa10036/env/boot/mmc-ext3 |    4 ++--
 arch/arm/boards/pcm038/env/boot/nand-ubi           |    4 ++--
 commands/bootm.c                                   |   24 ++++++++++++--------
 defaultenv-2/base/boot/initrd                      |    6 ++---
 defaultenv-2/base/boot/net                         |    4 ++--
 defaultenv-2/base/data/boot-template               |    6 ++---
 6 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
index 7d7eb50..163c2fe 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
@@ -5,6 +5,6 @@ if [ "$1" = menu ]; then
 	exit
 fi
 
-global.bootm.image="/mnt/disk0.1/zImage-cfa10036"
-global.bootm.oftree="/mnt/disk0.1/oftree-cfa10036"
+bootm.image="/mnt/disk0.1/zImage-cfa10036"
+bootm.oftree="/mnt/disk0.1/oftree-cfa10036"
 bootargs-root-ext -r 3 -m mmcblk0p3
diff --git a/arch/arm/boards/pcm038/env/boot/nand-ubi b/arch/arm/boards/pcm038/env/boot/nand-ubi
index a3f748e..81a4397 100644
--- a/arch/arm/boards/pcm038/env/boot/nand-ubi
+++ b/arch/arm/boards/pcm038/env/boot/nand-ubi
@@ -5,6 +5,6 @@ if [ "$1" = menu ]; then
 	exit
 fi
 
-global.bootm.image="/dev/nand0.kernel.bb"
-#global.bootm.oftree="/env/oftree"
+bootm.image="/dev/nand0.kernel.bb"
+#bootm.oftree="/env/oftree"
 bootargs-root-ubi -r root -m nand0.root
diff --git a/commands/bootm.c b/commands/bootm.c
index 8e51695..c0180d4 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -48,6 +48,12 @@
 #include <asm-generic/memory_layout.h>
 
 static LIST_HEAD(handler_list);
+static device_d *bootm_dev;
+
+static const char* bootm_get_global(const char * var)
+{
+	return dev_get_param(bootm_dev, var);
+}
 
 int register_image_handler(struct image_handler *handler)
 {
@@ -267,10 +273,10 @@ static int do_bootm(int argc, char *argv[])
 	data.verify = 0;
 	data.verbose = 0;
 
-	oftree = getenv("global.bootm.oftree");
-	os_file = getenv("global.bootm.image");
+	oftree = bootm_get_global("oftree");
+	os_file = bootm_get_global("image");
 	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
-		initrd_file = getenv("global.bootm.initrd");
+		initrd_file = bootm_get_global("initrd");
 
 	while ((opt = getopt(argc, argv, BOOTM_OPTS)) > 0) {
 		switch(opt) {
@@ -440,11 +446,11 @@ err_out:
 
 static int bootm_init(void)
 {
-
-	globalvar_add_simple("bootm.image");
-	globalvar_add_simple("bootm.oftree");
+	bootm_dev = global_add_device("bootm");
+	global_add_simple(bootm_dev, "image");
+	global_add_simple(bootm_dev, "oftree");
 	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
-		globalvar_add_simple("bootm.initrd");
+		global_add_simple(bootm_dev, "initrd");
 
 	return 0;
 }
@@ -475,8 +481,8 @@ BAREBOX_CMD_START(bootm)
 BAREBOX_CMD_END
 
 BAREBOX_MAGICVAR(bootargs, "Linux Kernel parameters");
-BAREBOX_MAGICVAR_NAMED(global_bootm_image, global.bootm.image, "bootm default boot image");
-BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, "bootm default initrd");
+BAREBOX_MAGICVAR_NAMED(bootm_image, bootm.image, "bootm default boot image");
+BAREBOX_MAGICVAR_NAMED(bootm_initrd, bootm.initrd, "bootm default initrd");
 
 static struct binfmt_hook binfmt_uimage_hook = {
 	.type = filetype_uimage,
diff --git a/defaultenv-2/base/boot/initrd b/defaultenv-2/base/boot/initrd
index 7c44d07..6bfc11c 100644
--- a/defaultenv-2/base/boot/initrd
+++ b/defaultenv-2/base/boot/initrd
@@ -6,10 +6,10 @@ if [ "$1" = menu ]; then
 fi
 
 path="/mnt/tftp"
-global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
-global.bootm.initrd="${path}/initramfs"
+bootm.image="${path}/${global.user}-linux-${global.hostname}"
+bootm.initrd="${path}/initramfs"
 bootargs-root-initrd
-#global.bootm.oftree=<path to oftree>
+#bootm.oftree=<path to oftree>
 
 global.linux.bootargs.dyn.root="root=/dev/ram0"
 
diff --git a/defaultenv-2/base/boot/net b/defaultenv-2/base/boot/net
index 922bef1..5cc9823 100644
--- a/defaultenv-2/base/boot/net
+++ b/defaultenv-2/base/boot/net
@@ -7,8 +7,8 @@ fi
 
 path="/mnt/tftp"
 
-global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
-#global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}"
+bootm.image="${path}/${global.user}-linux-${global.hostname}"
+#bootm.oftree="${path}/${global.user}-oftree-${global.hostname}"
 nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
 bootargs-ip
 bootargs-root-nfs -n "$nfsroot"
diff --git a/defaultenv-2/base/data/boot-template b/defaultenv-2/base/data/boot-template
index 1cacf18..d57c852 100644
--- a/defaultenv-2/base/data/boot-template
+++ b/defaultenv-2/base/data/boot-template
@@ -5,9 +5,9 @@ if [ "$1" = menu ]; then
 	exit
 fi
 
-global.bootm.image=<path to image>
-#global.bootm.oftree=<path to oftree>
-#global.bootm.initrd=<path to initrd>
+bootm.image=<path to image>
+#bootm.oftree=<path to oftree>
+#bootm.initrd=<path to initrd>
 
 #bootargs-ip
 
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-24 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-24 15:27 [RFC PATCH 0/5] switch globalvar to it's own bus Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 15:40 ` [PATCH 1/5] globalvar: add " Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 15:40   ` [PATCH 2/5] globalvar: allow to register multiple device Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 15:40   ` [PATCH 3/5] net: switch to global device Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 15:40   ` [PATCH 4/5] dhcp: switch globalvar to it's own device Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 15:40   ` [PATCH 5/5] bootm: " Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox