Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: introduce choice_set_value() helper

Currently, sym_set_tristate_value() is used to set 'y' to a choice
member, which is confusing because it not only sets 'y' to the given
symbol but also tweaks flags of other symbols as a side effect.

Add a dedicated function for setting the value of the given choice.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+47 -22
+1 -1
scripts/kconfig/conf.c
··· 507 507 print_help(child); 508 508 continue; 509 509 } 510 - sym_set_tristate_value(child->sym, yes); 510 + choice_set_value(menu, child->sym); 511 511 return; 512 512 } 513 513 }
+1
scripts/kconfig/lkc_proto.h
··· 28 28 enum symbol_type sym_get_type(struct symbol *sym); 29 29 bool sym_tristate_within_range(struct symbol *sym,tristate tri); 30 30 bool sym_set_tristate_value(struct symbol *sym,tristate tri); 31 + void choice_set_value(struct menu *choice, struct symbol *sym); 31 32 tristate sym_toggle_tristate_value(struct symbol *sym); 32 33 bool sym_string_valid(struct symbol *sym, const char *newval); 33 34 bool sym_string_within_range(struct symbol *sym, const char *str);
+1 -1
scripts/kconfig/mconf.c
··· 636 636 if (!child->sym) 637 637 break; 638 638 639 - sym_set_tristate_value(child->sym, yes); 639 + choice_set_value(menu, child->sym); 640 640 } 641 641 return; 642 642 case 1:
+1 -1
scripts/kconfig/nconf.c
··· 1331 1331 case ' ': 1332 1332 case 10: 1333 1333 case KEY_RIGHT: 1334 - sym_set_tristate_value(child->sym, yes); 1334 + choice_set_value(menu, child->sym); 1335 1335 return; 1336 1336 case 'h': 1337 1337 case '?':
+43 -19
scripts/kconfig/symbol.c
··· 516 516 return false; 517 517 if (sym->visible <= sym->rev_dep.tri) 518 518 return false; 519 - if (sym_is_choice_value(sym) && sym->visible == yes) 520 - return val == yes; 521 519 return val >= sym->rev_dep.tri && val <= sym->visible; 522 520 } 523 521 ··· 530 532 sym->flags |= SYMBOL_DEF_USER; 531 533 sym_set_changed(sym); 532 534 } 533 - /* 534 - * setting a choice value also resets the new flag of the choice 535 - * symbol and all other choice values. 536 - */ 537 - if (sym_is_choice_value(sym) && val == yes) { 538 - struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); 539 - struct property *prop; 540 - struct expr *e; 541 - 542 - cs->def[S_DEF_USER].val = sym; 543 - cs->flags |= SYMBOL_DEF_USER; 544 - prop = sym_get_choice_prop(cs); 545 - for (e = prop->expr; e; e = e->left.expr) { 546 - if (e->right.sym->visible != no) 547 - e->right.sym->flags |= SYMBOL_DEF_USER; 548 - } 549 - } 550 535 551 536 sym->def[S_DEF_USER].tri = val; 552 537 if (oldval != val) ··· 538 557 return true; 539 558 } 540 559 560 + /** 561 + * choice_set_value - set the user input to a choice 562 + * 563 + * @choice: menu entry for the choice 564 + * @sym: selected symbol 565 + */ 566 + void choice_set_value(struct menu *choice, struct symbol *sym) 567 + { 568 + struct menu *menu; 569 + bool changed = false; 570 + 571 + menu_for_each_sub_entry(menu, choice) { 572 + tristate val; 573 + 574 + if (!menu->sym) 575 + continue; 576 + 577 + if (menu->sym->visible == no) 578 + continue; 579 + 580 + val = menu->sym == sym ? yes : no; 581 + 582 + if (menu->sym->curr.tri != val) 583 + changed = true; 584 + 585 + menu->sym->def[S_DEF_USER].tri = val; 586 + menu->sym->flags |= SYMBOL_DEF_USER; 587 + } 588 + 589 + choice->sym->def[S_DEF_USER].val = sym; 590 + choice->sym->flags |= SYMBOL_DEF_USER; 591 + 592 + if (changed) 593 + sym_clear_all_valid(); 594 + } 595 + 541 596 tristate sym_toggle_tristate_value(struct symbol *sym) 542 597 { 598 + struct menu *choice; 543 599 tristate oldval, newval; 600 + 601 + choice = sym_get_choice_menu(sym); 602 + if (choice) { 603 + choice_set_value(choice, sym); 604 + return yes; 605 + } 544 606 545 607 oldval = newval = sym_get_tristate_value(sym); 546 608 do {