checkpatch: validate MODULE_LICENSE content
[linux-2.6-block.git] / scripts / checkpatch.pl
index dfeb553de798358da6ba66bf1f346d74602e81da..4cf4473ebf17cfc433c5ebc3e0d02e8567d9195f 100755 (executable)
@@ -5626,6 +5626,24 @@ sub process {
                                }
                        }
                }
+
+# validate content of MODULE_LICENSE against list from include/linux/module.h
+               if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) {
+                       my $extracted_string = get_quoted_string($line, $rawline);
+                       my $valid_licenses = qr{
+                                               GPL|
+                                               GPL\ v2|
+                                               GPL\ and\ additional\ rights|
+                                               Dual\ BSD/GPL|
+                                               Dual\ MIT/GPL|
+                                               Dual\ MPL/GPL|
+                                               Proprietary
+                                       }x;
+                       if ($extracted_string !~ /^"(?:$valid_licenses)"$/x) {
+                               WARN("MODULE_LICENSE",
+                                    "unknown module license " . $extracted_string . "\n" . $herecurr);
+                       }
+               }
        }
 
        # If we have no input at all, then there is nothing to report on