diff --git a/board/etx094/flash.c b/board/etx094/flash.c
index fa51c90..c1bd13c 100644
--- a/board/etx094/flash.c
+++ b/board/etx094/flash.c
@@ -24,19 +24,19 @@
 #include <common.h>
 #include <mpc8xx.h>
 
-flash_info_t	flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips	*/
+flash_info_t	flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
 
 /*-----------------------------------------------------------------------
  * Functions
  */
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
+static ulong flash_get_size(vu_long *addr, flash_info_t *info);
+static int write_word(flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets(ulong base, flash_info_t *info);
 
 /*-----------------------------------------------------------------------
  */
 
-unsigned long flash_init (void)
+unsigned long flash_init(void)
 {
 	volatile immap_t     *immap  = (immap_t *)CONFIG_SYS_IMMR;
 	volatile memctl8xx_t *memctl = &immap->im_memctl;
@@ -44,23 +44,22 @@
 	int i;
 
 	/* Init: no FLASHes known */
-	for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
+	for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
 		flash_info[i].flash_id = FLASH_UNKNOWN;
-	}
 
 	/* Static FLASH Bank configuration here - FIXME XXX */
 
 	size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
 
 	if (flash_info[0].flash_id == FLASH_UNKNOWN) {
-		printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
+		printf("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
 			size_b0, size_b0<<20);
 	}
 
 	size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
 
 	if (size_b1 > size_b0) {
-		printf ("## ERROR: "
+		printf("## ERROR: "
 			"Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
 			size_b1, size_b1<<20,
 			size_b0, size_b0<<20
@@ -71,21 +70,24 @@
 		flash_info[1].sector_count	= -1;
 		flash_info[0].size		= 0;
 		flash_info[1].size		= 0;
-		return (0);
+		return 0;
 	}
 
 	/* Remap FLASH according to real size */
 	memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b0 & 0xFFFF8000);
 #ifdef CONFIG_FLASH_16BIT
-	memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V | BR_PS_16; /* 16 Bit data port */
+	memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
+		BR_MS_GPCM | BR_V | BR_PS_16; /* 16 Bit data port */
 #else
-	memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
+	memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
+		BR_MS_GPCM | BR_V;
 #endif
 
 	/* Re-do sizing to get full correct info */
-	size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+	size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE,
+			&flash_info[0]);
 
-	flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+	flash_get_offsets(CONFIG_SYS_FLASH_BASE, &flash_info[0]);
 
 #if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
 	/* monitor protection ON by default */
@@ -96,20 +98,22 @@
 #endif
 
 	if (size_b1) {
-		memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b1 & 0xFFFF8000);
+		memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH |
+			(-size_b1 & 0xFFFF8000);
 #ifdef CONFIG_FLASH_16BIT
-		memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) & BR_BA_MSK) |
-				    BR_MS_GPCM | BR_V | BR_PS_16;
+		memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) &
+			BR_BA_MSK) | BR_MS_GPCM | BR_V | BR_PS_16;
 #else
-		memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) & BR_BA_MSK) |
-				    BR_MS_GPCM | BR_V;
+		memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) &
+			BR_BA_MSK) | BR_MS_GPCM | BR_V;
 #endif
 
 		/* Re-do sizing to get full correct info */
-		size_b1 = flash_get_size((vu_long *)(CONFIG_SYS_FLASH_BASE + size_b0),
-					  &flash_info[1]);
+		size_b1 = flash_get_size((vu_long *)(CONFIG_SYS_FLASH_BASE +
+				size_b0), &flash_info[1]);
 
-		flash_get_offsets (CONFIG_SYS_FLASH_BASE + size_b0, &flash_info[1]);
+		flash_get_offsets(CONFIG_SYS_FLASH_BASE + size_b0,
+				&flash_info[1]);
 
 #if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
 		/* monitor protection ON by default */
@@ -128,23 +132,22 @@
 	flash_info[0].size = size_b0;
 	flash_info[1].size = size_b1;
 
-	return (size_b0 + size_b1);
+	return size_b0 + size_b1;
 }
 
 /*-----------------------------------------------------------------------
  */
-static void flash_get_offsets (ulong base, flash_info_t *info)
+static void flash_get_offsets(ulong base, flash_info_t *info)
 {
 	int i;
 
-	if (info->flash_id == FLASH_UNKNOWN) {
+	if (info->flash_id == FLASH_UNKNOWN)
 		return;
-	}
 
 	if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
-		for (i = 0; i < info->sector_count; i++) {
+		for (i = 0; i < info->sector_count; i++)
 			info->start[i] = base + (i * 0x00002000);
-		}
+
 		return;
 	}
 
@@ -156,106 +159,119 @@
 		info->start[1] = base + 0x00004000;
 		info->start[2] = base + 0x00006000;
 		info->start[3] = base + 0x00008000;
-		for (i = 4; i < info->sector_count; i++) {
+		for (i = 4; i < info->sector_count; i++)
 			info->start[i] = base + (i * 0x00010000) - 0x00030000;
 #else
 		info->start[0] = base + 0x00000000;
 		info->start[1] = base + 0x00008000;
 		info->start[2] = base + 0x0000C000;
 		info->start[3] = base + 0x00010000;
-		for (i = 4; i < info->sector_count; i++) {
+		for (i = 4; i < info->sector_count; i++)
 			info->start[i] = base + (i * 0x00020000) - 0x00060000;
 #endif
-		}
 	} else {
 		/* set sector offsets for top boot block type		*/
 		i = info->sector_count - 1;
 		info->start[i--] = base + info->size - 0x00008000;
 		info->start[i--] = base + info->size - 0x0000C000;
 		info->start[i--] = base + info->size - 0x00010000;
-		for (; i >= 0; i--) {
+		for (; i >= 0; i--)
 			info->start[i] = base + i * 0x00020000;
-		}
 	}
-
 }
 
 /*-----------------------------------------------------------------------
  */
-void flash_print_info  (flash_info_t *info)
+void flash_print_info(flash_info_t *info)
 {
 	int i;
 
 	if (info->flash_id == FLASH_UNKNOWN) {
-		printf ("missing or unknown FLASH type\n");
+		printf("missing or unknown FLASH type\n");
 		return;
 	}
 
 	switch (info->flash_id & FLASH_VENDMASK) {
-	case FLASH_MAN_AMD:	printf ("AMD ");		break;
-	case FLASH_MAN_FUJ:	printf ("FUJITSU ");		break;
-	case FLASH_MAN_SST:	printf ("SST ");		break;
-	case FLASH_MAN_STM:	printf ("STM ");		break;
-	default:		printf ("Unknown Vendor ");	break;
+	case FLASH_MAN_AMD:
+		printf("AMD ");
+		break;
+	case FLASH_MAN_FUJ:
+		printf("FUJITSU ");
+		break;
+	case FLASH_MAN_SST:
+		printf("SST ");
+		break;
+	case FLASH_MAN_STM:
+		printf("STM ");
+		break;
+	default:
+		printf("Unknown Vendor ");
+		break;
 	}
 
 	switch (info->flash_id & FLASH_TYPEMASK) {
-	case FLASH_AM400B:	printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM400T:	printf ("AM29LV400T (4 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM800B:	printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM800T:	printf ("AM29LV800T (8 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM160B:	printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM160T:	printf ("AM29LV160T (16 Mbit, top boot sector)\n");
-				break;
-	case FLASH_AM320B:	printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
-				break;
-	case FLASH_AM320T:	printf ("AM29LV320T (32 Mbit, top boot sector)\n");
-				break;
-	case FLASH_SST200A:	printf ("39xF200A (2M = 128K x 16)\n");
-				break;
-	case FLASH_SST400A:	printf ("39xF400A (4M = 256K x 16)\n");
-				break;
-	case FLASH_SST800A:	printf ("39xF800A (8M = 512K x 16)\n");
-				break;
-	case FLASH_STM800AB:	printf ("M29W800AB (8M = 512K x 16)\n");
-				break;
-	default:		printf ("Unknown Chip Type\n");
-				break;
+	case FLASH_AM400B:
+		printf("AM29LV400B (4 Mbit, bottom boot sect)\n");
+		break;
+	case FLASH_AM400T:
+		printf("AM29LV400T (4 Mbit, top boot sector)\n");
+		break;
+	case FLASH_AM800B:
+		printf("AM29LV800B (8 Mbit, bottom boot sect)\n");
+		break;
+	case FLASH_AM800T:
+		printf("AM29LV800T (8 Mbit, top boot sector)\n");
+		break;
+	case FLASH_AM160B:
+		printf("AM29LV160B (16 Mbit, bottom boot sect)\n");
+		break;
+	case FLASH_AM160T:
+		printf("AM29LV160T (16 Mbit, top boot sector)\n");
+		break;
+	case FLASH_AM320B:
+		printf("AM29LV320B (32 Mbit, bottom boot sect)\n");
+		break;
+	case FLASH_AM320T:
+		printf("AM29LV320T (32 Mbit, top boot sector)\n");
+		break;
+	case FLASH_SST200A:
+		printf("39xF200A (2M = 128K x 16)\n");
+		break;
+	case FLASH_SST400A:
+		printf("39xF400A (4M = 256K x 16)\n");
+		break;
+	case FLASH_SST800A:
+		printf("39xF800A (8M = 512K x 16)\n");
+		break;
+	case FLASH_STM800AB:
+		printf("M29W800AB (8M = 512K x 16)\n");
+		break;
+	default:
+		printf("Unknown Chip Type\n");
+		break;
 	}
 
-	printf ("  Size: %ld MB in %d Sectors\n",
+	printf("  Size: %ld MB in %d Sectors\n",
 		info->size >> 20, info->sector_count);
 
-	printf ("  Sector Start Addresses:");
-	for (i=0; i<info->sector_count; ++i) {
+	printf("  Sector Start Addresses:");
+	for (i = 0; i < info->sector_count; ++i) {
 		if ((i % 5) == 0)
-			printf ("\n   ");
-		printf (" %08lX%s",
+			printf("\n   ");
+		printf(" %08lX%s",
 			info->start[i],
 			info->protect[i] ? " (RO)" : "     "
 		);
 	}
-	printf ("\n");
+	printf("\n");
 	return;
 }
 
-/*-----------------------------------------------------------------------
- */
-
-
-/*-----------------------------------------------------------------------
- */
-
 /*
  * The following code cannot be run from FLASH!
  */
 
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
+static ulong flash_get_size(vu_long *addr, flash_info_t *info)
 {
 	short i;
 	ulong value;
@@ -263,7 +279,7 @@
 
 	/* Write auto select command: read Manufacturer ID */
 #ifdef CONFIG_FLASH_16BIT
-	vu_short *s_addr = (vu_short*)addr;
+	vu_short *s_addr = (vu_short *)addr;
 	s_addr[0x5555] = 0x00AA;
 	s_addr[0x2AAA] = 0x0055;
 	s_addr[0x5555] = 0x0090;
@@ -293,7 +309,7 @@
 		info->flash_id = FLASH_UNKNOWN;
 		info->sector_count = 0;
 		info->size = 0;
-		return (0);			/* no or unknown flash	*/
+		return 0;			/* no or unknown flash	*/
 	}
 #ifdef CONFIG_FLASH_16BIT
 	value = s_addr[1];
@@ -349,32 +365,19 @@
 #endif
 
 		break;
-#if 0	/* enable when device IDs are available */
-	case AMD_ID_LV320T:
-		info->flash_id += FLASH_AM320T;
-		info->sector_count = 67;
-		info->size = 0x00800000;
-		break;				/* => 8 MB		*/
-
-	case AMD_ID_LV320B:
-		info->flash_id += FLASH_AM320B;
-		info->sector_count = 67;
-		info->size = 0x00800000;
-		break;				/* => 8 MB		*/
-#endif
 	case SST_ID_xF200A:
 		info->flash_id += FLASH_SST200A;
-		info->sector_count = 64;	/* 39xF200A ID ( 2M = 128K x 16	) */
+		info->sector_count = 64;	/* 39xF200A (2M = 128K x 16) */
 		info->size = 0x00080000;
 		break;
 	case SST_ID_xF400A:
 		info->flash_id += FLASH_SST400A;
-		info->sector_count = 128;	/* 39xF400A ID ( 4M = 256K x 16	) */
+		info->sector_count = 128;	/* 39xF400A (4M = 256K x 16) */
 		info->size = 0x00100000;
 		break;
 	case SST_ID_xF800A:
 		info->flash_id += FLASH_SST800A;
-		info->sector_count = 256;	/* 39xF800A ID ( 8M = 512K x 16	) */
+		info->sector_count = 256;	/* 39xF800A (8M = 512K x 16) */
 		info->size = 0x00200000;
 		break;				/* => 2 MB		*/
 	case STM_ID_x800AB:
@@ -384,55 +387,55 @@
 		break;				/* => 2 MB		*/
 	default:
 		info->flash_id = FLASH_UNKNOWN;
-		return (0);			/* => no or unknown flash */
+		return 0;			/* => no or unknown flash */
 
 	}
 
 	if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
-		printf ("** ERROR: sector count %d > max (%d) **\n",
+		printf("** ERROR: sector count %d > max (%d) **\n",
 			info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
 		info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
 	}
 
 	if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
-		for (i = 0; i < info->sector_count; i++) {
+		for (i = 0; i < info->sector_count; i++)
 			info->start[i] = base + (i * 0x00002000);
-		}
 	} else {	/* AMD and Fujitsu types */
 		/* set up sector start address table */
 		if (info->flash_id & FLASH_BTYPE) {
-			/* set sector offsets for bottom boot block type	*/
+			/* set sector offsets for bottom boot block type */
 #ifdef CONFIG_FLASH_16BIT
 
 			info->start[0] = base + 0x00000000;
 			info->start[1] = base + 0x00004000;
 			info->start[2] = base + 0x00006000;
 			info->start[3] = base + 0x00008000;
-			for (i = 4; i < info->sector_count; i++) {
-				info->start[i] = base + (i * 0x00010000) - 0x00030000;
+			for (i = 4; i < info->sector_count; i++)
+				info->start[i] = base +
+					(i * 0x00010000) - 0x00030000;
 #else
 			info->start[0] = base + 0x00000000;
 			info->start[1] = base + 0x00008000;
 			info->start[2] = base + 0x0000C000;
 			info->start[3] = base + 0x00010000;
-			for (i = 4; i < info->sector_count; i++) {
-				info->start[i] = base + (i * 0x00020000) - 0x00060000;
+			for (i = 4; i < info->sector_count; i++)
+				info->start[i] = base +
+					(i * 0x00020000) - 0x00060000;
 #endif
-			}
 		} else {
-			/* set sector offsets for top boot block type		*/
+			/* set sector offsets for top boot block type	*/
 			i = info->sector_count - 1;
 			info->start[i--] = base + info->size - 0x00008000;
 			info->start[i--] = base + info->size - 0x0000C000;
 			info->start[i--] = base + info->size - 0x00010000;
-			for (; i >= 0; i--) {
+			for (; i >= 0; i--)
 				info->start[i] = base + i * 0x00020000;
-			}
 		}
 
 		/* check for protected sectors */
 		for (i = 0; i < info->sector_count; i++) {
-			/* read sector protection at sector address:
+			/*
+			 * read sector protection at sector address:
 			 * (A7 .. A0) = 0x02
 			 * D0 = 1 if protected
 			 */
@@ -459,28 +462,23 @@
 #endif
 
 	}
-	return (info->size);
+	return info->size;
 }
 
-
-/*-----------------------------------------------------------------------
- */
-
-int	flash_erase (flash_info_t *info, int s_first, int s_last)
+int	flash_erase(flash_info_t *info, int s_first, int s_last)
 {
-	vu_long *addr = (vu_long*)(info->start[0]);
+	vu_long *addr = (vu_long *)(info->start[0]);
 	int flag, prot, sect;
 	ulong start, now, last;
 #ifdef CONFIG_FLASH_16BIT
-	vu_short *s_addr = (vu_short*)addr;
+	vu_short *s_addr = (vu_short *)addr;
 #endif
 
 	if ((s_first < 0) || (s_first > s_last)) {
-		if (info->flash_id == FLASH_UNKNOWN) {
-			printf ("- missing\n");
-		} else {
-			printf ("- no sectors to erase\n");
-		}
+		if (info->flash_id == FLASH_UNKNOWN)
+			printf("- missing\n");
+		else
+			printf("- no sectors to erase\n");
 		return 1;
 	}
 /*#ifndef CONFIG_FLASH_16BIT
@@ -493,30 +491,29 @@
 	}
 #endif*/
 	prot = 0;
-	for (sect=s_first; sect<=s_last; ++sect) {
-		if (info->protect[sect]) {
+	for (sect = s_first; sect <= s_last; ++sect) {
+		if (info->protect[sect])
 			prot++;
-		}
 	}
 
 	if (prot) {
-		printf ("- Warning: %d protected sectors will not be erased!\n",
+		printf("- Warning: %d protected sectors will not be erased!\n",
 			prot);
 	} else {
-		printf ("\n");
+		printf("\n");
 	}
 
-	start = get_timer (0);
+	start = get_timer(0);
 	last  = start;
 	/* Start erase on unprotected sectors */
-	for (sect = s_first; sect<=s_last; sect++) {
+	for (sect = s_first; sect <= s_last; sect++) {
 		if (info->protect[sect] == 0) {	/* not protected */
 #ifdef CONFIG_FLASH_16BIT
-			vu_short *s_sect_addr = (vu_short*)(info->start[sect]);
+			vu_short *s_sect_addr = (vu_short *)(info->start[sect]);
 #else
-			vu_long	*sect_addr = (vu_long*)(info->start[sect]);
+			vu_long	*sect_addr = (vu_long *)(info->start[sect]);
 #endif
-			/* Disable interrupts which might cause a timeout here */
+			/* Disable interrupts which might cause a timeout */
 			flag = disable_interrupts();
 
 #ifdef CONFIG_FLASH_16BIT
@@ -541,20 +538,21 @@
 				enable_interrupts();
 
 			/* wait at least 80us - let's wait 1 ms */
-			udelay (1000);
+			udelay(1000);
 
 #ifdef CONFIG_FLASH_16BIT
 			while ((s_sect_addr[0] & 0x0080) != 0x0080) {
 #else
 			while ((sect_addr[0] & 0x00800080) != 0x00800080) {
 #endif
-				if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-					printf ("Timeout\n");
+				now = get_timer(start);
+				if (now > CONFIG_SYS_FLASH_ERASE_TOUT) {
+					printf("Timeout\n");
 					return 1;
 				}
-				/* show that we're waiting */
-				if ((now - last) > 1000) {	/* every second */
-					putc ('.');
+				/* show every second that we're waiting */
+				if ((now - last) > 1000) {
+					putc('.');
 					last = now;
 				}
 			}
@@ -569,7 +567,7 @@
 	addr[0] = 0x00F000F0;	/* reset bank */
 #endif
 
-	printf (" done\n");
+	printf(" done\n");
 	return 0;
 }
 
@@ -581,37 +579,39 @@
  * 4 - Flash not identified
  */
 
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 {
 	ulong cp, wp, data;
 	int i, l, rc;
 
-	if (info->flash_id == FLASH_UNKNOWN) {
+	if (info->flash_id == FLASH_UNKNOWN)
 		return 4;
-	}
 
 	wp = (addr & ~3);	/* get lower word aligned address */
 
 	/*
 	 * handle unaligned start bytes
 	 */
-	if ((l = addr - wp) != 0) {
+	l = addr - wp;
+
+	if (l != 0) {
 		data = 0;
-		for (i=0, cp=wp; i<l; ++i, ++cp) {
+		for (i = 0, cp = wp; i < l; ++i, ++cp)
 			data = (data << 8) | (*(uchar *)cp);
-		}
-		for (; i<4 && cnt>0; ++i) {
+
+		for (; i < 4 && cnt > 0; ++i) {
 			data = (data << 8) | *src++;
 			--cnt;
 			++cp;
 		}
-		for (; cnt==0 && i<4; ++i, ++cp) {
+		for (; cnt == 0 && i < 4; ++i, ++cp)
 			data = (data << 8) | (*(uchar *)cp);
-		}
 
-		if ((rc = write_word(info, wp, data)) != 0) {
-			return (rc);
-		}
+		rc = write_word(info, wp, data);
+
+		if (rc != 0)
+			return rc;
+
 		wp += 4;
 	}
 
@@ -620,33 +620,32 @@
 	 */
 	while (cnt >= 4) {
 		data = 0;
-		for (i=0; i<4; ++i) {
+		for (i = 0; i < 4; ++i)
 			data = (data << 8) | *src++;
-		}
-		if ((rc = write_word(info, wp, data)) != 0) {
-			return (rc);
-		}
+
+		rc = write_word(info, wp, data);
+		if (rc != 0)
+			return rc;
+
 		wp  += 4;
 		cnt -= 4;
 	}
 
-	if (cnt == 0) {
-		return (0);
-	}
+	if (cnt == 0)
+		return 0;
 
 	/*
 	 * handle unaligned tail bytes
 	 */
 	data = 0;
-	for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+	for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
 		data = (data << 8) | *src++;
 		--cnt;
 	}
-	for (; i<4; ++i, ++cp) {
+	for (; i < 4; ++i, ++cp)
 		data = (data << 8) | (*(uchar *)cp);
-	}
 
-	return (write_word(info, wp, data));
+	return write_word(info, wp, data);
 }
 
 /*-----------------------------------------------------------------------
@@ -655,22 +654,21 @@
  * 1 - write timeout
  * 2 - Flash not erased
  */
-static int write_word (flash_info_t *info, ulong dest, ulong data)
+static int write_word(flash_info_t *info, ulong dest, ulong data)
 {
-	vu_long *addr = (vu_long*)(info->start[0]);
+	vu_long *addr = (vu_long *)(info->start[0]);
 
 #ifdef CONFIG_FLASH_16BIT
 	vu_short high_data;
 	vu_short low_data;
-	vu_short *s_addr = (vu_short*)addr;
+	vu_short *s_addr = (vu_short *)addr;
 #endif
 	ulong start;
 	int flag;
 
 	/* Check if Flash is (sufficiently) erased */
-	if ((*((vu_long *)dest) & data) != data) {
-		return (2);
-	}
+	if ((*((vu_long *)dest) & data) != data)
+		return 2;
 
 #ifdef CONFIG_FLASH_16BIT
 	/* Write the 16 higher-bits */
@@ -685,20 +683,17 @@
 
 	*((vu_short *)dest) = high_data;
 
-
 	/* re-enable interrupts if necessary */
 	if (flag)
 		enable_interrupts();
 
 	/* data polling for D7 */
-	start = get_timer (0);
+	start = get_timer(0);
 	while ((*((vu_short *)dest) & 0x0080) != (high_data & 0x0080)) {
-		if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-			return (1);
-		}
+		if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+			return 1;
 	}
 
-
 	/* Write the 16 lower-bits */
 #endif
 
@@ -725,7 +720,7 @@
 		enable_interrupts();
 
 	/* data polling for D7 */
-	start = get_timer (0);
+	start = get_timer(0);
 
 #ifdef CONFIG_FLASH_16BIT
 	while ((*((vu_short *)dest) & 0x0080) != (low_data & 0x0080)) {
@@ -733,12 +728,8 @@
 	while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) {
 #endif
 
-		if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-			return (1);
-		}
+		if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+			return 1;
 	}
-	return (0);
+	return 0;
 }
-
-/*-----------------------------------------------------------------------
- */
