lkml.org 
[lkml]   [2009]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/4] kconfig: streamline_config.pl: add handling for "if" statements in Kconfig
Date
I found that certain modules e.g. snd_hda_intel were not being enabled
by "make localmodconfig". stream_config.pl was unaware of the
dependencies implied by the "if" statements which surround many configs.

1) Maintain a global stack of the dependencies implied by "if" statements
These dependencies can then added to each config symbol as it is
created.

2) Refactor read_kconfig() to use more immediate recursion
This is necessary to ensure correct handling of "source" statements
which are nested within "if" statements.

* Declare $_ as a local variable, so that it is not clobbered by
recursive calls to read_kconfig().

* Similarly, we change the global file handle KIN to an indirect file
handle $kin, which we can then declare as a local variable.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
---
scripts/kconfig/streamline_config.pl | 37 ++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 7a7bcf7..f5b44c1 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -128,30 +128,45 @@ my $kconfig = $ARGV[0];
# prevent recursion
my %read_kconfigs;

+# stack of dependencies implied by "if" statements
+my @if_deps;
+
sub read_kconfig {
my ($kconfig) = @_;

my $state = "NONE";
my $config;
- my @kconfigs;
+ my $kin;
+ my $_;

- open(KIN, $kconfig) || (
+ open($kin, $kconfig) || (
$kconfig =~ "^[^/]" &&
- open(KIN, $srctree . "/" . $kconfig)
+ open($kin, $srctree . "/" . $kconfig)
) || die "Can't open $kconfig";

- while (<KIN>) {
+ while (<$kin>) {
chomp;

- # collect any Kconfig sources
+ # collect the conditions of "if" statements
+ if (/^if\s+(\S+)\s*$/) {
+ push(@if_deps, $1);
+ } elsif (/^endif/) {
+ pop(@if_deps);
+ }
+
+ # read in any Kconfig sources
if (/^source\s*"(.*)"/) {
- $kconfigs[$#kconfigs+1] = $1;
+ if (!defined($read_kconfigs{$1})) {
+ $read_kconfigs{$1} = 1;
+ read_kconfig($1);
+ }
}

# configs found
if (/^\s*config\s+(\S+)\s*$/) {
$state = "NEW";
$config = $1;
+ $depends{$config} = join(" ", @if_deps);

# collect the depends for the config
} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
@@ -178,15 +193,7 @@ sub read_kconfig {
$state = "NONE";
}
}
- close(KIN);
-
- # read in any configs that were found.
- foreach $kconfig (@kconfigs) {
- if (!defined($read_kconfigs{$kconfig})) {
- $read_kconfigs{$kconfig} = 1;
- read_kconfig($kconfig);
- }
- }
+ close($kin);
}

if ($kconfig) {
--
1.6.3.3


\
 
 \ /
  Last update: 2009-11-20 16:53    [W:0.078 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site