switch globalvar to it's own bus
Subsystems (3)
cover switch globalvar to it's own bus
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/5 net: switch to global device
In reply to Jean-Christophe PLAGNIOL-VILLARD--- net/net.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
net/net.c +7 -8
@@ -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 ; }
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/5 globalvar: add it's own bus
In reply to Jean-Christophe PLAGNIOL-VILLARD--- common/globalvar.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
common/globalvar.c +13 -0
@@ -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 ;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/5 globalvar: allow to register multiple device
--- common/globalvar.c | 77 +++++++++++++++++++++++++++++++++++++++------------ include/globalvar.h | 26 +++++++++++++++++ 2 files changed, 85 insertions(+), 18 deletions(-)
common/globalvar.c +59 -18
@@ -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);
include/globalvar.h +26 -0
@@ -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 */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/5 bootm: switch globalvar to it's own device
In reply to Jean-Christophe PLAGNIOL-VILLARD--- .../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(-)
arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 +2 -2
@@ -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
arch/arm/boards/pcm038/env/boot/nand-ubi +2 -2
@@ -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
commands/bootm.c +15 -9
@@ -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,
defaultenv-2/base/boot/initrd +3 -3
@@ -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"
defaultenv-2/base/boot/net +2 -2
@@ -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"
defaultenv-2/base/data/boot-template +3 -3
@@ -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
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/5 dhcp: switch globalvar to it's own device
In reply to Jean-Christophe PLAGNIOL-VILLARD--- 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(-)
arch/arm/boards/at91rm9200ek/env/config +1 -1
@@ -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
arch/arm/boards/at91sam9260ek/env/config +2 -2
@@ -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
arch/arm/boards/at91sam9261ek/env/config +2 -2
@@ -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
arch/arm/boards/at91sam9263ek/env/config +1 -1
@@ -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
arch/arm/boards/at91sam9m10g45ek/env/config +1 -1
@@ -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
arch/arm/boards/at91sam9x5ek/env/config +1 -1
@@ -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
arch/arm/boards/freescale-mx53-loco/env/config +1 -1
@@ -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
arch/arm/boards/qil-a9260/env/config +1 -1
@@ -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
arch/arm/boards/tny-a926x/env/config +3 -3
@@ -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
arch/arm/boards/usb-a926x/env/config +3 -3
@@ -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
defaultenv-2/base/network/eth0 +1 -1
@@ -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=
defaultenv/bin/boot +6 -6
@@ -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
defaultenv/config +1 -1
@@ -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
net/dhcp.c +17 -41
104 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox