kconfig - hex are considered decimal
Subsystems (6)
Hi Roman.
I was applying an old patch from you that introduces conf_set_all_new_symbols().
But when I tested it I noticed that all symbols of type "hex" were saved as decimal vlaues in .config.
Sample (first line is with unmodifed kconfig):
-CONFIG_RADIO_ZOLTRIX_PORT=0x20c
+CONFIG_RADIO_ZOLTRIX_PORT=20c
I guess this has something to do with the way we represent a hex value internally. But I have not yet dived into it.
Can you see where it goes wrong?
I have attached two patches.
The first is the one from you and the second is the one where I started to use the new function.
Sam
From 23a6db63846ef5658fd2e036064f03b98ea0ecec Mon Sep 17 00:00:00 2001
From: Roman Zippel <[email protected]>
Date: Tue, 6 May 2008 04:55:55 +0200
Subject: [PATCH] kconfig: set all new symbols automatically
Add conf_set_all_new_symbols() which set all symbols (which don't have a value yet) to a specifed value.
--- scripts/kconfig/confdata.c | 70 ++++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc.h | 9 +++++ 2 files changed, 79 insertions(+), 0 deletions(-)
scripts/kconfig/confdata.c +70 -0
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void)) { conf_changed_callback = fn; } + + +void conf_set_all_new_symbols (enum conf_def_mode mode) +{ +struct symbol *sym, *csym; +struct property *prop; +struct expr *e; +int i, cnt, def; + + for_all_symbols(i, sym) { +if (sym_has_value (sym)) +continue ; +switch (sym_get_type (sym)) { +case S_BOOLEAN : +case S_TRISTATE : +switch (mode) { +case def_yes: + sym->def[S_DEF_USER ].tri = yes; +break ; +case def_mod: + sym->def[S_DEF_USER ].tri = mod; +break ; +case def_no: + sym->def[S_DEF_USER ].tri = no; +break ; +case def_random: + sym->def[S_DEF_USER ].tri = (tristate)(rand () %3 ); +break ; +default : +continue ; + } +if (!sym_is_choice (sym) || mode != def_random) + sym->flags |=SYMBOL_DEF_USER ; +break ; +default : +break ; + } + + } + +if (modules_sym) +sym_calc_value (modules_sym); + +if (mode != def_random) +return ; + + for_all_symbols(i, csym) { +if (sym_has_value (csym) || !sym_is_choice (csym)) +continue ; + +sym_calc_value (csym); + prop =sym_get_choice_prop (csym); + def =-1 ; +while (1 ) { + cnt =0 ; +expr_list_for_each_sym (prop->expr, e, sym) { +if (sym->visible == no) +continue ; +if (def == cnt++) { + csym->def[S_DEF_USER ].val = sym; +break ; + } + } +if (def >=0 || cnt <2 ) +break ; + def = (rand () % cnt) +1 ; + } + csym->flags |=SYMBOL_DEF_USER ; + } +}
scripts/kconfig/lkc.h +9 -0
@@ -42,6 +42,14 @@ extern "C" {#define TF_PARAM 0x0002#define TF_OPTION 0x0004 +enum conf_def_mode { + def_default, + def_yes, + def_mod, + def_no, + def_random +}; +#define T_OPT_MODULES 1#define T_OPT_DEFCONFIG_LIST 2#define T_OPT_ENV 3
@@ -69,6 +77,7 @@ const char *conf_get_configname(void);char *conf_get_default_confname (void );void sym_set_change_count (int count);void sym_add_change_count (int count); +void conf_set_all_new_symbols (enum conf_def_mode mode);/* kconfig_load.c */ void kconfig_load (void );
Signature · 1 line
1.5.4.1.143.ge7e51
scripts/kconfig/conf.c +68 -86
200 lines not on this page · raw message
Quoted 13 lines · Sam Ravnborg
Hi Roman.
I was applying an old patch from you that introduces
conf_set_all_new_symbols().But when I tested it I noticed that all symbols of type "hex" were saved as decimal vlaues in .config.
Sample (first line is with unmodifed kconfig):
(quoted diff) +1
-1-CONFIG_RADIO_ZOLTRIX_PORT=0x20c +CONFIG_RADIO_ZOLTRIX_PORT=20c
Quoted 5 lines
I guess this has something to do with the way we represent a hex value internally. But I have not yet dived into it.
Can you see where it goes wrong?
This seems to be the right fix.
Sam
scripts/kconfig/confdata.c +1 -1
@@ -510,7 +510,7 @@ int conf_write(const char *name)case S_HEX : str =sym_get_string_value (sym);if (str[0 ] !='0' || (str[1 ] !='x' && str[1 ] !='X' )) { -fprintf (out,"CONFIG_%s=%s\n" , sym->name, str); +fprintf (out,"CONFIG_%s=0x%s\n" , sym->name, str);break ; }case S_INT :
Hi,
Quoted 10 lines · Sam Ravnborg
Sample (first line is with unmodifed kconfig):
(quoted diff) +1
-1-CONFIG_RADIO_ZOLTRIX_PORT=0x20c +CONFIG_RADIO_ZOLTRIX_PORT=20cI guess this has something to do with the way we represent a hex value internally. But I have not yet dived into it.
Can you see where it goes wrong?
It's not really wrong, it's a valid value there. Only if it's saved like this in the header file, it would be wrong.
I noticed that during testing too, that value is coming liking that directly from the Kconfig file. The real fix would be to deprecate hex values without prefix and automatically adding the prefix where needed (currently loading of Kconfig/.config).
I though about making it more consistent, but it's not really a pressing issue, so I left it as is for now.
bye, Roman
Quoted 13 lines · Roman Zippel
Hi,
Quoted 9 lines · Sam Ravnborg
Sample (first line is with unmodifed kconfig):
(quoted diff) +1
-1-CONFIG_RADIO_ZOLTRIX_PORT=0x20c +CONFIG_RADIO_ZOLTRIX_PORT=20cI guess this has something to do with the way we represent a hex value internally. But I have not yet dived into it.
Quoted 10 lines
Quoted 1 line
Can you see where it goes wrong?
It's not really wrong, it's a valid value there. Only if it's saved like this in the header file, it would be wrong.
I noticed that during testing too, that value is coming liking that directly from theKconfigfile. The real fix would be to deprecate hex values without prefix and automatically adding the prefix where needed (currently loading of Kconfig/.config).
I though about making it more consistent, but it's not really a pressing issue, so I left it as is for now.
For now I added this patch (for previous mail). This makes the configs equal so they can be compared.
Sam
scripts/kconfig/confdata.c +1 -1
@@ -510,7 +510,7 @@ int conf_write(const char *name)case S_HEX : str =sym_get_string_value (sym);if (str[0 ] !='0' || (str[1 ] !='x' && str[1 ] !='X' )) { -fprintf (out,"CONFIG_%s=%s\n" , sym->name, str); +fprintf (out,"CONFIG_%s=0x%s\n" , sym->name, str);break ; }case S_INT :
Hi,
Quoted 2 lines · Sam Ravnborg
For now I added this patch (for previous mail). This makes the configs equal so they can be compared.
Did you try changing and saving that hex value?
You need a similiar logic as used for saving the header file. Why is it a problem, that needs immediate fixing anyway?
bye, Roman
Quoted 8 lines · Roman Zippel
Hi,
Quoted 2 lines · Sam Ravnborg
For now I added this patch (for previous mail). This makes the configs equal so they can be compared.
Did you try changing and saving that hex value?
Yes.
- When changing I see the 0x prefix - which I consider OK for hex values
- When saving I see the 0x prefix in autoconf.h + .config
Quoted 2 lines
You need a similiar logic as used for saving the header file. Why is it a problem, that needs immediate fixing anyway?
To keep difference minimal for .config produced by old style 'all*config' and new style 'all*config'.
See patches where kconfig start to use the new method for 'all*config' targets - they are cc:ed to you and available on linux-kbuild.
I simply started to use conf_set_all_new_symbols() and as a result I could simplify conf.c.
And things got so simple that I dropped the patches introducing aconf.c.
Yet TODO:
-> Give Redhat's nonint_oldconfig a closer look and see
how to integrate this functionality
-> Give Andres Salomon patches a second look and see how to
integrate the functionality he requires
It it does not turn out to be simple I will lilely postpone it until I have moved.
Sam
Hi,
Quoted 2 lines · Sam Ravnborg
- When changing I see the 0x prefix - which I consider OK for hex values
- When saving I see the 0x prefix inautoconf.h+ .config
I disagree with the proposed patch. It only makes cosmetical changes, but it doesn't fix the current inconsistenties. Either we do it properly as in the patch below or I'd rather keep it as is.
The patch checks the default values more strictly, I'm open to opinions whether that warning is useful or maybe just check that hex values have the 0x prefix.
Quoted 8 lines
See patches where kconfig start to use the new method for 'all*config' targets - they are cc:ed to you and available on linux-kbuild.
I simply started to useconf_set_all_new_symbols()and as a result I could simplifyconf.c.And things got so simple that I dropped the patches introducing
aconf.c.
I'd actually prefer to move everything noninteractive out of conf.c, as this would be the right place for this:
Quoted 2 lines
-> Give Redhat's
nonint_oldconfiga closer look and see
how to integrate this functionality
This should be pretty much do it:
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (sym->flags & SYMBOL_WRITE && !sym_has_value(sym))
printf(...);
}The point is that this has nothing to do with what's already in conf.c, this should be a separate utility for all noninteractive kconfig jobs.
bye, Roman
[PATCH] normalize int/hex values
Introduce a new strdup_type() which normalizes the input value, so that all symbol values are properly formatted.
Check the values of defaults a bit more careful, so that their are either proper constants or other symbols of the same type.
--- arch/x86/Kconfig | 4 ++-- drivers/media/radio/Kconfig | 16 ++++++++-------- drivers/mtd/devices/Kconfig | 3 +-- drivers/mtd/maps/Kconfig | 2 +- scripts/kconfig/confdata.c | 2 +- scripts/kconfig/lkc.h | 2 ++ scripts/kconfig/menu.c | 41 ++++++++++++++++++++++++++++++++++++----- scripts/kconfig/util.c | 16 ++++++++++++++++ sound/oss/Kconfig | 10 +++++----- 9 files changed, 72 insertions(+), 24 deletions(-)
scripts/kconfig/confdata.c +1 -1
@@ -132,7 +132,7 @@ static int conf_set_sym_val(struct symbocase S_HEX : done:if (sym_string_valid (sym, p)) { - sym->def[def].val =strdup (p); + sym->def[def].val =strdup_type (p, sym->type); sym->flags |= def_flags; }else {conf_warning ("symbol value '%s' invalid for %s" , p, sym->name);
scripts/kconfig/lkc.h +2 -0
@@ -113,6 +113,8 @@ void str_append(struct gstr *gs, const cvoid str_printf (struct gstr *gs,const char *fmt, ...);const char *str_get (struct gstr *gs); +char *strdup_type (const char *str,int type); +/* symbol.c */ extern struct expr *sym_env_list;
scripts/kconfig/menu.c +36 -5
51 lines not on this page · raw message
scripts/kconfig/util.c +16 -0
@@ -131,3 +131,19 @@ const char *str_get(struct gstr *gs)return gs->s; } +/* duplicate str, but normalize any number according to the symbol type */ +char *strdup_type (const char *str,int type) +{ +char buf[64 ]; + +if (type ==S_STRING ) +return strdup (str); +if (type ==S_HEX ) { +unsigned int val =strtoul (str,NULL ,16 ); +sprintf (buf,"%#x" , val); + }else { +int val =strtol (str,NULL ,10 ); +sprintf (buf,"%d" , val); + } +return strdup (buf); +}
arch/x86/Kconfig +2 -2
@@ -885,11 +885,11 @@ endchoice config PAGE_OFFSET hex - default 0xB0000000 if VMSPLIT_3G_OPT + default 0xb0000000 if VMSPLIT_3G_OPT default 0x80000000 if VMSPLIT_2G default 0x78000000 if VMSPLIT_2G_OPT default 0x40000000 if VMSPLIT_1G - default 0xC0000000 + default 0xc0000000 depends on X86_32 config HIGHMEM
drivers/media/radio/Kconfig +8 -8
@@ -58,7 +58,7 @@ config RADIO_RTRACK config RADIO_RTRACK_PORT hex "RadioTrack i/o port (0x20f or 0x30f)" depends on RADIO_RTRACK=y - default "20f" + default "0x20f" help Enter either 0x30f or 0x20f here. The card default is 0x30f, if you haven't changed the jumper setting on the card.
@@ -81,7 +81,7 @@ config RADIO_RTRACK2 config RADIO_RTRACK2_PORT hex "RadioTrack II i/o port (0x20c or 0x30c)" depends on RADIO_RTRACK2=y - default "30c" + default "0x30c" help Enter either 0x30c or 0x20c here. The card default is 0x30c, if you haven't changed the jumper setting on the card.
@@ -104,7 +104,7 @@ config RADIO_AZTECH config RADIO_AZTECH_PORT hex "Aztech/Packard Bell I/O port (0x350 or 0x358)" depends on RADIO_AZTECH=y - default "350" + default "0x350" help Enter either 0x350 or 0x358 here. The card default is 0x350, if you haven't changed the setting of jumper JP3 on the card. Removing the
@@ -133,7 +133,7 @@ config RADIO_GEMTEK config RADIO_GEMTEK_PORT hex "Fixed I/O port (0x20c, 0x30c, 0x24c, 0x34c, 0c24c or 0x28c)" depends on RADIO_GEMTEK=y - default "34c" + default "0x34c" help Enter either 0x20c, 0x30c, 0x24c or 0x34c here. The card default is 0x34c, if you haven't changed the jumper setting on the card. On
@@ -250,7 +250,7 @@ config RADIO_TERRATEC config RADIO_TERRATEC_PORT hex "Terratec i/o port (normally 0x590)" depends on RADIO_TERRATEC=y - default "590" + default "0x590" help Fill in the I/O port of your TerraTec FM radio card. If unsure, go with the default.
@@ -268,7 +268,7 @@ config RADIO_TRUST config RADIO_TRUST_PORT hex "Trust i/o port (usually 0x350 or 0x358)" depends on RADIO_TRUST=y - default "350" + default "0x350" help Enter the I/O port of your Trust FM radio card. If unsure, try the values "0x350" or "0x358".
@@ -301,7 +301,7 @@ config RADIO_TYPHOON_PROC_FS config RADIO_TYPHOON_PORT hex "Typhoon I/O port (0x316 or 0x336)" depends on RADIO_TYPHOON=y - default "316" + default "0x316" help Enter the I/O port of your Typhoon or EcoRadio radio card.
@@ -335,7 +335,7 @@ config RADIO_ZOLTRIX config RADIO_ZOLTRIX_PORT hex "ZOLTRIX I/O port (0x20c or 0x30c)" depends on RADIO_ZOLTRIX=y - default "20c" + default "0x20c" help Enter the I/O port of your Zoltrix radio card.
drivers/mtd/devices/Kconfig +1 -2
@@ -240,8 +240,7 @@ config MTD_DOCPROBE_ADVANCED config MTD_DOCPROBE_ADDRESS hex "Physical address of DiskOnChip" if MTD_DOCPROBE_ADVANCED depends on MTD_DOCPROBE - default "0x0000" if MTD_DOCPROBE_ADVANCED - default "0" if !MTD_DOCPROBE_ADVANCED + default "0" ---help--- By default, the probe for DiskOnChip devices will look for a DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
drivers/mtd/maps/Kconfig +1 -1
@@ -92,7 +92,7 @@ endchoice config MSP_FLASH_MAP_LIMIT hex - default "0x02000000" + default "0x2000000" depends on MSP_FLASH_MAP_LIMIT_32M config MTD_PMC_MSP_RAMROOT
sound/oss/Kconfig +5 -5
@@ -129,7 +129,7 @@ config MSNDCLAS_IRQ config MSNDCLAS_MEM hex "MSND Classic memory B0000, C8000, D0000, D8000, E0000, E8000" depends on SOUND_MSNDCLAS=y - default "D0000" + default "0xd0000" help Memory-mapped I/O base address for the MultiSound Classic and related cards.
@@ -137,7 +137,7 @@ config MSNDCLAS_MEM config MSNDCLAS_IO hex "MSND Classic I/O 210, 220, 230, 240, 250, 260, 290, 3E0" depends on SOUND_MSNDCLAS=y - default "290" + default "0x290" help I/O port address for the MultiSound Classic and related cards.
@@ -192,7 +192,7 @@ config MSNDPIN_IRQ config MSNDPIN_MEM hex "MSND Pinnacle memory B0000, C8000, D0000, D8000, E0000, E8000" depends on SOUND_MSNDPIN=y - default "D0000" + default "0xd0000" help Memory-mapped I/O base address for the primary synthesizer on MultiSound Pinnacle and Fiji sound cards.
@@ -200,7 +200,7 @@ config MSNDPIN_MEM config MSNDPIN_IO hex "MSND Pinnacle I/O 210, 220, 230, 240, 250, 260, 290, 3E0" depends on SOUND_MSNDPIN=y - default "290" + default "0x290" help Memory-mapped I/O base address for the primary synthesizer on MultiSound Pinnacle and Fiji sound cards.
@@ -234,7 +234,7 @@ comment "MSND Pinnacle DSP section will config MSNDPIN_CFG hex "MSND Pinnacle config port 250,260,270" depends on MSNDPIN_NONPNP - default "250" + default "0x250" help This is the port which the Pinnacle and Fiji uses to configure the card's resources when not in PnP mode. If your card is in PnP mode,
Quoted 7 lines · Roman Zippel
Hi,
Quoted 2 lines · Sam Ravnborg
- When changing I see the 0x prefix - which I consider OK for hex values
- When saving I see the 0x prefix inautoconf.h+ .config
Quoted 6 lines
I disagree with the proposed patch. It only makes cosmetical changes, but it doesn't fix the current inconsistenties. Either we do it properly as in the patch below or I'd rather keep it as is.
The patch checks the default values more strictly, I'm open to opinions whether that warning is useful or maybe just check that hex values have the 0x prefix.
Thanks - I divided your patch up in two.
First one that adds the new checks
And the second that fixes the warnings
Quoted 18 lines
Quoted 9 lines
See patches where kconfig start to use the new method for 'all*config' targets - they are cc:ed to you and available on linux-kbuild.
I simply started to useconf_set_all_new_symbols()and as a result I could simplifyconf.c.And things got so simple that I dropped the patches introducing
aconf.c.I'd actually prefer to move everything noninteractive out of
conf.c, as this would be the right place for this:Quoted 2 lines
-> Give Redhat's
nonint_oldconfiga closer look and see
how to integrate this functionalityThis should be pretty much do it:
Quoted 8 lines
for_all_symbols(i, sym) { sym_calc_value(sym); if (sym->flags & SYMBOL_WRITE && !sym_has_value(sym)) printf(...); }The point is that this has nothing to do with what's already in
conf.c, this should be a separate utility for all noninteractive kconfig jobs.
I do not disagree with you here. But for now it was just more natural to add it where I deleted the other stuff. I will move it to a separate .c file later.
Sam