It is much more likely that an architecture file will want to directly include asm header files. Reduce this WARNING to a CHECK when the referencing file is in the arch directory.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -1942,12 +1942,17 @@ sub process { · 1941 unmodified lines | ||
| 1942 | 1942 | |
| 1943 | 1943 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) |
| 1944 | 1944 | if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { |
| 1945 | − my $checkfile = "include/linux/$1.h"; | |
| 1946 | − if (-f "$root/$checkfile" && $realfile ne $checkfile && | |
| 1945 | + my $file = "$1.h"; | |
| 1946 | + my $checkfile = "include/linux/$file"; | |
| 1947 | + if (-f "$root/$checkfile" && | |
| 1948 | + $realfile ne $checkfile && | |
| 1947 | 1949 | $1 ne 'irq') |
| 1948 | 1950 | { |
| 1949 | − WARN("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . | |
| 1950 | − $herecurr); | |
| 1951 | + if ($realfile =~ m{^arch/}) { | |
| 1952 | + CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | |
| 1953 | + } else { | |
| 1954 | + WARN("Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | |
| 1955 | + } | |
| 1951 | 1956 | } |
| 1952 | 1957 | } |
| 1953 | 1958 | |