Skip to contentSkip to conversation

Drivers:firewire: fix style errors in core-card.c This is a patch in the core-card.c file which fixes up 2 warnings found by the checkpatch.pl tool Signed-off-by: Sander Nemvalts <[email protected]>

PATCH In review Sander Nemvalts 3 participants 4 messages Sep 1, 2014 – Sep 2, 2014 1 message not in the archive Firewire

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers:firewire: fix style errors in core-card.c This is a patch in the core-card.c file which fixes up 2 warnings found by the checkpatch.pl tool Signed-off-by: Sander Nemvalts <[email protected]>

---
 drivers/firewire/core-card.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/firewire/core-card.c +5 -4
index 57ea7f4..825b260 100644
@@ -89,7 +89,8 @@ static size_t config_rom_length = 1 + 4 + 1 + 1;
 #define BIB_ISC			((1) << 29)
 #define BIB_CMC			((1) << 30)
 #define BIB_IRMC		((1) << 31)
-#define NODE_CAPABILITIES	0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */
+/* per IEEE 1394 clause 8.3.2.6.5.2 */
+#define NODE_CAPABILITIES	0x0c0083c0
 
 /*
  * IEEE-1394 specifies a default SPLIT_TIMEOUT value of 800 cycles (100 ms),
@@ -132,7 +133,7 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
 	j = 7 + descriptor_count;
 
 	/* Generate root directory entries for descriptors. */
-	list_for_each_entry (desc, &descriptor_list, link) {
+	list_for_each_entry(desc, &descriptor_list, link) {
 		if (desc->immediate > 0)
 			config_rom[i++] = cpu_to_be32(desc->immediate);
 		config_rom[i] = cpu_to_be32(desc->key | (j - i));
@@ -144,7 +145,7 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
 	config_rom[5] = cpu_to_be32((i - 5 - 1) << 16);
 
 	/* End of root directory, now copy in descriptors. */
-	list_for_each_entry (desc, &descriptor_list, link) {
+	list_for_each_entry(desc, &descriptor_list, link) {
 		for (k = 0; k < desc->length; k++)
 			config_rom[i + k] = cpu_to_be32(desc->data[k]);
 		i += desc->length;
@@ -164,7 +165,7 @@ static void update_config_roms(void)
 {
 	struct fw_card *card;
 
-	list_for_each_entry (card, &card_list, link) {
+	list_for_each_entry(card, &card_list, link) {
 		generate_config_rom(card, tmp_config_rom);
 		card->driver->set_config_rom(card, tmp_config_rom,
 					     config_rom_length);
Signature · 1 line
1.9.1
#1 lore raw

drivers/firewire/core-card.c static size_t config_rom_length = 1 + 4 + 1 + 1; · line 93

Quoted 9 lines · On Sep 01 Sander Nemvalts wrote:
drivers/firewire/core-card.c +2 -1
@@ -89,7 +89,8 @@ static size_t config_rom_length = 1 + 4 + 1 + 1;
 #define BIB_ISC			((1) << 29)
 #define BIB_CMC			((1) << 30)
 #define BIB_IRMC		((1) << 31)
-#define NODE_CAPABILITIES	0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */
+/* per IEEE 1394 clause 8.3.2.6.5.2 */
+#define NODE_CAPABILITIES	0x0c0083c0

This is no improvement.

drivers/firewire/core-card.c static void generate_config_rom(struct fw_card *card, __be32 *config_rom) · line 139

Quoted 11 lines
drivers/firewire/core-card.c +1 -1
 /*
  * IEEE-1394 specifies a default SPLIT_TIMEOUT value of 800 cycles (100 ms),
@@ -132,7 +133,7 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
 	j = 7 + descriptor_count;
 
 	/* Generate root directory entries for descriptors. */
-	list_for_each_entry (desc, &descriptor_list, link) {
+	list_for_each_entry(desc, &descriptor_list, link) {
 		if (desc->immediate > 0)
 			config_rom[i++] = cpu_to_be32(desc->immediate);
 		config_rom[i] = cpu_to_be32(desc->key | (j - i));

We are writing

	for (a; b; c);
not
	for(a; b; c);

and thus a space after list_for_each and friends makes sense.

Signature · 3 lines
Stefan Richter
-=====-====- =--= ----=
http://arcgraph.de/sr/
#2 lore raw

Quite a crowded subject line!

Quoted 12 lines · Stefan Richter

drivers/firewire/core-card.c static void generate_config_rom(struct fw_card *card, __be32 *config_rom) · line 139

Quoted 9 lines · On Sep 01 Sander Nemvalts wrote:
drivers/firewire/core-card.c +1 -1
@@ -132,7 +133,7 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
 	j = 7 + descriptor_count;
 
 	/* Generate root directory entries for descriptors. */
-	list_for_each_entry (desc, &descriptor_list, link) {
+	list_for_each_entry(desc, &descriptor_list, link) {
 		if (desc->immediate > 0)
 			config_rom[i++] = cpu_to_be32(desc->immediate);
 		config_rom[i] = cpu_to_be32(desc->key | (j - i));

We are writing

Quoted 4 lines
	for (a; b; c);
not
	for(a; b; c);

and thus a space after list_for_each and friends makes sense.

$ git grep "list_for_each_entry (" | wc -l
52
$ git grep "list_for_each_entry(" | wc -l
5991

So "list_for_each_entry(" (without space) seems to be the preferred style.

Paul Bolle

A message that is not in the archive (sent off-list or not yet received): CAAagr2=oG7dyKMBW0DZAJLDoW+2k=vFYADv-JVC6Q2sr7tEYcQ@mail.gmail.com

#4 lore raw

Folding two replies into one.

Quoted 15 lines · On Sep 02 Sander Nemvalts wrote:
Quoted 13 lines · Stefan Richter

drivers/firewire/core-card.c static size_t config_rom_length = 1 + 4 + 1 + 1; · line 93

Quoted 9 lines · On Sep 01 Sander Nemvalts wrote:
drivers/firewire/core-card.c +2 -1
@@ -89,7 +89,8 @@ static size_t config_rom_length = 1 + 4 + 1 + 1;
 #define BIB_ISC                      ((1) << 29)
 #define BIB_CMC                      ((1) << 30)
 #define BIB_IRMC             ((1) << 31)
-#define NODE_CAPABILITIES    0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */
+/* per IEEE 1394 clause 8.3.2.6.5.2 */
+#define NODE_CAPABILITIES    0x0c0083c0

This is no improvement.

Quoted 2 lines

The comment after NODE_CAPABILITIES was moved to front of statement because the line would otherwise be over 80 characters long.

There is no problem with this line's remaining 81 characters long.

Quoted 1 line

Also, commenting before the line is demonstrated in the next statement.

This block of statements is entirely unrelated to the next statement; furthermore the nature and form of this and the next comment are unrelated.

Quoted 18 lines · On Sep 02 Paul Bolle wrote:
Quoted 12 lines · Stefan Richter

drivers/firewire/core-card.c static void generate_config_rom(struct fw_card *card, __be32 *config_rom) · line 139

Quoted 9 lines · On Sep 01 Sander Nemvalts wrote:
drivers/firewire/core-card.c +1 -1
@@ -132,7 +133,7 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
 	j = 7 + descriptor_count;
 
 	/* Generate root directory entries for descriptors. */
-	list_for_each_entry (desc, &descriptor_list, link) {
+	list_for_each_entry(desc, &descriptor_list, link) {
 		if (desc->immediate > 0)
 			config_rom[i++] = cpu_to_be32(desc->immediate);
 		config_rom[i] = cpu_to_be32(desc->key | (j - i));

We are writing

Quoted 4 lines
	for (a; b; c);
not
	for(a; b; c);

and thus a space after list_for_each and friends makes sense.

Quoted 7 lines
$ git grep "list_for_each_entry (" | wc -l
52
$ git grep "list_for_each_entry(" | wc -l
5991

So "list_for_each_entry(" (without space) seems to be the preferred style.

'Seems to be' is an appropriate wording indeed, since grep shows occurrences, not preferences.

All,

here are some tips for whitespace changes and similar patches:

- As a general rule, do not propose style changes to code on which you are not working on.

- Do not propose style changes to code on which you are working on, unless you can significantly improve the code this way.

Rationale: Style changes (outside of drivers/staging/) tend to worsen rather than improve code. Style changes obfuscate code history. Style changes are of doubtfule value but create nonzero work for those who handle the code together with you or after you.

- checkpatch.pl is a help for you to evaluate stylistic conformance of your own new code submissions. Use checkpatch.pl for its original purpose.

Signature · 3 lines
Stefan Richter
-=====-====- =--= ---=-
http://arcgraph.de/sr/