diff options
Diffstat (limited to 'scripts/kconfig/symbol.c')
-rw-r--r-- | scripts/kconfig/symbol.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 0a013ab3ae27..e95718fea355 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -661,6 +661,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) | |||
661 | return true; | 661 | return true; |
662 | } | 662 | } |
663 | 663 | ||
664 | /* | ||
665 | * Find the default value associated to a symbol. | ||
666 | * For tristate symbol handle the modules=n case | ||
667 | * in which case "m" becomes "y". | ||
668 | * If the symbol does not have any default then fallback | ||
669 | * to the fixed default values. | ||
670 | */ | ||
671 | const char *sym_get_string_default(struct symbol *sym) | ||
672 | { | ||
673 | struct property *prop; | ||
674 | struct symbol *ds; | ||
675 | const char *str; | ||
676 | tristate val; | ||
677 | |||
678 | sym_calc_visibility(sym); | ||
679 | sym_calc_value(modules_sym); | ||
680 | val = symbol_no.curr.tri; | ||
681 | str = symbol_empty.curr.val; | ||
682 | |||
683 | /* If symbol has a default value look it up */ | ||
684 | prop = sym_get_default_prop(sym); | ||
685 | if (prop != NULL) { | ||
686 | switch (sym->type) { | ||
687 | case S_BOOLEAN: | ||
688 | case S_TRISTATE: | ||
689 | /* The visibility imay limit the value from yes => mod */ | ||
690 | val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); | ||
691 | break; | ||
692 | default: | ||
693 | /* | ||
694 | * The following fails to handle the situation | ||
695 | * where a default value is further limited by | ||
696 | * the valid range. | ||
697 | */ | ||
698 | ds = prop_get_symbol(prop); | ||
699 | if (ds != NULL) { | ||
700 | sym_calc_value(ds); | ||
701 | str = (const char *)ds->curr.val; | ||
702 | } | ||
703 | } | ||
704 | } | ||
705 | |||
706 | /* Handle select statements */ | ||
707 | val = EXPR_OR(val, sym->rev_dep.tri); | ||
708 | |||
709 | /* transpose mod to yes if modules are not enabled */ | ||
710 | if (val == mod) | ||
711 | if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) | ||
712 | val = yes; | ||
713 | |||
714 | /* transpose mod to yes if type is bool */ | ||
715 | if (sym->type == S_BOOLEAN && val == mod) | ||
716 | val = yes; | ||
717 | |||
718 | switch (sym->type) { | ||
719 | case S_BOOLEAN: | ||
720 | case S_TRISTATE: | ||
721 | switch (val) { | ||
722 | case no: return "n"; | ||
723 | case mod: return "m"; | ||
724 | case yes: return "y"; | ||
725 | } | ||
726 | case S_INT: | ||
727 | case S_HEX: | ||
728 | return str; | ||
729 | case S_STRING: | ||
730 | return str; | ||
731 | case S_OTHER: | ||
732 | case S_UNKNOWN: | ||
733 | break; | ||
734 | } | ||
735 | return ""; | ||
736 | } | ||
737 | |||
664 | const char *sym_get_string_value(struct symbol *sym) | 738 | const char *sym_get_string_value(struct symbol *sym) |
665 | { | 739 | { |
666 | tristate val; | 740 | tristate val; |