Skip to contentSkip to conversation

pmc551 remove unnecessary braces

PATCH In review Jiri Slaby 2 participants 3 messages Sep 18, 2006 – Sep 19, 2006 Memory technology devices (MTD)

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 2/4 pmc551 remove unnecessary braces

pmc551 remove unnecessary braces

---
commit f562d858f77d4a83f55cf7fa962cd4dbef3eb0d6
tree 4d9c7f60eb2fc8c4f708953d77c11113dcbc7489
parent 60ab613754650ef2972b3d35ac155e6b154046c6
author Jiri Slaby <[email protected]> Tue, 19 Sep 2006 00:31:58 +0200 committer Jiri Slaby <[email protected]> Tue, 19 Sep 2006 00:31:58 +0200

 drivers/mtd/devices/pmc551.c |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)
drivers/mtd/devices/pmc551.c +12 -19
index 6d4d5a4..0ee22ca 100644
@@ -137,11 +137,11 @@ #endif
 
 	pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr);
 
-	if (soff_hi == eoff_hi || mtd->size == priv->asize) {
+	if (soff_hi == eoff_hi || mtd->size == priv->asize)
 		/* The whole thing fits within one access, so just one shot
 		   will do it. */
 		memset(ptr, 0xff, instr->len);
-	} else {
+	else {
 		/* We have to do multiple writes to get all the data
 		   written. */
 		while (soff_hi != eoff_hi) {
@@ -366,9 +366,8 @@ #endif
 	u8 bcmd, counter;
 
 	/* Sanity Check */
-	if (!dev) {
+	if (!dev)
 		return -ENODEV;
-	}
 
 	/*
 	 * Attempt to reset the card
@@ -383,14 +382,12 @@ #endif
 	for (i = 0; i < 10; i++) {
 		counter = 0;
 		bcmd &= ~0x80;
-		while (counter++ < 100) {
+		while (counter++ < 100)
 			pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
-		}
 		counter = 0;
 		bcmd |= 0x80;
-		while (counter++ < 100) {
+		while (counter++ < 100)
 			pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
-		}
 	}
 	bcmd |= (0x40 | 0x20);
 	pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
@@ -461,14 +458,12 @@ #else
 	/*
 	 * Oops .. something went wrong
 	 */
-	if ((size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) {
+	if ((size &= PCI_BASE_ADDRESS_MEM_MASK) == 0)
 		return -ENODEV;
-	}
 #endif				/* CONFIG_MTD_PMC551_BUGFIX */
 
-	if ((cfg & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) {
+	if ((cfg & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY)
 		return -ENODEV;
-	}
 
 	/*
 	 * Precharge Dram
@@ -700,9 +695,8 @@ static int __init init_pmc551(void)
 
 		if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI,
 						  PCI_DEVICE_ID_V3_SEMI_V370PDC,
-						  PCI_Device)) == NULL) {
+						  PCI_Device)) == NULL)
 			break;
-		}
 
 		printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n",
 			(unsigned long long)PCI_Device->resource[0].start);
@@ -728,9 +722,8 @@ static int __init init_pmc551(void)
 			length = msize;
 			printk(KERN_NOTICE "pmc551: Using specified memory "
 				"size 0x%x\n", length);
-		} else {
+		} else
 			msize = length;
-		}
 
 		mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
 		if (!mtd) {
@@ -829,10 +822,10 @@ #endif
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");
 		return -ENODEV;
-	} else {
-		printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found);
-		return 0;
 	}
+
+	printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found);
+	return 0;
 }
 
 /*
#1 lore raw
Quoted 9 lines · Jiri Slaby
drivers/mtd/devices/pmc551.c +0 -0
index 6d4d5a4..0ee22ca 100644
@@ -137,11 +137,11 @@ #endif
 
 	pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr);
 

drivers/mtd/devices/pmc551.c #endif · line 147

Quoted 10 lines
drivers/mtd/devices/pmc551.c +2 -2
-	if (soff_hi == eoff_hi || mtd->size == priv->asize) {
+	if (soff_hi == eoff_hi || mtd->size == priv->asize)
 		/* The whole thing fits within one access, so just one shot
 		   will do it. */
 		memset(ptr, 0xff, instr->len);
-	} else {
+	else {
 		/* We have to do multiple writes to get all the data
 		   written. */
 		while (soff_hi != eoff_hi) {

I actually find this change to make the code less readable. Yes, the braces aren't technically necessary, but the else requires them, and the comment block before the memset makes this multi-line.

This whole patch is highly user preference, but I'd rather these braces stay.

drivers/mtd/devices/pmc551.c static int __init init_pmc551(void) · line 705

Quoted 8 lines
drivers/mtd/devices/pmc551.c +1 -2
@@ -700,9 +695,8 @@ static int __init init_pmc551(void)
 
 		if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI,
 						  PCI_DEVICE_ID_V3_SEMI_V370PDC,
-						  PCI_Device)) == NULL) {
+						  PCI_Device)) == NULL)
 			break;
-		}

1) If you're going for coding style, the assignment within the if condition needs to be moved outside of it.

2) If you're not going to fix 1, then leave the braces.

josh

author
#2 lore raw
Quoted 24 lines · Josh Boyer
Quoted 8 lines · Jiri Slaby
drivers/mtd/devices/pmc551.c +0 -0
index 6d4d5a4..0ee22ca 100644
@@ -137,11 +137,11 @@ #endif
 
 	pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr);
 

drivers/mtd/devices/pmc551.c #endif · line 147

Quoted 10 lines
drivers/mtd/devices/pmc551.c +2 -2
-	if (soff_hi == eoff_hi || mtd->size == priv->asize) {
+	if (soff_hi == eoff_hi || mtd->size == priv->asize)
 		/* The whole thing fits within one access, so just one shot
 		   will do it. */
 		memset(ptr, 0xff, instr->len);
-	} else {
+	else {
 		/* We have to do multiple writes to get all the data
 		   written. */
 		while (soff_hi != eoff_hi) {

I actually find this change to make the code less readable. Yes, the braces aren't technically necessary, but the else requires them, and the comment block before the memset makes this multi-line.

Quoted 2 lines

This whole patch is highly user preference, but I'd rather these braces stay.

Yes, I agree. This was one of my old patches stored on other PC, that I find now. The patch definitely makes it ugly.

Quoted 12 lines

drivers/mtd/devices/pmc551.c static int __init init_pmc551(void) · line 705

Quoted 8 lines
drivers/mtd/devices/pmc551.c +1 -2
@@ -700,9 +695,8 @@ static int __init init_pmc551(void)
 
 		if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI,
 						  PCI_DEVICE_ID_V3_SEMI_V370PDC,
-						  PCI_Device)) == NULL) {
+						  PCI_Device)) == NULL)
 			break;
-		}

1) If you're going for coding style, the assignment within the if condition needs to be moved outside of it.

Quoted 1 line

2) If you're not going to fix 1, then leave the braces.

1) is fine, I will do it, thanks for comments.

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E