VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700   1) #!/usr/bin/perl -w
b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100   2) # SPDX-License-Identifier: GPL-2.0
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700   3) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700   4) use strict;
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800   5) use Getopt::Long qw(:config no_auto_abbrev);
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800   6) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800   7) my $input_file = "MAINTAINERS";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800   8) my $output_file = "MAINTAINERS.new";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800   9) my $output_section = "SECTION.new";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  10) my $help = 0;
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  11) my $order = 0;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700  12) my $P = $0;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  13) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  14) if (!GetOptions(
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  15) 		'input=s' => \$input_file,
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  16) 		'output=s' => \$output_file,
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  17) 		'section=s' => \$output_section,
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  18) 		'order!' => \$order,
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  19) 		'h|help|usage' => \$help,
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  20) 	    )) {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  21)     die "$P: invalid argument - use --help if necessary\n";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  22) }
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  23) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  24) if ($help != 0) {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  25)     usage();
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  26)     exit 0;
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  27) }
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  28) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  29) sub usage {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  30)     print <<EOT;
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  31) usage: $P [options] <pattern matching regexes>
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  32) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  33)   --input => MAINTAINERS file to read (default: MAINTAINERS)
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  34)   --output => sorted MAINTAINERS file to write (default: MAINTAINERS.new)
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  35)   --section => new sorted MAINTAINERS file to write to (default: SECTION.new)
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  36)   --order => Use the preferred section content output ordering (default: 0)
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  37)     Preferred ordering of section output is:
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  38)       M:  Person acting as a maintainer
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  39)       R:  Person acting as a patch reviewer
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  40)       L:  Mailing list where patches should be sent
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  41)       S:  Maintenance status
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  42)       W:  URI for general information
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  43)       Q:  URI for patchwork tracking
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  44)       B:  URI for bug tracking/submission
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  45)       C:  URI for chat
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  46)       P:  URI or file for subsystem specific coding styles
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  47)       T:  SCM tree type and location
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  48)       F:  File and directory pattern
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  49)       X:  File and directory exclusion pattern
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  50)       N:  File glob
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  51)       K:  Keyword - patch content regex
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  52) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  53) If <pattern match regexes> exist, then the sections that match the
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  54) regexes are not written to the output file but are written to the
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  55) section file.
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  56) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  57) EOT
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  58) }
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800  59) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  60) # sort comparison functions
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  61) sub by_category($$) {
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  62)     my ($a, $b) = @_;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  63) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  64)     $a = uc $a;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  65)     $b = uc $b;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  66) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  67)     # This always sorts last
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  68)     $a =~ s/THE REST/ZZZZZZ/g;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  69)     $b =~ s/THE REST/ZZZZZZ/g;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  70) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  71)     return $a cmp $b;
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  72) }
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  73) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  74) sub by_pattern($$) {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  75)     my ($a, $b) = @_;
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800  76)     my $preferred_order = 'MRLSWQBCPTFXNK';
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  77) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  78)     my $a1 = uc(substr($a, 0, 1));
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  79)     my $b1 = uc(substr($b, 0, 1));
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  80) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  81)     my $a_index = index($preferred_order, $a1);
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  82)     my $b_index = index($preferred_order, $b1);
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  83) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  84)     $a_index = 1000 if ($a_index == -1);
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  85)     $b_index = 1000 if ($b_index == -1);
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  86) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  87)     if (($a1 =~ /^F$/ && $b1 =~ /^F$/) ||
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  88) 	($a1 =~ /^X$/ && $b1 =~ /^X$/)) {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  89) 	return $a cmp $b;
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  90)     }
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  91) 
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  92)     if ($a_index < $b_index) {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  93) 	return -1;
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  94)     } elsif ($a_index == $b_index) {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  95) 	return 0;
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  96)     } else {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  97) 	return 1;
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700  98)     }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700  99) }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 100) 
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 101) sub trim {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 102)     my $s = shift;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 103)     $s =~ s/\s+$//;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 104)     $s =~ s/^\s+//;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 105)     return $s;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 106) }
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 107) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 108) sub alpha_output {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 109)     my ($hashref, $filename) = (@_);
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 110) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 111)     return if ! scalar(keys %$hashref);
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 112) 
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 113)     open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 114)     my $separator;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 115)     foreach my $key (sort by_category keys %$hashref) {
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700 116) 	if ($key eq " ") {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 117) 	    print $file $$hashref{$key};
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700 118) 	} else {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 119) 	    if (! defined $separator) {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 120) 		$separator = "\n";
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 121) 	    } else {
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 122) 		print $file $separator;
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 123) 	    }
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 124) 	    print $file $key . "\n";
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 125) 	    if ($order) {
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 126) 		foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) {
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 127) 		    print $file ($pattern . "\n");
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 128) 		}
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 129) 	    } else {
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 130) 		foreach my $pattern (split('\n', %$hashref{$key})) {
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 131) 		    print $file ($pattern . "\n");
5cdbec108fd21 (Joe Perches        2020-03-07 18:59:05 -0800 132) 		}
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700 133) 	    }
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700 134) 	}
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 135)     }
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 136)     close($file);
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 137) }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 138) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 139) sub file_input {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 140)     my ($hashref, $filename) = (@_);
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 141) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 142)     my $lastline = "";
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 143)     my $case = " ";
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 144)     $$hashref{$case} = "";
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 145) 
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 146)     open(my $file, '<', "$filename") or die "$P: $filename: open failed - $!\n";
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 147) 
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 148)     while (<$file>) {
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 149)         my $line = $_;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 150) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 151)         # Pattern line?
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 152)         if ($line =~ m/^([A-Z]):\s*(.*)/) {
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 153)             $line = $1 . ":\t" . trim($2) . "\n";
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 154)             if ($lastline eq "") {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 155)                 $$hashref{$case} = $$hashref{$case} . $line;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 156)                 next;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 157)             }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 158)             $case = trim($lastline);
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 159)             exists $$hashref{$case} and die "Header '$case' already exists";
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 160)             $$hashref{$case} = $line;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 161)             $lastline = "";
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 162)             next;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 163)         }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 164) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 165)         if ($case eq " ") {
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 166)             $$hashref{$case} = $$hashref{$case} . $lastline;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 167)             $lastline = $line;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 168)             next;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 169)         }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 170)         trim($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 171)         $lastline = $line;
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 172)     }
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 173)     $$hashref{$case} = $$hashref{$case} . $lastline;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 174)     close($file);
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 175) }
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 176) 
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 177) my %hash;
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 178) my %new_hash;
fe9090301fed2 (Joe Perches        2017-08-05 18:45:48 -0700 179) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 180) file_input(\%hash, $input_file);
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 181) 
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 182) foreach my $type (@ARGV) {
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 183)     foreach my $key (keys %hash) {
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 184) 	if ($key =~ /$type/ || $hash{$key} =~ /$type/) {
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 185) 	    $new_hash{$key} = $hash{$key};
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 186) 	    delete $hash{$key};
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 187) 	}
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 188)     }
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 189) }
b95c29a20f070 (Joe Perches        2017-08-05 18:45:49 -0700 190) 
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 191) alpha_output(\%hash, $output_file);
1e6270d07cde9 (Joe Perches        2017-11-17 15:27:10 -0800 192) alpha_output(\%new_hash, $output_section);
61f741645a354 (Joe Perches        2017-08-05 18:45:47 -0700 193) 
7683e9e529258 (Linus Torvalds     2017-07-23 16:06:21 -0700 194) exit(0);