Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

checkpatch: don't ask for asm/file.h to linux/file.h unconditionally

Currently checkpatch warns when asm/file.h is included and linux/file.h
exists. That conversion can be made when linux/file.h includes asm/file.h
which is not always the case.(See signal.h)

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Andy Whitcroft <apw@canonical.com>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Fabian Frederick and committed by
Linus Torvalds
0e212e0a ab7e23f3

+11 -7
+11 -7
scripts/checkpatch.pl
··· 4242 4242 } 4243 4243 } 4244 4244 4245 - #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) 4245 + # warn if <asm/foo.h> is #included and <linux/foo.h> is available and includes 4246 + # itself <asm/foo.h> (uses RAW line) 4246 4247 if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { 4247 4248 my $file = "$1.h"; 4248 4249 my $checkfile = "include/linux/$file"; ··· 4251 4250 $realfile ne $checkfile && 4252 4251 $1 !~ /$allowed_asm_includes/) 4253 4252 { 4254 - if ($realfile =~ m{^arch/}) { 4255 - CHK("ARCH_INCLUDE_LINUX", 4256 - "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); 4257 - } else { 4258 - WARN("INCLUDE_LINUX", 4259 - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); 4253 + my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`; 4254 + if ($asminclude > 0) { 4255 + if ($realfile =~ m{^arch/}) { 4256 + CHK("ARCH_INCLUDE_LINUX", 4257 + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); 4258 + } else { 4259 + WARN("INCLUDE_LINUX", 4260 + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); 4261 + } 4260 4262 } 4261 4263 } 4262 4264 }