Skip to contentSkip to conversation

xHCI:Fixing xhci_readl definition and function call

v4:No,Change In review Sarah Sharp 2 participants 5 messages Sep 3, 2013 – Sep 5, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 5223383f.hCMXrpqEq1AlVw9b%[email protected]

#1 lore raw
Quoted 11 lines · Wang Shilong

Hello, Using checkpatch.pl, i get the following warnings(errors):
WARNING: Avoid CamelCase: <port_array[wIndex]>
#272: FILE: drivers/usb/host/xhci-hub.c:725:

(quoted diff) +1 -0
+		temp = xhci_readl(port_array[wIndex]);

total: 0 errors, 1 warnings, 826 lines checked

patch has style problems, please review.

If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Ignore this warning. The variable is called wIndex because it corresponds to a field in a USB control transfer, and that's what it's called in the spec. In this case, wIndex is the index into the hub's port array, so it's perfectly valid to use it as an array index here.

In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. If it's a variable that already present in USB code, it's probably used to match the spec.

Sarah Sharp

maintainer
#2 lore raw

PATCH 1/1 checkpatch: Extend CamelCase types and ignore existing CamelCase uses in a patch

Extend the CamelCase words found to include structure members.

In https://lkml.org/lkml/2013/9/3/318 Sarah Sharp (mostly) wrote:

"In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. Otherwise, [] ignore it."

So, if checking a patch, scan the original patched file if it's available and add any preexisting CamelCase types so reuses do not generate CamelCase messages.

That also means Andrew's not so cruelly spurned anymore.
https://lkml.org/lkml/2013/2/22/426

---
 scripts/checkpatch.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +10 -2
index 9ba4fc4..b98a996 100755
@@ -424,7 +424,7 @@ sub seed_camelcase_file {
 		if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
 			$camelcase{$1} = 1;
 		}
-	        elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) {
+	        elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
 			$camelcase{$1} = 1;
 		}
 	}
@@ -1593,6 +1593,8 @@ sub process {
 	my @setup_docs = ();
 	my $setup_docs = 0;
 
+	my $camelcase_file_seeded = 0;
+
 	sanitise_line_reset();
 	my $line;
 	foreach my $rawline (@rawlines) {
@@ -3377,7 +3379,13 @@ sub process {
 				while ($var =~ m{($Ident)}g) {
 					my $word = $1;
 					next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
-					seed_camelcase_includes() if ($check);
+					if ($check) {
+						seed_camelcase_includes();
+						if (!$file && !$camelcase_file_seeded) {
+							seed_camelcase_file($realfile);
+							$camelcase_file_seeded = 1;
+						}
+					}
 					if (!defined $camelcase{$word}) {
 						$camelcase{$word} = 1;
 						CHK("CAMELCASE",
#3 lore raw

Re: [PATCH] checkpatch: Extend CamelCase types and ignore existing CamelCase uses in a patch

Quoted 12 lines · Joe Perches

Extend the CamelCase words found to include structure members.

In https://lkml.org/lkml/2013/9/3/318 Sarah Sharp (mostly) wrote:

"In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. Otherwise, [] ignore it."

So, if checking a patch, scan the original patched file if it's available and add any preexisting CamelCase types so reuses do not generate CamelCase messages.

Quoted 6 lines

That also means Andrew's not so cruelly spurned anymore.
https://lkml.org/lkml/2013/2/22/426

Thanks! Will this mean checkpatch.pl still complains on CamelCase names if it's run against a file? I think that's still valuable.

Sarah Sharp

Quoted 43 lines
---
 scripts/checkpatch.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +10 -2
index 9ba4fc4..b98a996 100755
@@ -424,7 +424,7 @@ sub seed_camelcase_file {
 		if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
 			$camelcase{$1} = 1;
 		}
-	        elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) {
+	        elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
 			$camelcase{$1} = 1;
 		}
 	}
@@ -1593,6 +1593,8 @@ sub process {
 	my @setup_docs = ();
 	my $setup_docs = 0;
 
+	my $camelcase_file_seeded = 0;
+
 	sanitise_line_reset();
 	my $line;
 	foreach my $rawline (@rawlines) {
@@ -3377,7 +3379,13 @@ sub process {
 				while ($var =~ m{($Ident)}g) {
 					my $word = $1;
 					next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
-					seed_camelcase_includes() if ($check);
+					if ($check) {
+						seed_camelcase_includes();
+						if (!$file && !$camelcase_file_seeded) {
+							seed_camelcase_file($realfile);
+							$camelcase_file_seeded = 1;
+						}
+					}
 					if (!defined $camelcase{$word}) {
 						$camelcase{$word} = 1;
 						CHK("CAMELCASE",
maintainer
#4 lore raw

Re: [PATCH] checkpatch: Extend CamelCase types and ignore existing CamelCase uses in a patch

(sending for 3rd time, odd dns problems today, apologies for dupes)

Quoted 5 lines · Sarah Sharp
Quoted 4 lines · Joe Perches

Extend the CamelCase words found to include structure members.

In https://lkml.org/lkml/2013/9/3/318 Sarah Sharp (mostly) wrote:

Quoted 7 lines
Quoted 7 lines

"In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. Otherwise, [] ignore it."

So, if checking a patch, scan the original patched file if it's available and add any preexisting CamelCase types so reuses do not generate CamelCase messages.

[]

Quoted 2 lines

Thanks! Will this mean checkpatch.pl still complains on CamelCase names if it's run against a file? I think that's still valuable.

Yes.

First, checkpatch looks for all existing CamelCase #defines, typedefs, function names and struct/union members in the include path. (it uses regexes so it's actually not at all close to even good at finding those).

It stores all those CamelCase uses in a hash.

If checkpatch is scanning a patch, it'll now read the file being patched for existing uses of CamelCase #defines, etc, and checkpatch adds those uses to the hash.

If checkpatch is scanning a file, it doesn't doesn't prescan the file.

Then, when checkpatch scans the patch or file and finds a CamelCase use, it looks for that use in the hash and is silent if it's there, noisy otherwise.

This can still report CamelCase uses in a patch if say a CamelCase type is defined in a .h file in the same directory or some other include path and that word is not already used by the file.

#5 lore raw

Re: [PATCH] checkpatch: Extend CamelCase types and ignore existing CamelCase uses in a patch

Quoted 35 lines · Joe Perches

(sending for 3rd time, odd dns problems today, apologies for dupes)

Quoted 5 lines · Sarah Sharp
Quoted 4 lines · Joe Perches

Extend the CamelCase words found to include structure members.

In https://lkml.org/lkml/2013/9/3/318 Sarah Sharp (mostly) wrote:

Quoted 7 lines
Quoted 7 lines

"In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. Otherwise, [] ignore it."

So, if checking a patch, scan the original patched file if it's available and add any preexisting CamelCase types so reuses do not generate CamelCase messages.

[]

Quoted 2 lines

Thanks! Will this mean checkpatch.pl still complains on CamelCase names if it's run against a file? I think that's still valuable.

Yes.

First, checkpatch looks for all existing CamelCase #defines, typedefs, function names and struct/union members in the include path. (it uses regexes so it's actually not at all close to even good at finding those).

It stores all those CamelCase uses in a hash.

If checkpatch is scanning a patch, it'll now read the file being patched for existing uses of CamelCase #defines, etc, and checkpatch adds those uses to the hash.

If checkpatch is scanning a file, it doesn't doesn't prescan the file.

Quoted 8 lines

Then, when checkpatch scans the patch or file and finds a CamelCase use, it looks for that use in the hash and is silent if it's there, noisy otherwise.

This can still report CamelCase uses in a patch if say a CamelCase type is defined in a .h file in the same directory or some other include path and that word is not already used by the file.

Great! Thanks for doing this Joe.

Sarah Sharp