mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] add some Blackfin specific checks to checkpatch.pl
@ 2007-08-21 22:29 Mike Frysinger
  2007-08-22  2:15 ` Mike Frysinger
  2007-09-13 11:55 ` Andy Whitcroft
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Frysinger @ 2007-08-21 22:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, bryan.wu, apw

Check for a few common errors in Blackfin-specific code wrt MMR loading in
assembly and doing core/system syncs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Bryan Wu <bryan.wu@analog.com>
CC: Andy Whitcroft <apw@shadowen.org>
---
 scripts/checkpatch.pl |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dae7d30..ead9675 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -486,9 +486,29 @@ sub process {
 			WARN("line over 80 characters\n" . $herecurr);
 		}
 
+# Blackfin: use hi/lo macros
+		if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
+		}
+		if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the HI() macro, not (... >> 16)\n" . $herevet);
+		}
+
 # check we are in a valid source file *.[hc] if not then ignore this hunk
 		next if ($realfile !~ /\.[hc]$/);
 
+# Blackfin: don't use __builtin_bfin_[cs]sync
+		if ($line =~ /__builtin_bfin_csync/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
+		}
+		if ($line =~ /__builtin_bfin_ssync/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
+		}
+
 # at the beginning of a line any tabs must come first and anything
 # more than 8 must use tabs.
 		if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s*        \s*/) {
-- 
1.5.3.rc5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] add some Blackfin specific checks to checkpatch.pl
  2007-08-21 22:29 [patch] add some Blackfin specific checks to checkpatch.pl Mike Frysinger
@ 2007-08-22  2:15 ` Mike Frysinger
  2007-09-13 11:55 ` Andy Whitcroft
  1 sibling, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2007-08-22  2:15 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, bryan.wu, apw

[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]

Check for a few common errors in Blackfin-specific code wrt MMR loading in
assembly and doing core/system syncs.  Restrict the Blackfin MMR checks to 
actual Blackfin assembly files as pointed out by Joe Perches.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Bryan Wu <bryan.wu@analog.com>
CC: Andy Whitcroft <apw@shadowen.org>
---
 scripts/checkpatch.pl |   22 ++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dae7d30..ead9675 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -486,9 +486,31 @@ sub process {
 			WARN("line over 80 characters\n" . $herecurr);
 		}
 
+# Blackfin: use hi/lo macros
+		if ($realfile =~ s@arch/blackfin/.*\.S$@) {
+			if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
+				my $herevet = "$here\n" . cat_vet($line) . "\n";
+				ERROR("use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
+			}
+			if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
+				my $herevet = "$here\n" . cat_vet($line) . "\n";
+				ERROR("use the HI() macro, not (... >> 16)\n" . $herevet);
+			}
+		}
+
 # check we are in a valid source file *.[hc] if not then ignore this hunk
 		next if ($realfile !~ /\.[hc]$/);
 
+# Blackfin: don't use __builtin_bfin_[cs]sync
+		if ($line =~ /__builtin_bfin_csync/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
+		}
+		if ($line =~ /__builtin_bfin_ssync/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
+		}
+
 # at the beginning of a line any tabs must come first and anything
 # more than 8 must use tabs.
 		if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s*        \s*/) {
-- 
1.5.3.rc5

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] add some Blackfin specific checks to checkpatch.pl
  2007-08-21 22:29 [patch] add some Blackfin specific checks to checkpatch.pl Mike Frysinger
  2007-08-22  2:15 ` Mike Frysinger
@ 2007-09-13 11:55 ` Andy Whitcroft
  2007-09-13 15:33   ` Mike Frysinger
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Whitcroft @ 2007-09-13 11:55 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Andrew Morton, LKML, bryan.wu

On Tue, Aug 21, 2007 at 06:29:59PM -0400, Mike Frysinger wrote:
> Check for a few common errors in Blackfin-specific code wrt MMR loading in
> assembly and doing core/system syncs.

If we are going to pull arch specific things into checkpatch I think we
need to make sure we are pretty specific about where we apply them.  I
am assuming these checks only make sense againt some files in the arch
tree?

-apw

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] add some Blackfin specific checks to checkpatch.pl
  2007-09-13 11:55 ` Andy Whitcroft
@ 2007-09-13 15:33   ` Mike Frysinger
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2007-09-13 15:33 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: Mike Frysinger, Andrew Morton, LKML, bryan.wu

On 9/13/07, Andy Whitcroft <apw@shadowen.org> wrote:
> On Tue, Aug 21, 2007 at 06:29:59PM -0400, Mike Frysinger wrote:
> > Check for a few common errors in Blackfin-specific code wrt MMR loading in
> > assembly and doing core/system syncs.
>
> If we are going to pull arch specific things into checkpatch I think we
> need to make sure we are pretty specific about where we apply them.  I
> am assuming these checks only make sense againt some files in the arch
> tree?

ive restricted the .S check to arch/blackfin/, but the other check
should be run on all .c files since Blackfin drivers may live anywhere
in the tree, not just in arch/ ... i really doubt that'd be a problem
unless another architecture starts implementing functions with
"__builtin_bfin_ssync" in its name ...

side note, Joe pointed out that arch/blackfin regex should be m@...@, not s@...@
-mike

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-13 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-21 22:29 [patch] add some Blackfin specific checks to checkpatch.pl Mike Frysinger
2007-08-22  2:15 ` Mike Frysinger
2007-09-13 11:55 ` Andy Whitcroft
2007-09-13 15:33   ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome