aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl287
-rwxr-xr-xscripts/extract-vmlinux62
-rwxr-xr-xscripts/get_maintainer.pl4
-rw-r--r--scripts/kconfig/Makefile33
-rw-r--r--scripts/kconfig/confdata.c49
-rw-r--r--scripts/kconfig/lxdialog/textbox.c3
-rw-r--r--scripts/kconfig/mconf.c86
-rw-r--r--scripts/kconfig/menu.c13
-rw-r--r--scripts/kconfig/nconf.c23
-rw-r--r--scripts/kconfig/nconf.gui.c59
-rw-r--r--scripts/kconfig/nconf.h2
-rw-r--r--scripts/kconfig/streamline_config.pl74
-rw-r--r--scripts/mod/file2alias.c303
-rw-r--r--scripts/mod/modpost.c7
-rw-r--r--scripts/package/Makefile2
-rw-r--r--scripts/recordmcount.h2
-rwxr-xr-xscripts/tags.sh4
17 files changed, 662 insertions, 351 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9d761c95eca2..e3bfcbe8a520 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -227,7 +227,7 @@ our $Inline = qr{inline|__always_inline|noinline};
227our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; 227our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
228our $Lval = qr{$Ident(?:$Member)*}; 228our $Lval = qr{$Ident(?:$Member)*};
229 229
230our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*}; 230our $Constant = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)};
231our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; 231our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
232our $Compare = qr{<=|>=|==|!=|<|>}; 232our $Compare = qr{<=|>=|==|!=|<|>};
233our $Operators = qr{ 233our $Operators = qr{
@@ -240,9 +240,8 @@ our $NonptrType;
240our $Type; 240our $Type;
241our $Declare; 241our $Declare;
242 242
243our $UTF8 = qr { 243our $NON_ASCII_UTF8 = qr{
244 [\x09\x0A\x0D\x20-\x7E] # ASCII 244 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
245 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
246 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs 245 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
247 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte 246 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
248 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates 247 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
@@ -251,6 +250,11 @@ our $UTF8 = qr {
251 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 250 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
252}x; 251}x;
253 252
253our $UTF8 = qr{
254 [\x09\x0A\x0D\x20-\x7E] # ASCII
255 | $NON_ASCII_UTF8
256}x;
257
254our $typeTypedefs = qr{(?x: 258our $typeTypedefs = qr{(?x:
255 (?:__)?(?:u|s|be|le)(?:8|16|32|64)| 259 (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
256 atomic_t 260 atomic_t
@@ -311,7 +315,7 @@ sub build_types {
311 $NonptrType = qr{ 315 $NonptrType = qr{
312 (?:$Modifier\s+|const\s+)* 316 (?:$Modifier\s+|const\s+)*
313 (?: 317 (?:
314 (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| 318 (?:typeof|__typeof__)\s*\([^\)]*\)|
315 (?:$typeTypedefs\b)| 319 (?:$typeTypedefs\b)|
316 (?:${all}\b) 320 (?:${all}\b)
317 ) 321 )
@@ -330,6 +334,7 @@ our $match_balanced_parentheses = qr/(\((?:[^\(\)]+|(-1))*\))/;
330 334
331our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; 335our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
332our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*}; 336our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*};
337our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
333 338
334sub deparenthesize { 339sub deparenthesize {
335 my ($string) = @_; 340 my ($string) = @_;
@@ -672,6 +677,10 @@ sub ctx_statement_block {
672 if ($off >= $len) { 677 if ($off >= $len) {
673 last; 678 last;
674 } 679 }
680 if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) {
681 $level++;
682 $type = '#';
683 }
675 } 684 }
676 $p = $c; 685 $p = $c;
677 $c = substr($blk, $off, 1); 686 $c = substr($blk, $off, 1);
@@ -734,6 +743,13 @@ sub ctx_statement_block {
734 last; 743 last;
735 } 744 }
736 } 745 }
746 # Preprocessor commands end at the newline unless escaped.
747 if ($type eq '#' && $c eq "\n" && $p ne "\\") {
748 $level--;
749 $type = '';
750 $off++;
751 last;
752 }
737 $off++; 753 $off++;
738 } 754 }
739 # We are truly at the end, so shuffle to the next line. 755 # We are truly at the end, so shuffle to the next line.
@@ -1016,7 +1032,7 @@ sub annotate_values {
1016 } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') { 1032 } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
1017 print "CAST($1)\n" if ($dbg_values > 1); 1033 print "CAST($1)\n" if ($dbg_values > 1);
1018 push(@av_paren_type, $type); 1034 push(@av_paren_type, $type);
1019 $type = 'C'; 1035 $type = 'c';
1020 1036
1021 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) { 1037 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
1022 print "DECLARE($1)\n" if ($dbg_values > 1); 1038 print "DECLARE($1)\n" if ($dbg_values > 1);
@@ -1208,7 +1224,9 @@ sub possible {
1208 case| 1224 case|
1209 else| 1225 else|
1210 asm|__asm__| 1226 asm|__asm__|
1211 do 1227 do|
1228 \#|
1229 \#\#|
1212 )(?:\s|$)| 1230 )(?:\s|$)|
1213 ^(?:typedef|struct|enum)\b 1231 ^(?:typedef|struct|enum)\b
1214 )}x; 1232 )}x;
@@ -1330,6 +1348,9 @@ sub process {
1330 my $signoff = 0; 1348 my $signoff = 0;
1331 my $is_patch = 0; 1349 my $is_patch = 0;
1332 1350
1351 my $in_header_lines = 1;
1352 my $in_commit_log = 0; #Scanning lines before patch
1353
1333 our @report = (); 1354 our @report = ();
1334 our $cnt_lines = 0; 1355 our $cnt_lines = 0;
1335 our $cnt_error = 0; 1356 our $cnt_error = 0;
@@ -1352,6 +1373,7 @@ sub process {
1352 my %suppress_ifbraces; 1373 my %suppress_ifbraces;
1353 my %suppress_whiletrailers; 1374 my %suppress_whiletrailers;
1354 my %suppress_export; 1375 my %suppress_export;
1376 my $suppress_statement = 0;
1355 1377
1356 # Pre-scan the patch sanitizing the lines. 1378 # Pre-scan the patch sanitizing the lines.
1357 # Pre-scan the patch looking for any __setup documentation. 1379 # Pre-scan the patch looking for any __setup documentation.
@@ -1461,6 +1483,7 @@ sub process {
1461 %suppress_ifbraces = (); 1483 %suppress_ifbraces = ();
1462 %suppress_whiletrailers = (); 1484 %suppress_whiletrailers = ();
1463 %suppress_export = (); 1485 %suppress_export = ();
1486 $suppress_statement = 0;
1464 next; 1487 next;
1465 1488
1466# track the line number as we move through the hunk, note that 1489# track the line number as we move through the hunk, note that
@@ -1497,10 +1520,11 @@ sub process {
1497 if ($line =~ /^diff --git.*?(\S+)$/) { 1520 if ($line =~ /^diff --git.*?(\S+)$/) {
1498 $realfile = $1; 1521 $realfile = $1;
1499 $realfile =~ s@^([^/]*)/@@; 1522 $realfile =~ s@^([^/]*)/@@;
1500 1523 $in_commit_log = 0;
1501 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1524 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1502 $realfile = $1; 1525 $realfile = $1;
1503 $realfile =~ s@^([^/]*)/@@; 1526 $realfile =~ s@^([^/]*)/@@;
1527 $in_commit_log = 0;
1504 1528
1505 $p1_prefix = $1; 1529 $p1_prefix = $1;
1506 if (!$file && $tree && $p1_prefix ne '' && 1530 if (!$file && $tree && $p1_prefix ne '' &&
@@ -1536,10 +1560,12 @@ sub process {
1536# Check the patch for a signoff: 1560# Check the patch for a signoff:
1537 if ($line =~ /^\s*signed-off-by:/i) { 1561 if ($line =~ /^\s*signed-off-by:/i) {
1538 $signoff++; 1562 $signoff++;
1563 $in_commit_log = 0;
1539 } 1564 }
1540 1565
1541# Check signature styles 1566# Check signature styles
1542 if ($line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { 1567 if (!$in_header_lines &&
1568 $line =~ /^(\s*)($signature_tags)(\s*)(.*)/) {
1543 my $space_before = $1; 1569 my $space_before = $1;
1544 my $sign_off = $2; 1570 my $sign_off = $2;
1545 my $space_after = $3; 1571 my $space_after = $3;
@@ -1613,6 +1639,21 @@ sub process {
1613 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); 1639 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
1614 } 1640 }
1615 1641
1642# Check if it's the start of a commit log
1643# (not a header line and we haven't seen the patch filename)
1644 if ($in_header_lines && $realfile =~ /^$/ &&
1645 $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) {
1646 $in_header_lines = 0;
1647 $in_commit_log = 1;
1648 }
1649
1650# Still not yet in a patch, check for any UTF-8
1651 if ($in_commit_log && $realfile =~ /^$/ &&
1652 $rawline =~ /$NON_ASCII_UTF8/) {
1653 CHK("UTF8_BEFORE_PATCH",
1654 "8-bit UTF-8 used in possible commit log\n" . $herecurr);
1655 }
1656
1616# ignore non-hunk lines and lines being removed 1657# ignore non-hunk lines and lines being removed
1617 next if (!$hunk_line || $line =~ /^-/); 1658 next if (!$hunk_line || $line =~ /^-/);
1618 1659
@@ -1633,19 +1674,26 @@ sub process {
1633# Only applies when adding the entry originally, after that we do not have 1674# Only applies when adding the entry originally, after that we do not have
1634# sufficient context to determine whether it is indeed long enough. 1675# sufficient context to determine whether it is indeed long enough.
1635 if ($realfile =~ /Kconfig/ && 1676 if ($realfile =~ /Kconfig/ &&
1636 $line =~ /\+\s*(?:---)?help(?:---)?$/) { 1677 $line =~ /.\s*config\s+/) {
1637 my $length = 0; 1678 my $length = 0;
1638 my $cnt = $realcnt; 1679 my $cnt = $realcnt;
1639 my $ln = $linenr + 1; 1680 my $ln = $linenr + 1;
1640 my $f; 1681 my $f;
1682 my $is_start = 0;
1641 my $is_end = 0; 1683 my $is_end = 0;
1642 while ($cnt > 0 && defined $lines[$ln - 1]) { 1684 for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
1643 $f = $lines[$ln - 1]; 1685 $f = $lines[$ln - 1];
1644 $cnt-- if ($lines[$ln - 1] !~ /^-/); 1686 $cnt-- if ($lines[$ln - 1] !~ /^-/);
1645 $is_end = $lines[$ln - 1] =~ /^\+/; 1687 $is_end = $lines[$ln - 1] =~ /^\+/;
1646 $ln++;
1647 1688
1648 next if ($f =~ /^-/); 1689 next if ($f =~ /^-/);
1690
1691 if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) {
1692 $is_start = 1;
1693 } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) {
1694 $length = -1;
1695 }
1696
1649 $f =~ s/^.//; 1697 $f =~ s/^.//;
1650 $f =~ s/#.*//; 1698 $f =~ s/#.*//;
1651 $f =~ s/^\s+//; 1699 $f =~ s/^\s+//;
@@ -1657,8 +1705,22 @@ sub process {
1657 $length++; 1705 $length++;
1658 } 1706 }
1659 WARN("CONFIG_DESCRIPTION", 1707 WARN("CONFIG_DESCRIPTION",
1660 "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_end && $length < 4); 1708 "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4);
1661 #print "is_end<$is_end> length<$length>\n"; 1709 #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
1710 }
1711
1712 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
1713 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
1714 my $flag = $1;
1715 my $replacement = {
1716 'EXTRA_AFLAGS' => 'asflags-y',
1717 'EXTRA_CFLAGS' => 'ccflags-y',
1718 'EXTRA_CPPFLAGS' => 'cppflags-y',
1719 'EXTRA_LDFLAGS' => 'ldflags-y',
1720 };
1721
1722 WARN("DEPRECATED_VARIABLE",
1723 "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
1662 } 1724 }
1663 1725
1664# check we are in a valid source file if not then ignore this hunk 1726# check we are in a valid source file if not then ignore this hunk
@@ -1756,12 +1818,24 @@ sub process {
1756# Check for potential 'bare' types 1818# Check for potential 'bare' types
1757 my ($stat, $cond, $line_nr_next, $remain_next, $off_next, 1819 my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
1758 $realline_next); 1820 $realline_next);
1759 if ($realcnt && $line =~ /.\s*\S/) { 1821#print "LINE<$line>\n";
1822 if ($linenr >= $suppress_statement &&
1823 $realcnt && $line =~ /.\s*\S/) {
1760 ($stat, $cond, $line_nr_next, $remain_next, $off_next) = 1824 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1761 ctx_statement_block($linenr, $realcnt, 0); 1825 ctx_statement_block($linenr, $realcnt, 0);
1762 $stat =~ s/\n./\n /g; 1826 $stat =~ s/\n./\n /g;
1763 $cond =~ s/\n./\n /g; 1827 $cond =~ s/\n./\n /g;
1764 1828
1829#print "linenr<$linenr> <$stat>\n";
1830 # If this statement has no statement boundaries within
1831 # it there is no point in retrying a statement scan
1832 # until we hit end of it.
1833 my $frag = $stat; $frag =~ s/;+\s*$//;
1834 if ($frag !~ /(?:{|;)/) {
1835#print "skip<$line_nr_next>\n";
1836 $suppress_statement = $line_nr_next;
1837 }
1838
1765 # Find the real next line. 1839 # Find the real next line.
1766 $realline_next = $line_nr_next; 1840 $realline_next = $line_nr_next;
1767 if (defined $realline_next && 1841 if (defined $realline_next &&
@@ -1887,6 +1961,9 @@ sub process {
1887 1961
1888# Check relative indent for conditionals and blocks. 1962# Check relative indent for conditionals and blocks.
1889 if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { 1963 if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
1964 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1965 ctx_statement_block($linenr, $realcnt, 0)
1966 if (!defined $stat);
1890 my ($s, $c) = ($stat, $cond); 1967 my ($s, $c) = ($stat, $cond);
1891 1968
1892 substr($s, 0, length($c), ''); 1969 substr($s, 0, length($c), '');
@@ -2054,7 +2131,7 @@ sub process {
2054 # XXX(foo); 2131 # XXX(foo);
2055 # EXPORT_SYMBOL(something_foo); 2132 # EXPORT_SYMBOL(something_foo);
2056 my $name = $1; 2133 my $name = $1;
2057 if ($stat =~ /^.([A-Z_]+)\s*\(\s*($Ident)/ && 2134 if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
2058 $name =~ /^${Ident}_$2/) { 2135 $name =~ /^${Ident}_$2/) {
2059#print "FOO C name<$name>\n"; 2136#print "FOO C name<$name>\n";
2060 $suppress_export{$realline_next} = 1; 2137 $suppress_export{$realline_next} = 1;
@@ -2132,8 +2209,9 @@ sub process {
2132 2209
2133# * goes on variable not on type 2210# * goes on variable not on type
2134 # (char*[ const]) 2211 # (char*[ const])
2135 if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) { 2212 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
2136 my ($from, $to) = ($1, $1); 2213 #print "AA<$1>\n";
2214 my ($from, $to) = ($2, $2);
2137 2215
2138 # Should start with a space. 2216 # Should start with a space.
2139 $to =~ s/^(\S)/ $1/; 2217 $to =~ s/^(\S)/ $1/;
@@ -2148,8 +2226,10 @@ sub process {
2148 ERROR("POINTER_LOCATION", 2226 ERROR("POINTER_LOCATION",
2149 "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); 2227 "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr);
2150 } 2228 }
2151 } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) { 2229 }
2152 my ($from, $to, $ident) = ($1, $1, $2); 2230 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
2231 #print "BB<$1>\n";
2232 my ($from, $to, $ident) = ($2, $2, $3);
2153 2233
2154 # Should start with a space. 2234 # Should start with a space.
2155 $to =~ s/^(\S)/ $1/; 2235 $to =~ s/^(\S)/ $1/;
@@ -2532,7 +2612,7 @@ sub process {
2532 # Flatten any parentheses 2612 # Flatten any parentheses
2533 $value =~ s/\(/ \(/g; 2613 $value =~ s/\(/ \(/g;
2534 $value =~ s/\)/\) /g; 2614 $value =~ s/\)/\) /g;
2535 while ($value =~ s/\[[^\{\}]*\]/1/ || 2615 while ($value =~ s/\[[^\[\]]*\]/1/ ||
2536 $value !~ /(?:$Ident|-?$Constant)\s* 2616 $value !~ /(?:$Ident|-?$Constant)\s*
2537 $Compare\s* 2617 $Compare\s*
2538 (?:$Ident|-?$Constant)/x && 2618 (?:$Ident|-?$Constant)/x &&
@@ -2557,27 +2637,6 @@ sub process {
2557 } 2637 }
2558 } 2638 }
2559 2639
2560# typecasts on min/max could be min_t/max_t
2561 if ($line =~ /^\+(?:.*?)\b(min|max)\s*\($Typecast{0,1}($LvalOrFunc)\s*,\s*$Typecast{0,1}($LvalOrFunc)\s*\)/) {
2562 if (defined $2 || defined $8) {
2563 my $call = $1;
2564 my $cast1 = deparenthesize($2);
2565 my $arg1 = $3;
2566 my $cast2 = deparenthesize($8);
2567 my $arg2 = $9;
2568 my $cast;
2569
2570 if ($cast1 ne "" && $cast2 ne "") {
2571 $cast = "$cast1 or $cast2";
2572 } elsif ($cast1 ne "") {
2573 $cast = $cast1;
2574 } else {
2575 $cast = $cast2;
2576 }
2577 WARN("$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr);
2578 }
2579 }
2580
2581# Need a space before open parenthesis after if, while etc 2640# Need a space before open parenthesis after if, while etc
2582 if ($line=~/\b(if|while|for|switch)\(/) { 2641 if ($line=~/\b(if|while|for|switch)\(/) {
2583 ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); 2642 ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr);
@@ -2586,6 +2645,9 @@ sub process {
2586# Check for illegal assignment in if conditional -- and check for trailing 2645# Check for illegal assignment in if conditional -- and check for trailing
2587# statements after the conditional. 2646# statements after the conditional.
2588 if ($line =~ /do\s*(?!{)/) { 2647 if ($line =~ /do\s*(?!{)/) {
2648 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
2649 ctx_statement_block($linenr, $realcnt, 0)
2650 if (!defined $stat);
2589 my ($stat_next) = ctx_statement_block($line_nr_next, 2651 my ($stat_next) = ctx_statement_block($line_nr_next,
2590 $remain_next, $off_next); 2652 $remain_next, $off_next);
2591 $stat_next =~ s/\n./\n /g; 2653 $stat_next =~ s/\n./\n /g;
@@ -2741,47 +2803,13 @@ sub process {
2741 my $cnt = $realcnt; 2803 my $cnt = $realcnt;
2742 my ($off, $dstat, $dcond, $rest); 2804 my ($off, $dstat, $dcond, $rest);
2743 my $ctx = ''; 2805 my $ctx = '';
2744
2745 my $args = defined($1);
2746
2747 # Find the end of the macro and limit our statement
2748 # search to that.
2749 while ($cnt > 0 && defined $lines[$ln - 1] &&
2750 $lines[$ln - 1] =~ /^(?:-|..*\\$)/)
2751 {
2752 $ctx .= $rawlines[$ln - 1] . "\n";
2753 $cnt-- if ($lines[$ln - 1] !~ /^-/);
2754 $ln++;
2755 }
2756 $ctx .= $rawlines[$ln - 1];
2757
2758 ($dstat, $dcond, $ln, $cnt, $off) = 2806 ($dstat, $dcond, $ln, $cnt, $off) =
2759 ctx_statement_block($linenr, $ln - $linenr + 1, 0); 2807 ctx_statement_block($linenr, $realcnt, 0);
2808 $ctx = $dstat;
2760 #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; 2809 #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n";
2761 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; 2810 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
2762 2811
2763 # Extract the remainder of the define (if any) and 2812 $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
2764 # rip off surrounding spaces, and trailing \'s.
2765 $rest = '';
2766 while ($off != 0 || ($cnt > 0 && $rest =~ /\\\s*$/)) {
2767 #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n";
2768 if ($off != 0 || $lines[$ln - 1] !~ /^-/) {
2769 $rest .= substr($lines[$ln - 1], $off) . "\n";
2770 $cnt--;
2771 }
2772 $ln++;
2773 $off = 0;
2774 }
2775 $rest =~ s/\\\n.//g;
2776 $rest =~ s/^\s*//s;
2777 $rest =~ s/\s*$//s;
2778
2779 # Clean up the original statement.
2780 if ($args) {
2781 substr($dstat, 0, length($dcond), '');
2782 } else {
2783 $dstat =~ s/^.\s*\#\s*define\s+$Ident\s*//;
2784 }
2785 $dstat =~ s/$;//g; 2813 $dstat =~ s/$;//g;
2786 $dstat =~ s/\\\n.//g; 2814 $dstat =~ s/\\\n.//g;
2787 $dstat =~ s/^\s*//s; 2815 $dstat =~ s/^\s*//s;
@@ -2790,7 +2818,7 @@ sub process {
2790 # Flatten any parentheses and braces 2818 # Flatten any parentheses and braces
2791 while ($dstat =~ s/\([^\(\)]*\)/1/ || 2819 while ($dstat =~ s/\([^\(\)]*\)/1/ ||
2792 $dstat =~ s/\{[^\{\}]*\}/1/ || 2820 $dstat =~ s/\{[^\{\}]*\}/1/ ||
2793 $dstat =~ s/\[[^\{\}]*\]/1/) 2821 $dstat =~ s/\[[^\[\]]*\]/1/)
2794 { 2822 {
2795 } 2823 }
2796 2824
@@ -2807,23 +2835,32 @@ sub process {
2807 ^\"|\"$ 2835 ^\"|\"$
2808 }x; 2836 }x;
2809 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; 2837 #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
2810 if ($rest ne '' && $rest ne ',') { 2838 if ($dstat ne '' &&
2811 if ($rest !~ /while\s*\(/ && 2839 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
2812 $dstat !~ /$exceptions/) 2840 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
2813 { 2841 $dstat !~ /^(?:$Ident|-?$Constant)$/ && # 10 // foo()
2814 ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", 2842 $dstat !~ /$exceptions/ &&
2815 "Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); 2843 $dstat !~ /^\.$Ident\s*=/ && # .foo =
2844 $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...)
2845 $dstat !~ /^for\s*$Constant$/ && # for (...)
2846 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
2847 $dstat !~ /^do\s*{/ && # do {...
2848 $dstat !~ /^\({/) # ({...
2849 {
2850 $ctx =~ s/\n*$//;
2851 my $herectx = $here . "\n";
2852 my $cnt = statement_rawlines($ctx);
2853
2854 for (my $n = 0; $n < $cnt; $n++) {
2855 $herectx .= raw_line($linenr, $n) . "\n";
2816 } 2856 }
2817 2857
2818 } elsif ($ctx !~ /;/) { 2858 if ($dstat =~ /;/) {
2819 if ($dstat ne '' && 2859 ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
2820 $dstat !~ /^(?:$Ident|-?$Constant)$/ && 2860 "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
2821 $dstat !~ /$exceptions/ && 2861 } else {
2822 $dstat !~ /^\.$Ident\s*=/ &&
2823 $dstat =~ /$Operators/)
2824 {
2825 ERROR("COMPLEX_MACRO", 2862 ERROR("COMPLEX_MACRO",
2826 "Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); 2863 "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
2827 } 2864 }
2828 } 2865 }
2829 } 2866 }
@@ -2931,11 +2968,11 @@ sub process {
2931 } 2968 }
2932 } 2969 }
2933 if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) { 2970 if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
2934 my $herectx = $here . "\n";; 2971 my $herectx = $here . "\n";
2935 my $cnt = statement_rawlines($block); 2972 my $cnt = statement_rawlines($block);
2936 2973
2937 for (my $n = 0; $n < $cnt; $n++) { 2974 for (my $n = 0; $n < $cnt; $n++) {
2938 $herectx .= raw_line($linenr, $n) . "\n";; 2975 $herectx .= raw_line($linenr, $n) . "\n";
2939 } 2976 }
2940 2977
2941 WARN("BRACES", 2978 WARN("BRACES",
@@ -3074,6 +3111,12 @@ sub process {
3074 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr); 3111 "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
3075 } 3112 }
3076 3113
3114# Check for __attribute__ format(printf, prefer __printf
3115 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3116 WARN("PREFER_PRINTF",
3117 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr);
3118 }
3119
3077# check for sizeof(&) 3120# check for sizeof(&)
3078 if ($line =~ /\bsizeof\s*\(\s*\&/) { 3121 if ($line =~ /\bsizeof\s*\(\s*\&/) {
3079 WARN("SIZEOF_ADDRESS", 3122 WARN("SIZEOF_ADDRESS",
@@ -3086,6 +3129,46 @@ sub process {
3086 "Avoid line continuations in quoted strings\n" . $herecurr); 3129 "Avoid line continuations in quoted strings\n" . $herecurr);
3087 } 3130 }
3088 3131
3132# Check for misused memsets
3133 if (defined $stat &&
3134 $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) {
3135
3136 my $ms_addr = $2;
3137 my $ms_val = $8;
3138 my $ms_size = $14;
3139
3140 if ($ms_size =~ /^(0x|)0$/i) {
3141 ERROR("MEMSET",
3142 "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n");
3143 } elsif ($ms_size =~ /^(0x|)1$/i) {
3144 WARN("MEMSET",
3145 "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n");
3146 }
3147 }
3148
3149# typecasts on min/max could be min_t/max_t
3150 if (defined $stat &&
3151 $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) {
3152 if (defined $2 || defined $8) {
3153 my $call = $1;
3154 my $cast1 = deparenthesize($2);
3155 my $arg1 = $3;
3156 my $cast2 = deparenthesize($8);
3157 my $arg2 = $9;
3158 my $cast;
3159
3160 if ($cast1 ne "" && $cast2 ne "") {
3161 $cast = "$cast1 or $cast2";
3162 } elsif ($cast1 ne "") {
3163 $cast = $cast1;
3164 } else {
3165 $cast = $cast2;
3166 }
3167 WARN("MINMAX",
3168 "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n");
3169 }
3170 }
3171
3089# check for new externs in .c files. 3172# check for new externs in .c files.
3090 if ($realfile =~ /\.c$/ && defined $stat && 3173 if ($realfile =~ /\.c$/ && defined $stat &&
3091 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 3174 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -3150,10 +3233,10 @@ sub process {
3150 "consider using a completion\n" . $herecurr); 3233 "consider using a completion\n" . $herecurr);
3151 3234
3152 } 3235 }
3153# recommend kstrto* over simple_strto* 3236# recommend kstrto* over simple_strto* and strict_strto*
3154 if ($line =~ /\bsimple_(strto.*?)\s*\(/) { 3237 if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
3155 WARN("CONSIDER_KSTRTO", 3238 WARN("CONSIDER_KSTRTO",
3156 "consider using kstrto* in preference to simple_$1\n" . $herecurr); 3239 "$1 is obsolete, use k$3 instead\n" . $herecurr);
3157 } 3240 }
3158# check for __initcall(), use device_initcall() explicitly please 3241# check for __initcall(), use device_initcall() explicitly please
3159 if ($line =~ /^.\s*__initcall\s*\(/) { 3242 if ($line =~ /^.\s*__initcall\s*\(/) {
@@ -3257,12 +3340,6 @@ sub process {
3257 WARN("EXPORTED_WORLD_WRITABLE", 3340 WARN("EXPORTED_WORLD_WRITABLE",
3258 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); 3341 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
3259 } 3342 }
3260
3261 # Check for memset with swapped arguments
3262 if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) {
3263 ERROR("MEMSET",
3264 "memset size is 3rd argument, not the second.\n" . $herecurr);
3265 }
3266 } 3343 }
3267 3344
3268 # If we have no input at all, then there is nothing to report on 3345 # If we have no input at all, then there is nothing to report on
diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
new file mode 100755
index 000000000000..5061abcc2540
--- /dev/null
+++ b/scripts/extract-vmlinux
@@ -0,0 +1,62 @@
1#!/bin/sh
2# ----------------------------------------------------------------------
3# extract-vmlinux - Extract uncompressed vmlinux from a kernel image
4#
5# Inspired from extract-ikconfig
6# (c) 2009,2010 Dick Streefland <dick@streefland.net>
7#
8# (c) 2011 Corentin Chary <corentin.chary@gmail.com>
9#
10# Licensed under the GNU General Public License, version 2 (GPLv2).
11# ----------------------------------------------------------------------
12
13check_vmlinux()
14{
15 # Use readelf to check if it's a valid ELF
16 # TODO: find a better to way to check that it's really vmlinux
17 # and not just an elf
18 readelf -h $1 > /dev/null 2>&1 || return 1
19
20 cat $1
21 exit 0
22}
23
24try_decompress()
25{
26 # The obscure use of the "tr" filter is to work around older versions of
27 # "grep" that report the byte offset of the line instead of the pattern.
28
29 # Try to find the header ($1) and decompress from here
30 for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
31 do
32 pos=${pos%%:*}
33 tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
34 check_vmlinux $tmp
35 done
36}
37
38# Check invocation:
39me=${0##*/}
40img=$1
41if [ $# -ne 1 -o ! -s "$img" ]
42then
43 echo "Usage: $me <kernel-image>" >&2
44 exit 2
45fi
46
47# Prepare temp files:
48tmp=$(mktemp /tmp/vmlinux-XXX)
49trap "rm -f $tmp" 0
50
51# Initial attempt for uncompressed images or objects:
52check_vmlinux $img
53
54# That didn't work, so retry after decompression.
55try_decompress '\037\213\010' xy gunzip
56try_decompress '\3757zXZ\000' abcde unxz
57try_decompress 'BZh' xy bunzip2
58try_decompress '\135\0\0\0' xxx unlzma
59try_decompress '\211\114\132' xy 'lzop -d'
60
61# Bail out:
62echo "$me: Cannot find vmlinux." >&2
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index eb2f1e64edf7..f32a04c4c5bc 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -95,7 +95,7 @@ my %VCS_cmds_git = (
95 "execute_cmd" => \&git_execute_cmd, 95 "execute_cmd" => \&git_execute_cmd,
96 "available" => '(which("git") ne "") && (-d ".git")', 96 "available" => '(which("git") ne "") && (-d ".git")',
97 "find_signers_cmd" => 97 "find_signers_cmd" =>
98 "git log --no-color --since=\$email_git_since " . 98 "git log --no-color --follow --since=\$email_git_since " .
99 '--format="GitCommit: %H%n' . 99 '--format="GitCommit: %H%n' .
100 'GitAuthor: %an <%ae>%n' . 100 'GitAuthor: %an <%ae>%n' .
101 'GitDate: %aD%n' . 101 'GitDate: %aD%n' .
@@ -1389,7 +1389,7 @@ sub vcs_exists {
1389 warn("$P: No supported VCS found. Add --nogit to options?\n"); 1389 warn("$P: No supported VCS found. Add --nogit to options?\n");
1390 warn("Using a git repository produces better results.\n"); 1390 warn("Using a git repository produces better results.\n");
1391 warn("Try Linus Torvalds' latest git repository using:\n"); 1391 warn("Try Linus Torvalds' latest git repository using:\n");
1392 warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n"); 1392 warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\n");
1393 $printed_novcs = 1; 1393 $printed_novcs = 1;
1394 } 1394 }
1395 return 0; 1395 return 0;
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 82d2eb285b70..914833d99b06 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -33,17 +33,9 @@ silentoldconfig: $(obj)/conf
33 $(Q)mkdir -p include/generated 33 $(Q)mkdir -p include/generated
34 $< --$@ $(Kconfig) 34 $< --$@ $(Kconfig)
35 35
36# if no path is given, then use src directory to find file 36localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
37ifdef LSMOD
38LSMOD_F := $(LSMOD)
39ifeq ($(findstring /,$(LSMOD)),)
40 LSMOD_F := $(objtree)/$(LSMOD)
41endif
42endif
43
44localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
45 $(Q)mkdir -p include/generated 37 $(Q)mkdir -p include/generated
46 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config 38 $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
47 $(Q)if [ -f .config ]; then \ 39 $(Q)if [ -f .config ]; then \
48 cmp -s .tmp.config .config || \ 40 cmp -s .tmp.config .config || \
49 (mv -f .config .config.old.1; \ 41 (mv -f .config .config.old.1; \
@@ -56,22 +48,6 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
56 fi 48 fi
57 $(Q)rm -f .tmp.config 49 $(Q)rm -f .tmp.config
58 50
59localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
60 $(Q)mkdir -p include/generated
61 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
62 $(Q)sed -i s/=m/=y/ .tmp.config
63 $(Q)if [ -f .config ]; then \
64 cmp -s .tmp.config .config || \
65 (mv -f .config .config.old.1; \
66 mv -f .tmp.config .config; \
67 $(obj)/conf --silentoldconfig $(Kconfig); \
68 mv -f .config.old.1 .config.old) \
69 else \
70 mv -f .tmp.config .config; \
71 $(obj)/conf --silentoldconfig $(Kconfig); \
72 fi
73 $(Q)rm -f .tmp.config
74
75# Create new linux.pot file 51# Create new linux.pot file
76# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 52# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
77# The symlink is used to repair a deficiency in arch/um 53# The symlink is used to repair a deficiency in arch/um
@@ -84,8 +60,8 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
84 --directory=$(srctree) --directory=$(objtree) \ 60 --directory=$(srctree) --directory=$(objtree) \
85 --output $(obj)/config.pot 61 --output $(obj)/config.pot
86 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 62 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
87 $(Q)ln -fs Kconfig.x86 arch/um/Kconfig 63 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
88 $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \ 64 $(srctree)/arch/*/um/Kconfig`; \
89 do \ 65 do \
90 echo " GEN $$i"; \ 66 echo " GEN $$i"; \
91 $(obj)/kxgettext $$i \ 67 $(obj)/kxgettext $$i \
@@ -93,7 +69,6 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
93 done ) 69 done )
94 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 70 $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
95 --output $(obj)/linux.pot 71 --output $(obj)/linux.pot
96 $(Q)rm -f $(srctree)/arch/um/Kconfig
97 $(Q)rm -f $(obj)/config.pot 72 $(Q)rm -f $(obj)/config.pot
98 73
99PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig 74PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 59b667cae5f3..5a58965d8800 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -503,17 +503,6 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
503 fprintf(fp, "#define %s%s%s 1\n", 503 fprintf(fp, "#define %s%s%s 1\n",
504 CONFIG_, sym->name, suffix); 504 CONFIG_, sym->name, suffix);
505 } 505 }
506 /*
507 * Generate the __enabled_CONFIG_* and
508 * __enabled_CONFIG_*_MODULE macros for use by the
509 * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
510 * generated even for booleans so that the IS_ENABLED() macro
511 * works.
512 */
513 fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
514 sym->name, (*value == 'y'));
515 fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
516 sym->name, (*value == 'm'));
517 break; 506 break;
518 } 507 }
519 case S_HEX: { 508 case S_HEX: {
@@ -565,6 +554,35 @@ static struct conf_printer header_printer_cb =
565}; 554};
566 555
567/* 556/*
557 * Generate the __enabled_CONFIG_* and __enabled_CONFIG_*_MODULE macros for
558 * use by the IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
559 * generated even for booleans so that the IS_ENABLED() macro works.
560 */
561static void
562header_print__enabled_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
563{
564
565 switch (sym->type) {
566 case S_BOOLEAN:
567 case S_TRISTATE: {
568 fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
569 sym->name, (*value == 'y'));
570 fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
571 sym->name, (*value == 'm'));
572 break;
573 }
574 default:
575 break;
576 }
577}
578
579static struct conf_printer header__enabled_printer_cb =
580{
581 .print_symbol = header_print__enabled_symbol,
582 .print_comment = header_print_comment,
583};
584
585/*
568 * Tristate printer 586 * Tristate printer
569 * 587 *
570 * This printer is used when generating the `include/config/tristate.conf' file. 588 * This printer is used when generating the `include/config/tristate.conf' file.
@@ -945,11 +963,16 @@ int conf_write_autoconf(void)
945 conf_write_heading(out_h, &header_printer_cb, NULL); 963 conf_write_heading(out_h, &header_printer_cb, NULL);
946 964
947 for_all_symbols(i, sym) { 965 for_all_symbols(i, sym) {
966 if (!sym->name)
967 continue;
968
948 sym_calc_value(sym); 969 sym_calc_value(sym);
949 if (!(sym->flags & SYMBOL_WRITE) || !sym->name) 970
971 conf_write_symbol(out_h, sym, &header__enabled_printer_cb, NULL);
972
973 if (!(sym->flags & SYMBOL_WRITE))
950 continue; 974 continue;
951 975
952 /* write symbol to auto.conf, tristate and header files */
953 conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); 976 conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
954 977
955 conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); 978 conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index c704712d0227..154c2dd245b7 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -320,7 +320,6 @@ static void print_page(WINDOW * win, int height, int width)
320 */ 320 */
321static void print_line(WINDOW * win, int row, int width) 321static void print_line(WINDOW * win, int row, int width)
322{ 322{
323 int y, x;
324 char *line; 323 char *line;
325 324
326 line = get_line(); 325 line = get_line();
@@ -329,10 +328,10 @@ static void print_line(WINDOW * win, int row, int width)
329 waddch(win, ' '); 328 waddch(win, ' ');
330 waddnstr(win, line, MIN(strlen(line), width - 2)); 329 waddnstr(win, line, MIN(strlen(line), width - 2));
331 330
332 getyx(win, y, x);
333 /* Clear 'residue' of previous line */ 331 /* Clear 'residue' of previous line */
334#if OLD_NCURSES 332#if OLD_NCURSES
335 { 333 {
334 int x = getcurx(win);
336 int i; 335 int i;
337 for (i = 0; i < width - x; i++) 336 for (i = 0; i < width - x; i++)
338 waddch(win, ' '); 337 waddch(win, ' ');
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 820d2b6800fb..19e200d91120 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -15,6 +15,7 @@
15#include <stdarg.h> 15#include <stdarg.h>
16#include <stdlib.h> 16#include <stdlib.h>
17#include <string.h> 17#include <string.h>
18#include <signal.h>
18#include <unistd.h> 19#include <unistd.h>
19#include <locale.h> 20#include <locale.h>
20 21
@@ -272,6 +273,7 @@ static struct menu *current_menu;
272static int child_count; 273static int child_count;
273static int single_menu_mode; 274static int single_menu_mode;
274static int show_all_options; 275static int show_all_options;
276static int saved_x, saved_y;
275 277
276static void conf(struct menu *menu); 278static void conf(struct menu *menu);
277static void conf_choice(struct menu *menu); 279static void conf_choice(struct menu *menu);
@@ -792,9 +794,54 @@ static void conf_save(void)
792 } 794 }
793} 795}
794 796
797static int handle_exit(void)
798{
799 int res;
800
801 dialog_clear();
802 if (conf_get_changed())
803 res = dialog_yesno(NULL,
804 _("Do you wish to save your new configuration ?\n"
805 "<ESC><ESC> to continue."),
806 6, 60);
807 else
808 res = -1;
809
810 end_dialog(saved_x, saved_y);
811
812 switch (res) {
813 case 0:
814 if (conf_write(filename)) {
815 fprintf(stderr, _("\n\n"
816 "Error while writing of the configuration.\n"
817 "Your configuration changes were NOT saved."
818 "\n\n"));
819 return 1;
820 }
821 /* fall through */
822 case -1:
823 printf(_("\n\n"
824 "*** End of the configuration.\n"
825 "*** Execute 'make' to start the build or try 'make help'."
826 "\n\n"));
827 res = 0;
828 break;
829 default:
830 fprintf(stderr, _("\n\n"
831 "Your configuration changes were NOT saved."
832 "\n\n"));
833 }
834
835 return res;
836}
837
838static void sig_handler(int signo)
839{
840 exit(handle_exit());
841}
842
795int main(int ac, char **av) 843int main(int ac, char **av)
796{ 844{
797 int saved_x, saved_y;
798 char *mode; 845 char *mode;
799 int res; 846 int res;
800 847
@@ -802,6 +849,8 @@ int main(int ac, char **av)
802 bindtextdomain(PACKAGE, LOCALEDIR); 849 bindtextdomain(PACKAGE, LOCALEDIR);
803 textdomain(PACKAGE); 850 textdomain(PACKAGE);
804 851
852 signal(SIGINT, sig_handler);
853
805 conf_parse(av[1]); 854 conf_parse(av[1]);
806 conf_read(NULL); 855 conf_read(NULL);
807 856
@@ -823,40 +872,9 @@ int main(int ac, char **av)
823 set_config_filename(conf_get_configname()); 872 set_config_filename(conf_get_configname());
824 do { 873 do {
825 conf(&rootmenu); 874 conf(&rootmenu);
826 dialog_clear(); 875 res = handle_exit();
827 if (conf_get_changed())
828 res = dialog_yesno(NULL,
829 _("Do you wish to save your "
830 "new configuration?\n"
831 "<ESC><ESC> to continue."),
832 6, 60);
833 else
834 res = -1;
835 } while (res == KEY_ESC); 876 } while (res == KEY_ESC);
836 end_dialog(saved_x, saved_y);
837
838 switch (res) {
839 case 0:
840 if (conf_write(filename)) {
841 fprintf(stderr, _("\n\n"
842 "Error while writing of the configuration.\n"
843 "Your configuration changes were NOT saved."
844 "\n\n"));
845 return 1;
846 }
847 /* fall through */
848 case -1:
849 printf(_("\n\n"
850 "*** End of the configuration.\n"
851 "*** Execute 'make' to start the build or try 'make help'."
852 "\n\n"));
853 break;
854 default:
855 fprintf(stderr, _("\n\n"
856 "Your configuration changes were NOT saved."
857 "\n\n"));
858 }
859 877
860 return 0; 878 return res;
861} 879}
862 880
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index d66008639a43..8c2a97e60faf 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -10,8 +10,7 @@
10 10
11#include "lkc.h" 11#include "lkc.h"
12 12
13static const char nohelp_text[] = N_( 13static const char nohelp_text[] = "There is no help available for this option.";
14 "There is no help available for this option.\n");
15 14
16struct menu rootmenu; 15struct menu rootmenu;
17static struct menu **last_entry_ptr; 16static struct menu **last_entry_ptr;
@@ -595,16 +594,14 @@ struct gstr get_relations_str(struct symbol **sym_arr)
595void menu_get_ext_help(struct menu *menu, struct gstr *help) 594void menu_get_ext_help(struct menu *menu, struct gstr *help)
596{ 595{
597 struct symbol *sym = menu->sym; 596 struct symbol *sym = menu->sym;
597 const char *help_text = nohelp_text;
598 598
599 if (menu_has_help(menu)) { 599 if (menu_has_help(menu)) {
600 if (sym->name) { 600 if (sym->name)
601 str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); 601 str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
602 str_append(help, _(menu_get_help(menu))); 602 help_text = menu_get_help(menu);
603 str_append(help, "\n");
604 }
605 } else {
606 str_append(help, nohelp_text);
607 } 603 }
604 str_printf(help, "%s\n", _(help_text));
608 if (sym) 605 if (sym)
609 get_symbol_str(help, sym); 606 get_symbol_str(help, sym);
610} 607}
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 39ca1f1640ea..73070cb0b6de 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -182,8 +182,6 @@ setmod_text[] = N_(
182"This feature depends on another which\n" 182"This feature depends on another which\n"
183"has been configured as a module.\n" 183"has been configured as a module.\n"
184"As a result, this feature will be built as a module."), 184"As a result, this feature will be built as a module."),
185nohelp_text[] = N_(
186"There is no help available for this option.\n"),
187load_config_text[] = N_( 185load_config_text[] = N_(
188"Enter the name of the configuration file you wish to load.\n" 186"Enter the name of the configuration file you wish to load.\n"
189"Accept the name shown to restore the configuration you\n" 187"Accept the name shown to restore the configuration you\n"
@@ -280,6 +278,9 @@ static int global_exit;
280/* the currently selected button */ 278/* the currently selected button */
281const char *current_instructions = menu_instructions; 279const char *current_instructions = menu_instructions;
282 280
281static char *dialog_input_result;
282static int dialog_input_result_len;
283
283static void conf(struct menu *menu); 284static void conf(struct menu *menu);
284static void conf_choice(struct menu *menu); 285static void conf_choice(struct menu *menu);
285static void conf_string(struct menu *menu); 286static void conf_string(struct menu *menu);
@@ -695,7 +696,6 @@ static void search_conf(void)
695{ 696{
696 struct symbol **sym_arr; 697 struct symbol **sym_arr;
697 struct gstr res; 698 struct gstr res;
698 char dialog_input_result[100];
699 char *dialog_input; 699 char *dialog_input;
700 int dres; 700 int dres;
701again: 701again:
@@ -703,7 +703,7 @@ again:
703 _("Search Configuration Parameter"), 703 _("Search Configuration Parameter"),
704 _("Enter " CONFIG_ " (sub)string to search for " 704 _("Enter " CONFIG_ " (sub)string to search for "
705 "(with or without \"" CONFIG_ "\")"), 705 "(with or without \"" CONFIG_ "\")"),
706 "", dialog_input_result, 99); 706 "", &dialog_input_result, &dialog_input_result_len);
707 switch (dres) { 707 switch (dres) {
708 case 0: 708 case 0:
709 break; 709 break;
@@ -1348,7 +1348,6 @@ static void conf_choice(struct menu *menu)
1348static void conf_string(struct menu *menu) 1348static void conf_string(struct menu *menu)
1349{ 1349{
1350 const char *prompt = menu_get_prompt(menu); 1350 const char *prompt = menu_get_prompt(menu);
1351 char dialog_input_result[256];
1352 1351
1353 while (1) { 1352 while (1) {
1354 int res; 1353 int res;
@@ -1371,8 +1370,8 @@ static void conf_string(struct menu *menu)
1371 prompt ? _(prompt) : _("Main Menu"), 1370 prompt ? _(prompt) : _("Main Menu"),
1372 heading, 1371 heading,
1373 sym_get_string_value(menu->sym), 1372 sym_get_string_value(menu->sym),
1374 dialog_input_result, 1373 &dialog_input_result,
1375 sizeof(dialog_input_result)); 1374 &dialog_input_result_len);
1376 switch (res) { 1375 switch (res) {
1377 case 0: 1376 case 0:
1378 if (sym_set_string_value(menu->sym, 1377 if (sym_set_string_value(menu->sym,
@@ -1392,14 +1391,13 @@ static void conf_string(struct menu *menu)
1392 1391
1393static void conf_load(void) 1392static void conf_load(void)
1394{ 1393{
1395 char dialog_input_result[256];
1396 while (1) { 1394 while (1) {
1397 int res; 1395 int res;
1398 res = dialog_inputbox(main_window, 1396 res = dialog_inputbox(main_window,
1399 NULL, load_config_text, 1397 NULL, load_config_text,
1400 filename, 1398 filename,
1401 dialog_input_result, 1399 &dialog_input_result,
1402 sizeof(dialog_input_result)); 1400 &dialog_input_result_len);
1403 switch (res) { 1401 switch (res) {
1404 case 0: 1402 case 0:
1405 if (!dialog_input_result[0]) 1403 if (!dialog_input_result[0])
@@ -1424,14 +1422,13 @@ static void conf_load(void)
1424 1422
1425static void conf_save(void) 1423static void conf_save(void)
1426{ 1424{
1427 char dialog_input_result[256];
1428 while (1) { 1425 while (1) {
1429 int res; 1426 int res;
1430 res = dialog_inputbox(main_window, 1427 res = dialog_inputbox(main_window,
1431 NULL, save_config_text, 1428 NULL, save_config_text,
1432 filename, 1429 filename,
1433 dialog_input_result, 1430 &dialog_input_result,
1434 sizeof(dialog_input_result)); 1431 &dialog_input_result_len);
1435 switch (res) { 1432 switch (res) {
1436 case 0: 1433 case 0:
1437 if (!dialog_input_result[0]) 1434 if (!dialog_input_result[0])
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index f8137b3a5382..3b18dd839668 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -356,7 +356,7 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
356 356
357int dialog_inputbox(WINDOW *main_window, 357int dialog_inputbox(WINDOW *main_window,
358 const char *title, const char *prompt, 358 const char *title, const char *prompt,
359 const char *init, char *result, int result_len) 359 const char *init, char **resultp, int *result_len)
360{ 360{
361 int prompt_lines = 0; 361 int prompt_lines = 0;
362 int prompt_width = 0; 362 int prompt_width = 0;
@@ -367,7 +367,13 @@ int dialog_inputbox(WINDOW *main_window,
367 int i, x, y; 367 int i, x, y;
368 int res = -1; 368 int res = -1;
369 int cursor_position = strlen(init); 369 int cursor_position = strlen(init);
370 int cursor_form_win;
371 char *result = *resultp;
370 372
373 if (strlen(init)+1 > *result_len) {
374 *result_len = strlen(init)+1;
375 *resultp = result = realloc(result, *result_len);
376 }
371 377
372 /* find the widest line of msg: */ 378 /* find the widest line of msg: */
373 prompt_lines = get_line_no(prompt); 379 prompt_lines = get_line_no(prompt);
@@ -384,7 +390,7 @@ int dialog_inputbox(WINDOW *main_window,
384 y = (LINES-(prompt_lines+4))/2; 390 y = (LINES-(prompt_lines+4))/2;
385 x = (COLS-(prompt_width+4))/2; 391 x = (COLS-(prompt_width+4))/2;
386 392
387 strncpy(result, init, result_len); 393 strncpy(result, init, *result_len);
388 394
389 /* create the windows */ 395 /* create the windows */
390 win = newwin(prompt_lines+6, prompt_width+7, y, x); 396 win = newwin(prompt_lines+6, prompt_width+7, y, x);
@@ -405,7 +411,9 @@ int dialog_inputbox(WINDOW *main_window,
405 fill_window(prompt_win, prompt); 411 fill_window(prompt_win, prompt);
406 412
407 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); 413 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
408 mvwprintw(form_win, 0, 0, "%s", result); 414 cursor_form_win = min(cursor_position, prompt_width-1);
415 mvwprintw(form_win, 0, 0, "%s",
416 result + cursor_position-cursor_form_win);
409 417
410 /* create panels */ 418 /* create panels */
411 panel = new_panel(win); 419 panel = new_panel(win);
@@ -431,6 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
431 &result[cursor_position], 439 &result[cursor_position],
432 len-cursor_position+1); 440 len-cursor_position+1);
433 cursor_position--; 441 cursor_position--;
442 cursor_form_win--;
443 len--;
434 } 444 }
435 break; 445 break;
436 case KEY_DC: 446 case KEY_DC:
@@ -438,38 +448,63 @@ int dialog_inputbox(WINDOW *main_window,
438 memmove(&result[cursor_position], 448 memmove(&result[cursor_position],
439 &result[cursor_position+1], 449 &result[cursor_position+1],
440 len-cursor_position+1); 450 len-cursor_position+1);
451 len--;
441 } 452 }
442 break; 453 break;
443 case KEY_UP: 454 case KEY_UP:
444 case KEY_RIGHT: 455 case KEY_RIGHT:
445 if (cursor_position < len && 456 if (cursor_position < len) {
446 cursor_position < min(result_len, prompt_width))
447 cursor_position++; 457 cursor_position++;
458 cursor_form_win++;
459 }
448 break; 460 break;
449 case KEY_DOWN: 461 case KEY_DOWN:
450 case KEY_LEFT: 462 case KEY_LEFT:
451 if (cursor_position > 0) 463 if (cursor_position > 0) {
452 cursor_position--; 464 cursor_position--;
465 cursor_form_win--;
466 }
467 break;
468 case KEY_HOME:
469 cursor_position = 0;
470 cursor_form_win = 0;
471 break;
472 case KEY_END:
473 cursor_position = len;
474 cursor_form_win = min(cursor_position, prompt_width-1);
453 break; 475 break;
454 default: 476 default:
455 if ((isgraph(res) || isspace(res)) && 477 if ((isgraph(res) || isspace(res))) {
456 len-2 < result_len) { 478 /* one for new char, one for '\0' */
479 if (len+2 > *result_len) {
480 *result_len = len+2;
481 *resultp = result = realloc(result,
482 *result_len);
483 }
457 /* insert the char at the proper position */ 484 /* insert the char at the proper position */
458 memmove(&result[cursor_position+1], 485 memmove(&result[cursor_position+1],
459 &result[cursor_position], 486 &result[cursor_position],
460 len+1); 487 len-cursor_position+1);
461 result[cursor_position] = res; 488 result[cursor_position] = res;
462 cursor_position++; 489 cursor_position++;
490 cursor_form_win++;
491 len++;
463 } else { 492 } else {
464 mvprintw(0, 0, "unknow key: %d\n", res); 493 mvprintw(0, 0, "unknown key: %d\n", res);
465 } 494 }
466 break; 495 break;
467 } 496 }
497 if (cursor_form_win < 0)
498 cursor_form_win = 0;
499 else if (cursor_form_win > prompt_width-1)
500 cursor_form_win = prompt_width-1;
501
468 wmove(form_win, 0, 0); 502 wmove(form_win, 0, 0);
469 wclrtoeol(form_win); 503 wclrtoeol(form_win);
470 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); 504 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
471 mvwprintw(form_win, 0, 0, "%s", result); 505 mvwprintw(form_win, 0, 0, "%s",
472 wmove(form_win, 0, cursor_position); 506 result + cursor_position-cursor_form_win);
507 wmove(form_win, 0, cursor_form_win);
473 touchwin(win); 508 touchwin(win);
474 refresh_all_windows(main_window); 509 refresh_all_windows(main_window);
475 510
diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h
index 58fbda8fc0dc..0d5261705ef5 100644
--- a/scripts/kconfig/nconf.h
+++ b/scripts/kconfig/nconf.h
@@ -89,7 +89,7 @@ void fill_window(WINDOW *win, const char *text);
89int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); 89int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
90int dialog_inputbox(WINDOW *main_window, 90int dialog_inputbox(WINDOW *main_window,
91 const char *title, const char *prompt, 91 const char *title, const char *prompt,
92 const char *init, char *result, int result_len); 92 const char *init, char **resultp, int *result_len);
93void refresh_all_windows(WINDOW *main_window); 93void refresh_all_windows(WINDOW *main_window);
94void show_scroll_win(WINDOW *main_window, 94void show_scroll_win(WINDOW *main_window,
95 const char *title, 95 const char *title,
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index a4fe923c0131..bccf07ddd0b6 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -43,6 +43,7 @@
43# make oldconfig 43# make oldconfig
44# 44#
45use strict; 45use strict;
46use Getopt::Long;
46 47
47my $config = ".config"; 48my $config = ".config";
48 49
@@ -112,10 +113,17 @@ sub find_config {
112 113
113find_config; 114find_config;
114 115
116# Parse options
117my $localmodconfig = 0;
118my $localyesconfig = 0;
119
120GetOptions("localmodconfig" => \$localmodconfig,
121 "localyesconfig" => \$localyesconfig);
122
115# Get the build source and top level Kconfig file (passed in) 123# Get the build source and top level Kconfig file (passed in)
116my $ksource = $ARGV[0]; 124my $ksource = $ARGV[0];
117my $kconfig = $ARGV[1]; 125my $kconfig = $ARGV[1];
118my $lsmod_file = $ARGV[2]; 126my $lsmod_file = $ENV{'LSMOD'};
119 127
120my @makefiles = `find $ksource -name Makefile 2>/dev/null`; 128my @makefiles = `find $ksource -name Makefile 2>/dev/null`;
121chomp @makefiles; 129chomp @makefiles;
@@ -242,33 +250,61 @@ if ($kconfig) {
242 read_kconfig($kconfig); 250 read_kconfig($kconfig);
243} 251}
244 252
253sub convert_vars {
254 my ($line, %vars) = @_;
255
256 my $process = "";
257
258 while ($line =~ s/^(.*?)(\$\((.*?)\))//) {
259 my $start = $1;
260 my $variable = $2;
261 my $var = $3;
262
263 if (defined($vars{$var})) {
264 $process .= $start . $vars{$var};
265 } else {
266 $process .= $start . $variable;
267 }
268 }
269
270 $process .= $line;
271
272 return $process;
273}
274
245# Read all Makefiles to map the configs to the objects 275# Read all Makefiles to map the configs to the objects
246foreach my $makefile (@makefiles) { 276foreach my $makefile (@makefiles) {
247 277
248 my $cont = 0; 278 my $line = "";
279 my %make_vars;
249 280
250 open(MIN,$makefile) || die "Can't open $makefile"; 281 open(MIN,$makefile) || die "Can't open $makefile";
251 while (<MIN>) { 282 while (<MIN>) {
283 # if this line ends with a backslash, continue
284 chomp;
285 if (/^(.*)\\$/) {
286 $line .= $1;
287 next;
288 }
289
290 $line .= $_;
291 $_ = $line;
292 $line = "";
293
252 my $objs; 294 my $objs;
253 295
254 # is this a line after a line with a backslash? 296 $_ = convert_vars($_, %make_vars);
255 if ($cont && /(\S.*)$/) {
256 $objs = $1;
257 }
258 $cont = 0;
259 297
260 # collect objects after obj-$(CONFIG_FOO_BAR) 298 # collect objects after obj-$(CONFIG_FOO_BAR)
261 if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) { 299 if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
262 $var = $1; 300 $var = $1;
263 $objs = $2; 301 $objs = $2;
302
303 # check if variables are set
304 } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) {
305 $make_vars{$1} = $2;
264 } 306 }
265 if (defined($objs)) { 307 if (defined($objs)) {
266 # test if the line ends with a backslash
267 if ($objs =~ m,(.*)\\$,) {
268 $objs = $1;
269 $cont = 1;
270 }
271
272 foreach my $obj (split /\s+/,$objs) { 308 foreach my $obj (split /\s+/,$objs) {
273 $obj =~ s/-/_/g; 309 $obj =~ s/-/_/g;
274 if ($obj =~ /(.*)\.o$/) { 310 if ($obj =~ /(.*)\.o$/) {
@@ -296,7 +332,11 @@ my %modules;
296 332
297if (defined($lsmod_file)) { 333if (defined($lsmod_file)) {
298 if ( ! -f $lsmod_file) { 334 if ( ! -f $lsmod_file) {
299 die "$lsmod_file not found"; 335 if ( -f $ENV{'objtree'}."/".$lsmod_file) {
336 $lsmod_file = $ENV{'objtree'}."/".$lsmod_file;
337 } else {
338 die "$lsmod_file not found";
339 }
300 } 340 }
301 if ( -x $lsmod_file) { 341 if ( -x $lsmod_file) {
302 # the file is executable, run it 342 # the file is executable, run it
@@ -421,7 +461,11 @@ while(<CIN>) {
421 461
422 if (/^(CONFIG.*)=(m|y)/) { 462 if (/^(CONFIG.*)=(m|y)/) {
423 if (defined($configs{$1})) { 463 if (defined($configs{$1})) {
424 $setconfigs{$1} = $2; 464 if ($localyesconfig) {
465 $setconfigs{$1} = 'y';
466 } else {
467 $setconfigs{$1} = $2;
468 }
425 } elsif ($2 eq "m") { 469 } elsif ($2 eq "m") {
426 print "# $1 is not set\n"; 470 print "# $1 is not set\n";
427 next; 471 next;
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e26e2fb462d4..c0e14b3f2306 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -28,6 +28,7 @@ typedef Elf64_Addr kernel_ulong_t;
28#endif 28#endif
29 29
30#include <ctype.h> 30#include <ctype.h>
31#include <stdbool.h>
31 32
32typedef uint32_t __u32; 33typedef uint32_t __u32;
33typedef uint16_t __u16; 34typedef uint16_t __u16;
@@ -38,6 +39,35 @@ typedef unsigned char __u8;
38 * we handle those differences explicitly below */ 39 * we handle those differences explicitly below */
39#include "../../include/linux/mod_devicetable.h" 40#include "../../include/linux/mod_devicetable.h"
40 41
42/* This array collects all instances that use the generic do_table */
43struct devtable {
44 const char *device_id; /* name of table, __mod_<name>_device_table. */
45 unsigned long id_size;
46 void *function;
47};
48
49/* We construct a table of pointers in an ELF section (pointers generally
50 * go unpadded by gcc). ld creates boundary syms for us. */
51extern struct devtable *__start___devtable[], *__stop___devtable[];
52#define ___cat(a,b) a ## b
53#define __cat(a,b) ___cat(a,b)
54
55#if __GNUC__ == 3 && __GNUC_MINOR__ < 3
56# define __used __attribute__((__unused__))
57#else
58# define __used __attribute__((__used__))
59#endif
60
61/* Add a table entry. We test function type matches while we're here. */
62#define ADD_TO_DEVTABLE(device_id, type, function) \
63 static struct devtable __cat(devtable,__LINE__) = { \
64 device_id + 0*sizeof((function)((const char *)NULL, \
65 (type *)NULL, \
66 (char *)NULL)), \
67 sizeof(type), (function) }; \
68 static struct devtable *__attribute__((section("__devtable"))) \
69 __used __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__)
70
41#define ADD(str, sep, cond, field) \ 71#define ADD(str, sep, cond, field) \
42do { \ 72do { \
43 strcat(str, sep); \ 73 strcat(str, sep); \
@@ -289,6 +319,7 @@ static int do_hid_entry(const char *filename,
289 319
290 return 1; 320 return 1;
291} 321}
322ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry);
292 323
293/* Looks like: ieee1394:venNmoNspNverN */ 324/* Looks like: ieee1394:venNmoNspNverN */
294static int do_ieee1394_entry(const char *filename, 325static int do_ieee1394_entry(const char *filename,
@@ -313,6 +344,7 @@ static int do_ieee1394_entry(const char *filename,
313 add_wildcard(alias); 344 add_wildcard(alias);
314 return 1; 345 return 1;
315} 346}
347ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry);
316 348
317/* Looks like: pci:vNdNsvNsdNbcNscNiN. */ 349/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
318static int do_pci_entry(const char *filename, 350static int do_pci_entry(const char *filename,
@@ -356,6 +388,7 @@ static int do_pci_entry(const char *filename,
356 add_wildcard(alias); 388 add_wildcard(alias);
357 return 1; 389 return 1;
358} 390}
391ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry);
359 392
360/* looks like: "ccw:tNmNdtNdmN" */ 393/* looks like: "ccw:tNmNdtNdmN" */
361static int do_ccw_entry(const char *filename, 394static int do_ccw_entry(const char *filename,
@@ -379,6 +412,7 @@ static int do_ccw_entry(const char *filename,
379 add_wildcard(alias); 412 add_wildcard(alias);
380 return 1; 413 return 1;
381} 414}
415ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry);
382 416
383/* looks like: "ap:tN" */ 417/* looks like: "ap:tN" */
384static int do_ap_entry(const char *filename, 418static int do_ap_entry(const char *filename,
@@ -387,6 +421,7 @@ static int do_ap_entry(const char *filename,
387 sprintf(alias, "ap:t%02X*", id->dev_type); 421 sprintf(alias, "ap:t%02X*", id->dev_type);
388 return 1; 422 return 1;
389} 423}
424ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry);
390 425
391/* looks like: "css:tN" */ 426/* looks like: "css:tN" */
392static int do_css_entry(const char *filename, 427static int do_css_entry(const char *filename,
@@ -395,6 +430,7 @@ static int do_css_entry(const char *filename,
395 sprintf(alias, "css:t%01X", id->type); 430 sprintf(alias, "css:t%01X", id->type);
396 return 1; 431 return 1;
397} 432}
433ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry);
398 434
399/* Looks like: "serio:tyNprNidNexN" */ 435/* Looks like: "serio:tyNprNidNexN" */
400static int do_serio_entry(const char *filename, 436static int do_serio_entry(const char *filename,
@@ -414,6 +450,7 @@ static int do_serio_entry(const char *filename,
414 add_wildcard(alias); 450 add_wildcard(alias);
415 return 1; 451 return 1;
416} 452}
453ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry);
417 454
418/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ 455/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
419static int do_acpi_entry(const char *filename, 456static int do_acpi_entry(const char *filename,
@@ -422,6 +459,7 @@ static int do_acpi_entry(const char *filename,
422 sprintf(alias, "acpi*:%s:*", id->id); 459 sprintf(alias, "acpi*:%s:*", id->id);
423 return 1; 460 return 1;
424} 461}
462ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry);
425 463
426/* looks like: "pnp:dD" */ 464/* looks like: "pnp:dD" */
427static void do_pnp_device_entry(void *symval, unsigned long size, 465static void do_pnp_device_entry(void *symval, unsigned long size,
@@ -544,8 +582,7 @@ static int do_pcmcia_entry(const char *filename,
544 add_wildcard(alias); 582 add_wildcard(alias);
545 return 1; 583 return 1;
546} 584}
547 585ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry);
548
549 586
550static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) 587static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
551{ 588{
@@ -568,6 +605,7 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali
568 add_wildcard(alias); 605 add_wildcard(alias);
569 return 1; 606 return 1;
570} 607}
608ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry);
571 609
572static int do_vio_entry(const char *filename, struct vio_device_id *vio, 610static int do_vio_entry(const char *filename, struct vio_device_id *vio,
573 char *alias) 611 char *alias)
@@ -585,6 +623,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio,
585 add_wildcard(alias); 623 add_wildcard(alias);
586 return 1; 624 return 1;
587} 625}
626ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry);
588 627
589#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 628#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
590 629
@@ -640,6 +679,7 @@ static int do_input_entry(const char *filename, struct input_device_id *id,
640 do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); 679 do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX);
641 return 1; 680 return 1;
642} 681}
682ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry);
643 683
644static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, 684static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
645 char *alias) 685 char *alias)
@@ -650,6 +690,7 @@ static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
650 strcat(alias, "*"); 690 strcat(alias, "*");
651 return 1; 691 return 1;
652} 692}
693ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry);
653 694
654/* Looks like: parisc:tNhvNrevNsvN */ 695/* Looks like: parisc:tNhvNrevNsvN */
655static int do_parisc_entry(const char *filename, struct parisc_device_id *id, 696static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
@@ -669,6 +710,7 @@ static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
669 add_wildcard(alias); 710 add_wildcard(alias);
670 return 1; 711 return 1;
671} 712}
713ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry);
672 714
673/* Looks like: sdio:cNvNdN. */ 715/* Looks like: sdio:cNvNdN. */
674static int do_sdio_entry(const char *filename, 716static int do_sdio_entry(const char *filename,
@@ -685,6 +727,7 @@ static int do_sdio_entry(const char *filename,
685 add_wildcard(alias); 727 add_wildcard(alias);
686 return 1; 728 return 1;
687} 729}
730ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry);
688 731
689/* Looks like: ssb:vNidNrevN. */ 732/* Looks like: ssb:vNidNrevN. */
690static int do_ssb_entry(const char *filename, 733static int do_ssb_entry(const char *filename,
@@ -701,6 +744,7 @@ static int do_ssb_entry(const char *filename,
701 add_wildcard(alias); 744 add_wildcard(alias);
702 return 1; 745 return 1;
703} 746}
747ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry);
704 748
705/* Looks like: bcma:mNidNrevNclN. */ 749/* Looks like: bcma:mNidNrevNclN. */
706static int do_bcma_entry(const char *filename, 750static int do_bcma_entry(const char *filename,
@@ -719,6 +763,7 @@ static int do_bcma_entry(const char *filename,
719 add_wildcard(alias); 763 add_wildcard(alias);
720 return 1; 764 return 1;
721} 765}
766ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry);
722 767
723/* Looks like: virtio:dNvN */ 768/* Looks like: virtio:dNvN */
724static int do_virtio_entry(const char *filename, struct virtio_device_id *id, 769static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
@@ -734,6 +779,29 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
734 add_wildcard(alias); 779 add_wildcard(alias);
735 return 1; 780 return 1;
736} 781}
782ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry);
783
784/*
785 * Looks like: vmbus:guid
786 * Each byte of the guid will be represented by two hex characters
787 * in the name.
788 */
789
790static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id,
791 char *alias)
792{
793 int i;
794 char guid_name[((sizeof(id->guid) + 1)) * 2];
795
796 for (i = 0; i < (sizeof(id->guid) * 2); i += 2)
797 sprintf(&guid_name[i], "%02x", id->guid[i/2]);
798
799 strcpy(alias, "vmbus:");
800 strcat(alias, guid_name);
801
802 return 1;
803}
804ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry);
737 805
738/* Looks like: i2c:S */ 806/* Looks like: i2c:S */
739static int do_i2c_entry(const char *filename, struct i2c_device_id *id, 807static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
@@ -743,6 +811,7 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
743 811
744 return 1; 812 return 1;
745} 813}
814ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry);
746 815
747/* Looks like: spi:S */ 816/* Looks like: spi:S */
748static int do_spi_entry(const char *filename, struct spi_device_id *id, 817static int do_spi_entry(const char *filename, struct spi_device_id *id,
@@ -752,6 +821,17 @@ static int do_spi_entry(const char *filename, struct spi_device_id *id,
752 821
753 return 1; 822 return 1;
754} 823}
824ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry);
825
826/* Looks like: mcp:S */
827static int do_mcp_entry(const char *filename, struct mcp_device_id *id,
828 char *alias)
829{
830 sprintf(alias, MCP_MODULE_PREFIX "%s", id->name);
831
832 return 1;
833}
834ADD_TO_DEVTABLE("mcp", struct mcp_device_id, do_mcp_entry);
755 835
756static const struct dmifield { 836static const struct dmifield {
757 const char *prefix; 837 const char *prefix;
@@ -806,6 +886,7 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
806 strcat(alias, ":"); 886 strcat(alias, ":");
807 return 1; 887 return 1;
808} 888}
889ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry);
809 890
810static int do_platform_entry(const char *filename, 891static int do_platform_entry(const char *filename,
811 struct platform_device_id *id, char *alias) 892 struct platform_device_id *id, char *alias)
@@ -813,6 +894,7 @@ static int do_platform_entry(const char *filename,
813 sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); 894 sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name);
814 return 1; 895 return 1;
815} 896}
897ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry);
816 898
817static int do_mdio_entry(const char *filename, 899static int do_mdio_entry(const char *filename,
818 struct mdio_device_id *id, char *alias) 900 struct mdio_device_id *id, char *alias)
@@ -835,6 +917,7 @@ static int do_mdio_entry(const char *filename,
835 917
836 return 1; 918 return 1;
837} 919}
920ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry);
838 921
839/* Looks like: zorro:iN. */ 922/* Looks like: zorro:iN. */
840static int do_zorro_entry(const char *filename, struct zorro_device_id *id, 923static int do_zorro_entry(const char *filename, struct zorro_device_id *id,
@@ -845,6 +928,7 @@ static int do_zorro_entry(const char *filename, struct zorro_device_id *id,
845 ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); 928 ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id);
846 return 1; 929 return 1;
847} 930}
931ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry);
848 932
849/* looks like: "pnp:dD" */ 933/* looks like: "pnp:dD" */
850static int do_isapnp_entry(const char *filename, 934static int do_isapnp_entry(const char *filename,
@@ -858,16 +942,84 @@ static int do_isapnp_entry(const char *filename,
858 (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); 942 (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f);
859 return 1; 943 return 1;
860} 944}
945ADD_TO_DEVTABLE("isa", struct isapnp_device_id, do_isapnp_entry);
946
947/*
948 * Append a match expression for a single masked hex digit.
949 * outp points to a pointer to the character at which to append.
950 * *outp is updated on return to point just after the appended text,
951 * to facilitate further appending.
952 */
953static void append_nibble_mask(char **outp,
954 unsigned int nibble, unsigned int mask)
955{
956 char *p = *outp;
957 unsigned int i;
958
959 switch (mask) {
960 case 0:
961 *p++ = '?';
962 break;
963
964 case 0xf:
965 p += sprintf(p, "%X", nibble);
966 break;
967
968 default:
969 /*
970 * Dumbly emit a match pattern for all possible matching
971 * digits. This could be improved in some cases using ranges,
972 * but it has the advantage of being trivially correct, and is
973 * often optimal.
974 */
975 *p++ = '[';
976 for (i = 0; i < 0x10; i++)
977 if ((i & mask) == nibble)
978 p += sprintf(p, "%X", i);
979 *p++ = ']';
980 }
981
982 /* Ensure that the string remains NUL-terminated: */
983 *p = '\0';
984
985 /* Advance the caller's end-of-string pointer: */
986 *outp = p;
987}
988
989/*
990 * looks like: "amba:dN"
991 *
992 * N is exactly 8 digits, where each is an upper-case hex digit, or
993 * a ? or [] pattern matching exactly one digit.
994 */
995static int do_amba_entry(const char *filename,
996 struct amba_id *id, char *alias)
997{
998 unsigned int digit;
999 char *p = alias;
1000
1001 if ((id->id & id->mask) != id->id)
1002 fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: "
1003 "id=0x%08X, mask=0x%08X. Please fix this driver.\n",
1004 filename, id->id, id->mask);
1005
1006 p += sprintf(alias, "amba:d");
1007 for (digit = 0; digit < 8; digit++)
1008 append_nibble_mask(&p,
1009 (id->id >> (4 * (7 - digit))) & 0xf,
1010 (id->mask >> (4 * (7 - digit))) & 0xf);
1011
1012 return 1;
1013}
1014ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry);
861 1015
862/* Ignore any prefix, eg. some architectures prepend _ */ 1016/* Does namelen bytes of name exactly match the symbol? */
863static inline int sym_is(const char *symbol, const char *name) 1017static bool sym_is(const char *name, unsigned namelen, const char *symbol)
864{ 1018{
865 const char *match; 1019 if (namelen != strlen(symbol))
1020 return false;
866 1021
867 match = strstr(symbol, name); 1022 return memcmp(name, symbol, namelen) == 0;
868 if (!match)
869 return 0;
870 return match[strlen(name)] == '\0';
871} 1023}
872 1024
873static void do_table(void *symval, unsigned long size, 1025static void do_table(void *symval, unsigned long size,
@@ -900,11 +1052,25 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
900{ 1052{
901 void *symval; 1053 void *symval;
902 char *zeros = NULL; 1054 char *zeros = NULL;
1055 const char *name;
1056 unsigned int namelen;
903 1057
904 /* We're looking for a section relative symbol */ 1058 /* We're looking for a section relative symbol */
905 if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) 1059 if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)
906 return; 1060 return;
907 1061
1062 /* All our symbols are of form <prefix>__mod_XXX_device_table. */
1063 name = strstr(symname, "__mod_");
1064 if (!name)
1065 return;
1066 name += strlen("__mod_");
1067 namelen = strlen(name);
1068 if (namelen < strlen("_device_table"))
1069 return;
1070 if (strcmp(name + namelen - strlen("_device_table"), "_device_table"))
1071 return;
1072 namelen -= strlen("_device_table");
1073
908 /* Handle all-NULL symbols allocated into .bss */ 1074 /* Handle all-NULL symbols allocated into .bss */
909 if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { 1075 if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) {
910 zeros = calloc(1, sym->st_size); 1076 zeros = calloc(1, sym->st_size);
@@ -915,113 +1081,24 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
915 + sym->st_value; 1081 + sym->st_value;
916 } 1082 }
917 1083
918 if (sym_is(symname, "__mod_pci_device_table")) 1084 /* First handle the "special" cases */
919 do_table(symval, sym->st_size, 1085 if (sym_is(name, namelen, "usb"))
920 sizeof(struct pci_device_id), "pci",
921 do_pci_entry, mod);
922 else if (sym_is(symname, "__mod_usb_device_table"))
923 /* special case to handle bcdDevice ranges */
924 do_usb_table(symval, sym->st_size, mod); 1086 do_usb_table(symval, sym->st_size, mod);
925 else if (sym_is(symname, "__mod_hid_device_table")) 1087 else if (sym_is(name, namelen, "pnp"))
926 do_table(symval, sym->st_size,
927 sizeof(struct hid_device_id), "hid",
928 do_hid_entry, mod);
929 else if (sym_is(symname, "__mod_ieee1394_device_table"))
930 do_table(symval, sym->st_size,
931 sizeof(struct ieee1394_device_id), "ieee1394",
932 do_ieee1394_entry, mod);
933 else if (sym_is(symname, "__mod_ccw_device_table"))
934 do_table(symval, sym->st_size,
935 sizeof(struct ccw_device_id), "ccw",
936 do_ccw_entry, mod);
937 else if (sym_is(symname, "__mod_ap_device_table"))
938 do_table(symval, sym->st_size,
939 sizeof(struct ap_device_id), "ap",
940 do_ap_entry, mod);
941 else if (sym_is(symname, "__mod_css_device_table"))
942 do_table(symval, sym->st_size,
943 sizeof(struct css_device_id), "css",
944 do_css_entry, mod);
945 else if (sym_is(symname, "__mod_serio_device_table"))
946 do_table(symval, sym->st_size,
947 sizeof(struct serio_device_id), "serio",
948 do_serio_entry, mod);
949 else if (sym_is(symname, "__mod_acpi_device_table"))
950 do_table(symval, sym->st_size,
951 sizeof(struct acpi_device_id), "acpi",
952 do_acpi_entry, mod);
953 else if (sym_is(symname, "__mod_pnp_device_table"))
954 do_pnp_device_entry(symval, sym->st_size, mod); 1088 do_pnp_device_entry(symval, sym->st_size, mod);
955 else if (sym_is(symname, "__mod_pnp_card_device_table")) 1089 else if (sym_is(name, namelen, "pnp_card"))
956 do_pnp_card_entries(symval, sym->st_size, mod); 1090 do_pnp_card_entries(symval, sym->st_size, mod);
957 else if (sym_is(symname, "__mod_pcmcia_device_table")) 1091 else {
958 do_table(symval, sym->st_size, 1092 struct devtable **p;
959 sizeof(struct pcmcia_device_id), "pcmcia", 1093
960 do_pcmcia_entry, mod); 1094 for (p = __start___devtable; p < __stop___devtable; p++) {
961 else if (sym_is(symname, "__mod_of_device_table")) 1095 if (sym_is(name, namelen, (*p)->device_id)) {
962 do_table(symval, sym->st_size, 1096 do_table(symval, sym->st_size, (*p)->id_size,
963 sizeof(struct of_device_id), "of", 1097 (*p)->device_id, (*p)->function, mod);
964 do_of_entry, mod); 1098 break;
965 else if (sym_is(symname, "__mod_vio_device_table")) 1099 }
966 do_table(symval, sym->st_size, 1100 }
967 sizeof(struct vio_device_id), "vio", 1101 }
968 do_vio_entry, mod);
969 else if (sym_is(symname, "__mod_input_device_table"))
970 do_table(symval, sym->st_size,
971 sizeof(struct input_device_id), "input",
972 do_input_entry, mod);
973 else if (sym_is(symname, "__mod_eisa_device_table"))
974 do_table(symval, sym->st_size,
975 sizeof(struct eisa_device_id), "eisa",
976 do_eisa_entry, mod);
977 else if (sym_is(symname, "__mod_parisc_device_table"))
978 do_table(symval, sym->st_size,
979 sizeof(struct parisc_device_id), "parisc",
980 do_parisc_entry, mod);
981 else if (sym_is(symname, "__mod_sdio_device_table"))
982 do_table(symval, sym->st_size,
983 sizeof(struct sdio_device_id), "sdio",
984 do_sdio_entry, mod);
985 else if (sym_is(symname, "__mod_ssb_device_table"))
986 do_table(symval, sym->st_size,
987 sizeof(struct ssb_device_id), "ssb",
988 do_ssb_entry, mod);
989 else if (sym_is(symname, "__mod_bcma_device_table"))
990 do_table(symval, sym->st_size,
991 sizeof(struct bcma_device_id), "bcma",
992 do_bcma_entry, mod);
993 else if (sym_is(symname, "__mod_virtio_device_table"))
994 do_table(symval, sym->st_size,
995 sizeof(struct virtio_device_id), "virtio",
996 do_virtio_entry, mod);
997 else if (sym_is(symname, "__mod_i2c_device_table"))
998 do_table(symval, sym->st_size,
999 sizeof(struct i2c_device_id), "i2c",
1000 do_i2c_entry, mod);
1001 else if (sym_is(symname, "__mod_spi_device_table"))
1002 do_table(symval, sym->st_size,
1003 sizeof(struct spi_device_id), "spi",
1004 do_spi_entry, mod);
1005 else if (sym_is(symname, "__mod_dmi_device_table"))
1006 do_table(symval, sym->st_size,
1007 sizeof(struct dmi_system_id), "dmi",
1008 do_dmi_entry, mod);
1009 else if (sym_is(symname, "__mod_platform_device_table"))
1010 do_table(symval, sym->st_size,
1011 sizeof(struct platform_device_id), "platform",
1012 do_platform_entry, mod);
1013 else if (sym_is(symname, "__mod_mdio_device_table"))
1014 do_table(symval, sym->st_size,
1015 sizeof(struct mdio_device_id), "mdio",
1016 do_mdio_entry, mod);
1017 else if (sym_is(symname, "__mod_zorro_device_table"))
1018 do_table(symval, sym->st_size,
1019 sizeof(struct zorro_device_id), "zorro",
1020 do_zorro_entry, mod);
1021 else if (sym_is(symname, "__mod_isapnp_device_table"))
1022 do_table(symval, sym->st_size,
1023 sizeof(struct isapnp_device_id), "isa",
1024 do_isapnp_entry, mod);
1025 free(zeros); 1102 free(zeros);
1026} 1103}
1027 1104
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a509ff8f32fa..2bd594e6d1b4 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1849,6 +1849,12 @@ static void add_header(struct buffer *b, struct module *mod)
1849 buf_printf(b, "};\n"); 1849 buf_printf(b, "};\n");
1850} 1850}
1851 1851
1852static void add_intree_flag(struct buffer *b, int is_intree)
1853{
1854 if (is_intree)
1855 buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
1856}
1857
1852static void add_staging_flag(struct buffer *b, const char *name) 1858static void add_staging_flag(struct buffer *b, const char *name)
1853{ 1859{
1854 static const char *staging_dir = "drivers/staging"; 1860 static const char *staging_dir = "drivers/staging";
@@ -2169,6 +2175,7 @@ int main(int argc, char **argv)
2169 buf.pos = 0; 2175 buf.pos = 0;
2170 2176
2171 add_header(&buf, mod); 2177 add_header(&buf, mod);
2178 add_intree_flag(&buf, !external_module);
2172 add_staging_flag(&buf, mod->name); 2179 add_staging_flag(&buf, mod->name);
2173 err |= add_versions(&buf, mod); 2180 err |= add_versions(&buf, mod);
2174 add_depends(&buf, mod, modules); 2181 add_depends(&buf, mod, modules);
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index bc6aa003860e..87bf08076b11 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -141,7 +141,7 @@ perf-%pkg: FORCE
141help: FORCE 141help: FORCE
142 @echo ' rpm-pkg - Build both source and binary RPM kernel packages' 142 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
143 @echo ' binrpm-pkg - Build only the binary kernel package' 143 @echo ' binrpm-pkg - Build only the binary kernel package'
144 @echo ' deb-pkg - Build the kernel as an deb package' 144 @echo ' deb-pkg - Build the kernel as a deb package'
145 @echo ' tar-pkg - Build the kernel as an uncompressed tarball' 145 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
146 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' 146 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
147 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' 147 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index f40a6af6bf40..54e35c1e5948 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -462,7 +462,7 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
462 succeed_file(); 462 succeed_file();
463 } 463 }
464 if (w(txthdr->sh_type) != SHT_PROGBITS || 464 if (w(txthdr->sh_type) != SHT_PROGBITS ||
465 !(w(txthdr->sh_flags) & SHF_EXECINSTR)) 465 !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
466 return NULL; 466 return NULL;
467 return txtname; 467 return txtname;
468} 468}
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 75c5d24f1993..38f6617a2cb1 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -129,7 +129,7 @@ exuberant()
129 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 129 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
130 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ 130 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
131 --extra=+f --c-kinds=+px \ 131 --extra=+f --c-kinds=+px \
132 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ 132 --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \
133 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ 133 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \
134 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ 134 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \
135 --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' 135 --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/'
@@ -151,7 +151,7 @@ exuberant()
151emacs() 151emacs()
152{ 152{
153 all_sources | xargs $1 -a \ 153 all_sources | xargs $1 -a \
154 --regex='/^ENTRY(\([^)]*\)).*/\1/' \ 154 --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \
155 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ 155 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \
156 --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ 156 --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \
157 --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' 157 --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/'