kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on
RFC PATCH 1/1 kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on
The defconfig and Kconfig combination below, which is based on 3.10-rc4 Kconfigs, resulted in several options getting set to "m" instead of "y".
defconfig:
---CONFIG_MODULES=yCONFIG_USB_GADGET=yCONFIG_USB_ZERO=y
---
Kconfig:
---
menuconfig MODULES
bool "Enable loadable module support"
config CONFIGFS_FS
tristate "Userspace-driven configuration filesystem"
config OCFS2_FS
tristate "OCFS2 file system support"
depends on CONFIGFS_FS
select CRC32
config USB_LIBCOMPOSITE
tristate
select CONFIGFS_FS
choice
tristate "USB Gadget Drivers"
default USB_ETH
config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE
config USB_ETH
tristate "Ethernet Gadget (with CDC Ethernet support)" select USB_LIBCOMPOSITE
endchoice
config CRC32
tristate "CRC32/CRC32c functions"
default y
choice
prompt "CRC32 implementation"
depends on CRC32
default CRC32_SLICEBY8
config CRC32_SLICEBY8
bool "Slice by 8 bytes"
endchoice
---
--- scripts/kconfig/confdata.c | 14 ++++++++++---- scripts/kconfig/expr.h | 3 +++ scripts/kconfig/lkc.h | 1 + scripts/kconfig/symbol.c | 11 +++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-)
scripts/kconfig/confdata.c +10 -4
@@ -1083,7 +1083,7 @@ static void randomize_choice_values(struct symbol *csym) csym->flags &= ~(SYMBOL_VALID ); } -static void set_all_choice_values (struct symbol *csym) +void set_all_choice_values (struct symbol *csym) {struct property *prop;struct symbol *sym;
@@ -1100,7 +1100,7 @@ static void set_all_choice_values(struct symbol *csym) } csym->flags |=SYMBOL_DEF_USER ;/* clear VALID to get value calculated */ - csym->flags &= ~(SYMBOL_VALID ); + csym->flags &= ~(SYMBOL_VALID |SYMBOL_NEED_SET_CHOICE_VALUES ); }void conf_set_all_new_symbols (enum conf_def_mode mode)
@@ -1202,6 +1202,14 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)* selected in a choice block and we set it to yes, * and the rest to no. */ +if (mode != def_random) { + for_all_symbols(i, csym) { +if ((sym_is_choice (csym) && !sym_has_value (csym)) || +sym_is_choice_value (csym)) + csym->flags |=SYMBOL_NEED_SET_CHOICE_VALUES ; + } + } + for_all_symbols(i, csym) {if (sym_has_value (csym) || !sym_is_choice (csym))continue ;
@@ -1209,7 +1217,5 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)sym_calc_value (csym);if (mode == def_random)randomize_choice_values (csym); -else -set_all_choice_values (csym); } }
scripts/kconfig/expr.h +3 -0
@@ -106,6 +106,9 @@ struct symbol {#define SYMBOL_DEF3 0x40000/* symbol.def[S_DEF_3] is valid */ #define SYMBOL_DEF4 0x80000/* symbol.def[S_DEF_4] is valid */ +/* choice values need to be set before calculating this symbol value */ +#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 +#define SYMBOL_MAXLENGTH 256#define SYMBOL_HASHSIZE 9973
scripts/kconfig/lkc.h +1 -0
@@ -87,6 +87,7 @@ 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); +void set_all_choice_values (struct symbol *csym);struct conf_printer {void (*print_symbol)(FILE *,struct symbol *,const char *,void *);
scripts/kconfig/symbol.c +11 -0
@@ -300,6 +300,14 @@ void sym_calc_value(struct symbol *sym)if (sym->flags &SYMBOL_VALID )return ; + +if (sym_is_choice_value (sym) && + sym->flags &SYMBOL_NEED_SET_CHOICE_VALUES ) { + sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES ; + prop =sym_get_choice_prop (sym); +sym_calc_value (prop_get_symbol (prop)); + } + sym->flags |=SYMBOL_VALID ; oldval = sym->curr;
@@ -425,6 +433,9 @@ void sym_calc_value(struct symbol *sym)if (sym->flags &SYMBOL_AUTO ) sym->flags &= ~SYMBOL_WRITE ; + +if (sym->flags &SYMBOL_NEED_SET_CHOICE_VALUES ) +set_all_choice_values (sym); }void sym_clear_all_valid (void )
Signature · 1 line
1.8.3
Arve, All,
On 2013-06-06 20:37 -0700, Arve Hjønnevåg spake thusly:
Quoted 2 lines
The defconfig and
Kconfigcombination below, which is based on 3.10-rc4 Kconfigs, resulted in several options getting set to "m" instead of "y".
OK, I was able to reproduce your test-case, and the fix seems reasonable.
I'm just back from a week-end no-internet-access break, so I'll look at it more thoroughly tomorrow.
Thank you!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
Arve, All,
On 2013-06-06 20:37 -0700, Arve Hjønnevåg spake thusly:
Quoted 2 lines
The defconfig and
Kconfigcombination below, which is based on 3.10-rc4 Kconfigs, resulted in several options getting set to "m" instead of "y".
[--SNIP--]
Quoted 1 line
Signed-off-by Arve Hjønnevåg <[email protected]>
I've taken this in my tree, and will push to Michal for the next merge window:
https://www.gitorious.org/linux-kconfig/linux-kconfig/ yem-kconfig-for-next
Thank you!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'