checkpatch: add --fix option for INCLUDE_LINUX
PATCH 1/1 checkpatch: add --fix option for INCLUDE_LINUX
Provide fix option to INCLUDE_LINUX check to replace asm includes.
Macros of type:
#include <asm/percpu.h>
are corrected to:
#include <linux/percpu.h>
--- scripts/checkpatch.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +5 -2
@@ -5468,8 +5468,11 @@ sub process { CHK("ARCH_INCLUDE_LINUX", "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); } else { - WARN("INCLUDE_LINUX", - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + if (WARN("INCLUDE_LINUX", + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\<asm\/$file\>/\<linux\/$file\>/; + } } } }
Signature · 6 lines
2.27.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Joe Perches
maintainerQuoted 8 lines · Dwaipayan Ray
Provide fix option to
INCLUDE_LINUXcheck to replace asm includes.Macros of type:
#include <asm/percpu.h>are corrected to:
#include <linux/percpu.h>
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 5474
Quoted 10 lines
scripts/checkpatch.pl +4
-2@@ -5468,8 +5468,11 @@ sub process { CHK("ARCH_INCLUDE_LINUX", "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); } else { - WARN("INCLUDE_LINUX", - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + if (WARN("INCLUDE_LINUX", + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\<asm\/$file\>/\<linux\/$file\>/;
$file can include a slash.
e.g.: arch/arm/kernel/atags_parse.c:#include <asm/mach/arch.h>
Probably simpler to use /Q /E quoting.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 26 lines · Joe Perches
Quoted 8 lines · Dwaipayan Ray
Provide fix option to
INCLUDE_LINUXcheck to replace asm includes.Macros of type:
#include <asm/percpu.h>are corrected to:
#include <linux/percpu.h>[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
scripts/checkpatch.pl sub process { · line 5474
Quoted 10 lines
scripts/checkpatch.pl +4
-2@@ -5468,8 +5468,11 @@ sub process { CHK("ARCH_INCLUDE_LINUX", "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); } else { - WARN("INCLUDE_LINUX", - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); + if (WARN("INCLUDE_LINUX", + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\<asm\/$file\>/\<linux\/$file\>/;$file can include a slash.
Quoted 5 lines
e.g.: arch/arm/kernel/atags_parse.c:#include <
asm/mach/arch.h>Probably simpler to use /Q /E quoting.
Thanks. I will do that.
Regards,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees