* [PATCH v3] checkpatch: add --fix option to include linux checks
@ 2020-12-06 15:23 ` Dwaipayan Ray
0 siblings, 0 replies; 6+ messages in thread
From: Dwaipayan Ray @ 2020-12-06 15:23 UTC (permalink / raw)
To: joe; +Cc: linux-kernel-mentees, dwaipayanray1, linux-kernel, lukas.bulwahn
Add fix option to INCLUDE_LINUX and ARCH_INCLUDE_LINUX
checks to replace asm includes.
Macros of type:
#include <asm/percpu.h>
#include <asm/processor.h>
are corrected to:
#include <linux/percpu.h>
#include <linux/processor.h>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
Changes in v3:
- Add --fix option to ARCH_INCLUDE_LINUX check
Changes in v2:
- Use \Q..\E quoting
- Use @ as regex delimiter
scripts/checkpatch.pl | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7b086d1cd6c2..4aecc237ed38 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5558,11 +5558,17 @@ sub process {
my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
if ($asminclude > 0) {
if ($realfile =~ m{^arch/}) {
- CHK("ARCH_INCLUDE_LINUX",
- "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+ if (CHK("ARCH_INCLUDE_LINUX",
+ "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
+ }
} 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@\Q<asm/$file>\E@<linux/$file>@;
+ }
}
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Linux-kernel-mentees] [PATCH v3] checkpatch: add --fix option to include linux checks
@ 2020-12-06 15:23 ` Dwaipayan Ray
0 siblings, 0 replies; 6+ messages in thread
From: Dwaipayan Ray @ 2020-12-06 15:23 UTC (permalink / raw)
To: joe; +Cc: dwaipayanray1, linux-kernel-mentees, linux-kernel
Add fix option to INCLUDE_LINUX and ARCH_INCLUDE_LINUX
checks to replace asm includes.
Macros of type:
#include <asm/percpu.h>
#include <asm/processor.h>
are corrected to:
#include <linux/percpu.h>
#include <linux/processor.h>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
Changes in v3:
- Add --fix option to ARCH_INCLUDE_LINUX check
Changes in v2:
- Use \Q..\E quoting
- Use @ as regex delimiter
scripts/checkpatch.pl | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7b086d1cd6c2..4aecc237ed38 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5558,11 +5558,17 @@ sub process {
my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
if ($asminclude > 0) {
if ($realfile =~ m{^arch/}) {
- CHK("ARCH_INCLUDE_LINUX",
- "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+ if (CHK("ARCH_INCLUDE_LINUX",
+ "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
+ }
} 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@\Q<asm/$file>\E@<linux/$file>@;
+ }
}
}
}
--
2.27.0
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] checkpatch: add --fix option to include linux checks
2020-12-06 15:23 ` [Linux-kernel-mentees] " Dwaipayan Ray
@ 2020-12-09 9:17 ` Lukas Bulwahn
-1 siblings, 0 replies; 6+ messages in thread
From: Lukas Bulwahn @ 2020-12-09 9:17 UTC (permalink / raw)
To: Dwaipayan Ray
Cc: Joe Perches, linux-kernel-mentees, Linux Kernel Mailing List
On Sun, Dec 6, 2020 at 4:24 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> Add fix option to INCLUDE_LINUX and ARCH_INCLUDE_LINUX
> checks to replace asm includes.
>
> Macros of type:
> #include <asm/percpu.h>
> #include <asm/processor.h>
>
> are corrected to:
> #include <linux/percpu.h>
> #include <linux/processor.h>
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Dwaipayan, can you run this rule from checkpatch.pl on all files in
the current linux-next tree and share all findings with me?
Maybe, we can fix a few places and improve the rule.
Lukas
> ---
> Changes in v3:
> - Add --fix option to ARCH_INCLUDE_LINUX check
>
> Changes in v2:
> - Use \Q..\E quoting
> - Use @ as regex delimiter
>
> scripts/checkpatch.pl | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7b086d1cd6c2..4aecc237ed38 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5558,11 +5558,17 @@ sub process {
> my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
> if ($asminclude > 0) {
> if ($realfile =~ m{^arch/}) {
> - CHK("ARCH_INCLUDE_LINUX",
> - "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + if (CHK("ARCH_INCLUDE_LINUX",
> + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
> + $fix) {
> + $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
> + }
> } 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@\Q<asm/$file>\E@<linux/$file>@;
> + }
> }
> }
> }
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH v3] checkpatch: add --fix option to include linux checks
@ 2020-12-09 9:17 ` Lukas Bulwahn
0 siblings, 0 replies; 6+ messages in thread
From: Lukas Bulwahn @ 2020-12-09 9:17 UTC (permalink / raw)
To: Dwaipayan Ray
Cc: Joe Perches, linux-kernel-mentees, Linux Kernel Mailing List
On Sun, Dec 6, 2020 at 4:24 PM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> Add fix option to INCLUDE_LINUX and ARCH_INCLUDE_LINUX
> checks to replace asm includes.
>
> Macros of type:
> #include <asm/percpu.h>
> #include <asm/processor.h>
>
> are corrected to:
> #include <linux/percpu.h>
> #include <linux/processor.h>
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
Dwaipayan, can you run this rule from checkpatch.pl on all files in
the current linux-next tree and share all findings with me?
Maybe, we can fix a few places and improve the rule.
Lukas
> ---
> Changes in v3:
> - Add --fix option to ARCH_INCLUDE_LINUX check
>
> Changes in v2:
> - Use \Q..\E quoting
> - Use @ as regex delimiter
>
> scripts/checkpatch.pl | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7b086d1cd6c2..4aecc237ed38 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5558,11 +5558,17 @@ sub process {
> my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
> if ($asminclude > 0) {
> if ($realfile =~ m{^arch/}) {
> - CHK("ARCH_INCLUDE_LINUX",
> - "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + if (CHK("ARCH_INCLUDE_LINUX",
> + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr) &&
> + $fix) {
> + $fixed[$fixlinenr] =~ s@\Q<asm/$file>\E@<linux/$file>@;
> + }
> } 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@\Q<asm/$file>\E@<linux/$file>@;
> + }
> }
> }
> }
> --
> 2.27.0
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] checkpatch: add --fix option to include linux checks
2020-12-09 9:17 ` [Linux-kernel-mentees] " Lukas Bulwahn
@ 2020-12-09 15:22 ` Dwaipayan Ray
-1 siblings, 0 replies; 6+ messages in thread
From: Dwaipayan Ray @ 2020-12-09 15:22 UTC (permalink / raw)
To: Lukas Bulwahn
Cc: Joe Perches, linux-kernel-mentees, Linux Kernel Mailing List
> Dwaipayan, can you run this rule from checkpatch.pl on all files in
> the current linux-next tree and share all findings with me?
>
> Maybe, we can fix a few places and improve the rule.
>
> Lukas
>
Hi,
I am actually a bit confused here. I couldn't find any particular place in
documentation which demarcates where to include asm or linux headers.
As far as my understanding, include/linux headers are meant to be
architecture independent.
There are several places in the kernel tree which use the <asm/*> headers.
Checkpatch emits warnings for the following headers in kernel/ :
kernel/dma/swiotlb.c:43:#include <asm/io.h>
kernel/exit.c:69:#include <asm/mmu_context.h>
kernel/fork.c:103:#include <asm/mmu_context.h>
kernel/irq_work.c:21:#include <asm/processor.h>
kernel/module-internal.h:9:#include <asm/module.h>
kernel/module.c:45:#include <asm/mmu_context.h>
kernel/resource.c:27:#include <asm/io.h>
kernel/power/snapshot.c:36:#include <asm/mmu_context.h>
kernel/power/snapshot.c:38:#include <asm/io.h>
kernel/sys.c:73:#include <asm/io.h>
kernel/sysctl.c:78:#include <asm/processor.h>
kernel/sysctl.c:81:#include <asm/nmi.h>
kernel/sysctl.c:83:#include <asm/io.h>
kernel/time/timer.c:52:#include <asm/io.h>
drivers/ had yet a more number of such uses.
I am not entirely sure that changing them will break more stuff or not.
It would be great to have your opinions on this as experienced kernel
programmers.
Thank you,
Dwaipayan.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH v3] checkpatch: add --fix option to include linux checks
@ 2020-12-09 15:22 ` Dwaipayan Ray
0 siblings, 0 replies; 6+ messages in thread
From: Dwaipayan Ray @ 2020-12-09 15:22 UTC (permalink / raw)
To: Lukas Bulwahn
Cc: Joe Perches, linux-kernel-mentees, Linux Kernel Mailing List
> Dwaipayan, can you run this rule from checkpatch.pl on all files in
> the current linux-next tree and share all findings with me?
>
> Maybe, we can fix a few places and improve the rule.
>
> Lukas
>
Hi,
I am actually a bit confused here. I couldn't find any particular place in
documentation which demarcates where to include asm or linux headers.
As far as my understanding, include/linux headers are meant to be
architecture independent.
There are several places in the kernel tree which use the <asm/*> headers.
Checkpatch emits warnings for the following headers in kernel/ :
kernel/dma/swiotlb.c:43:#include <asm/io.h>
kernel/exit.c:69:#include <asm/mmu_context.h>
kernel/fork.c:103:#include <asm/mmu_context.h>
kernel/irq_work.c:21:#include <asm/processor.h>
kernel/module-internal.h:9:#include <asm/module.h>
kernel/module.c:45:#include <asm/mmu_context.h>
kernel/resource.c:27:#include <asm/io.h>
kernel/power/snapshot.c:36:#include <asm/mmu_context.h>
kernel/power/snapshot.c:38:#include <asm/io.h>
kernel/sys.c:73:#include <asm/io.h>
kernel/sysctl.c:78:#include <asm/processor.h>
kernel/sysctl.c:81:#include <asm/nmi.h>
kernel/sysctl.c:83:#include <asm/io.h>
kernel/time/timer.c:52:#include <asm/io.h>
drivers/ had yet a more number of such uses.
I am not entirely sure that changing them will break more stuff or not.
It would be great to have your opinions on this as experienced kernel
programmers.
Thank you,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-09 15:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 15:23 [PATCH v3] checkpatch: add --fix option to include linux checks Dwaipayan Ray
2020-12-06 15:23 ` [Linux-kernel-mentees] " Dwaipayan Ray
2020-12-09 9:17 ` Lukas Bulwahn
2020-12-09 9:17 ` [Linux-kernel-mentees] " Lukas Bulwahn
2020-12-09 15:22 ` Dwaipayan Ray
2020-12-09 15:22 ` [Linux-kernel-mentees] " Dwaipayan Ray
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.