All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis
@ 2018-01-26 13:43 Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 02/26] cfi_flash: Fix style of pointer declarations Mario Six
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

There should not be a space between a function name and a parenthesis
("func (...)"). Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 428 ++++++++++++++++++++++++------------------------
 1 file changed, 214 insertions(+), 214 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index f096e039cb..0dc7f4a6ba 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -204,7 +204,7 @@ unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect)
  * create an address based on the offset and the port width
  */
 static inline void *
-flash_map (flash_info_t * info, flash_sect_t sect, uint offset)
+flash_map(flash_info_t * info, flash_sect_t sect, uint offset)
 {
 	unsigned int byte_offset = offset * info->portwidth;

@@ -247,17 +247,17 @@ static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 /*-----------------------------------------------------------------------
  * Debug support
  */
-static void print_longlong (char *str, unsigned long long data)
+static void print_longlong(char *str, unsigned long long data)
 {
 	int i;
 	char *cp;

 	cp = (char *) &data;
 	for (i = 0; i < 8; i++)
-		sprintf (&str[i * 2], "%2.2x", *cp++);
+		sprintf(&str[i * 2], "%2.2x", *cp++);
 }

-static void flash_printqry (struct cfi_qry *qry)
+static void flash_printqry(struct cfi_qry *qry)
 {
 	u8 *p = (u8 *)qry;
 	int x, y;
@@ -283,31 +283,31 @@ static void flash_printqry (struct cfi_qry *qry)
 /*-----------------------------------------------------------------------
  * read a character@a port width address
  */
-static inline uchar flash_read_uchar (flash_info_t * info, uint offset)
+static inline uchar flash_read_uchar(flash_info_t * info, uint offset)
 {
 	uchar *cp;
 	uchar retval;

-	cp = flash_map (info, 0, offset);
+	cp = flash_map(info, 0, offset);
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 	retval = flash_read8(cp);
 #else
 	retval = flash_read8(cp + info->portwidth - 1);
 #endif
-	flash_unmap (info, 0, offset, cp);
+	flash_unmap(info, 0, offset, cp);
 	return retval;
 }

 /*-----------------------------------------------------------------------
  * read a word at a port width address, assume 16bit bus
  */
-static inline ushort flash_read_word (flash_info_t * info, uint offset)
+static inline ushort flash_read_word(flash_info_t * info, uint offset)
 {
 	ushort *addr, retval;

-	addr = flash_map (info, 0, offset);
-	retval = flash_read16 (addr);
-	flash_unmap (info, 0, offset, addr);
+	addr = flash_map(info, 0, offset);
+	retval = flash_read16(addr);
+	flash_unmap(info, 0, offset, addr);
 	return retval;
 }

@@ -325,13 +325,13 @@ static ulong flash_read_long (flash_info_t * info, flash_sect_t sect,
 #ifdef DEBUG
 	int x;
 #endif
-	addr = flash_map (info, sect, offset);
+	addr = flash_map(info, sect, offset);

 #ifdef DEBUG
-	debug ("long addr is at %p info->portwidth = %d\n", addr,
+	debug("long addr is at %p info->portwidth = %d\n", addr,
 	       info->portwidth);
 	for (x = 0; x < 4 * info->portwidth; x++) {
-		debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
+		debug("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
 	}
 #endif
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
@@ -360,22 +360,22 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 	void *addr;
 	cfiword_t cword;

-	addr = flash_map (info, sect, offset);
-	flash_make_cmd (info, cmd, &cword);
+	addr = flash_map(info, sect, offset);
+	flash_make_cmd(info, cmd, &cword);
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
-		debug ("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
+		debug("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
 		       cword.w8, info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write8(cword.w8, addr);
 		break;
 	case FLASH_CFI_16BIT:
-		debug ("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
+		debug("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
 		       cmd, cword.w16,
 		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write16(cword.w16, addr);
 		break;
 	case FLASH_CFI_32BIT:
-		debug ("fwc addr %p cmd %x %8.8x 32bit x %d bit\n", addr,
+		debug("fwc addr %p cmd %x %8.8x 32bit x %d bit\n", addr,
 		       cmd, cword.w32,
 		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write32(cword.w32, addr);
@@ -385,9 +385,9 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 		{
 			char str[20];

-			print_longlong (str, cword.w64);
+			print_longlong(str, cword.w64);

-			debug ("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
+			debug("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
 			       addr, cmd, str,
 			       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		}
@@ -402,36 +402,36 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 	flash_unmap(info, sect, offset, addr);
 }

-static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect)
+static void flash_unlock_seq(flash_info_t * info, flash_sect_t sect)
 {
-	flash_write_cmd (info, sect, info->addr_unlock1, AMD_CMD_UNLOCK_START);
-	flash_write_cmd (info, sect, info->addr_unlock2, AMD_CMD_UNLOCK_ACK);
+	flash_write_cmd(info, sect, info->addr_unlock1, AMD_CMD_UNLOCK_START);
+	flash_write_cmd(info, sect, info->addr_unlock2, AMD_CMD_UNLOCK_ACK);
 }

 /*-----------------------------------------------------------------------
  */
-static int flash_isequal (flash_info_t * info, flash_sect_t sect,
+static int flash_isequal(flash_info_t * info, flash_sect_t sect,
 			  uint offset, uchar cmd)
 {
 	void *addr;
 	cfiword_t cword;
 	int retval;

-	addr = flash_map (info, sect, offset);
-	flash_make_cmd (info, cmd, &cword);
+	addr = flash_map(info, sect, offset);
+	flash_make_cmd(info, cmd, &cword);

-	debug ("is= cmd %x(%c) addr %p ", cmd, cmd, addr);
+	debug("is= cmd %x(%c) addr %p ", cmd, cmd, addr);
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
-		debug ("is= %x %x\n", flash_read8(addr), cword.w8);
+		debug("is= %x %x\n", flash_read8(addr), cword.w8);
 		retval = (flash_read8(addr) == cword.w8);
 		break;
 	case FLASH_CFI_16BIT:
-		debug ("is= %4.4x %4.4x\n", flash_read16(addr), cword.w16);
+		debug("is= %4.4x %4.4x\n", flash_read16(addr), cword.w16);
 		retval = (flash_read16(addr) == cword.w16);
 		break;
 	case FLASH_CFI_32BIT:
-		debug ("is= %8.8x %8.8x\n", flash_read32(addr), cword.w32);
+		debug("is= %8.8x %8.8x\n", flash_read32(addr), cword.w32);
 		retval = (flash_read32(addr) == cword.w32);
 		break;
 	case FLASH_CFI_64BIT:
@@ -440,9 +440,9 @@ static int flash_isequal (flash_info_t * info, flash_sect_t sect,
 			char str1[20];
 			char str2[20];

-			print_longlong (str1, flash_read64(addr));
-			print_longlong (str2, cword.w64);
-			debug ("is= %s %s\n", str1, str2);
+			print_longlong(str1, flash_read64(addr));
+			print_longlong(str2, cword.w64);
+			debug("is= %s %s\n", str1, str2);
 		}
 #endif
 		retval = (flash_read64(addr) == cword.w64);
@@ -458,15 +458,15 @@ static int flash_isequal (flash_info_t * info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_isset (flash_info_t * info, flash_sect_t sect,
+static int flash_isset(flash_info_t * info, flash_sect_t sect,
 			uint offset, uchar cmd)
 {
 	void *addr;
 	cfiword_t cword;
 	int retval;

-	addr = flash_map (info, sect, offset);
-	flash_make_cmd (info, cmd, &cword);
+	addr = flash_map(info, sect, offset);
+	flash_make_cmd(info, cmd, &cword);
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
 		retval = ((flash_read8(addr) & cword.w8) == cword.w8);
@@ -491,15 +491,15 @@ static int flash_isset (flash_info_t * info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_toggle (flash_info_t * info, flash_sect_t sect,
+static int flash_toggle(flash_info_t * info, flash_sect_t sect,
 			 uint offset, uchar cmd)
 {
 	void *addr;
 	cfiword_t cword;
 	int retval;

-	addr = flash_map (info, sect, offset);
-	flash_make_cmd (info, cmd, &cword);
+	addr = flash_map(info, sect, offset);
+	flash_make_cmd(info, cmd, &cword);
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
 		retval = flash_read8(addr) != flash_read8(addr);
@@ -529,7 +529,7 @@ static int flash_toggle (flash_info_t * info, flash_sect_t sect,
  * This routine checks the status of the chip and returns true if the
  * chip is busy.
  */
-static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
+static int flash_is_busy(flash_info_t * info, flash_sect_t sect)
 {
 	int retval;

@@ -537,7 +537,7 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
 	case CFI_CMDSET_INTEL_STANDARD:
 	case CFI_CMDSET_INTEL_EXTENDED:
-		retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE);
+		retval = !flash_isset(info, sect, 0, FLASH_STATUS_DONE);
 		break;
 	case CFI_CMDSET_AMD_STANDARD:
 	case CFI_CMDSET_AMD_EXTENDED:
@@ -545,12 +545,12 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
 	case CFI_CMDSET_AMD_LEGACY:
 #endif
 		if (info->sr_supported) {
-			flash_write_cmd (info, sect, info->addr_unlock1,
+			flash_write_cmd(info, sect, info->addr_unlock1,
 					 FLASH_CMD_READ_STATUS);
-			retval = !flash_isset (info, sect, 0,
+			retval = !flash_isset(info, sect, 0,
 					       FLASH_STATUS_DONE);
 		} else {
-			retval = flash_toggle (info, sect, 0,
+			retval = flash_toggle(info, sect, 0,
 					       AMD_STATUS_TOGGLE);
 		}

@@ -558,7 +558,7 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
 	default:
 		retval = 0;
 	}
-	debug ("flash_is_busy: %d\n", retval);
+	debug("flash_is_busy: %d\n", retval);
 	return retval;
 }

@@ -566,7 +566,7 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
  *  wait for XSR.7 to be set. Time out with an error if it does not.
  *  This routine does not set the flash to read-array mode.
  */
-static int flash_status_check (flash_info_t * info, flash_sect_t sector,
+static int flash_status_check(flash_info_t * info, flash_sect_t sector,
 			       ulong tout, char *prompt)
 {
 	ulong start;
@@ -582,18 +582,18 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 #ifdef CONFIG_SYS_LOW_RES_TIMER
 	reset_timer();
 #endif
-	start = get_timer (0);
+	start = get_timer(0);
 	WATCHDOG_RESET();
-	while (flash_is_busy (info, sector)) {
-		if (get_timer (start) > tout) {
-			printf ("Flash %s timeout at address %lx data %lx\n",
+	while (flash_is_busy(info, sector)) {
+		if (get_timer(start) > tout) {
+			printf("Flash %s timeout at address %lx data %lx\n",
 				prompt, info->start[sector],
-				flash_read_long (info, sector, 0));
-			flash_write_cmd (info, sector, 0, info->cmd_reset);
+				flash_read_long(info, sector, 0));
+			flash_write_cmd(info, sector, 0, info->cmd_reset);
 			udelay(1);
 			return ERR_TIMOUT;
 		}
-		udelay (1);		/* also triggers watchdog */
+		udelay(1);		/* also triggers watchdog */
 	}
 	return ERR_OK;
 }
@@ -604,12 +604,12 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
  *
  * This routine sets the flash to read-array mode.
  */
-static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
+static int flash_full_status_check(flash_info_t * info, flash_sect_t sector,
 				    ulong tout, char *prompt)
 {
 	int retcode;

-	retcode = flash_status_check (info, sector, tout, prompt);
+	retcode = flash_status_check(info, sector, tout, prompt);
 	switch (info->vendor) {
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
 	case CFI_CMDSET_INTEL_EXTENDED:
@@ -617,27 +617,27 @@ static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
 		if ((retcode == ERR_OK)
 		    && !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
 			retcode = ERR_INVAL;
-			printf ("Flash %s error at address %lx\n", prompt,
+			printf("Flash %s error at address %lx\n", prompt,
 				info->start[sector]);
-			if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS |
+			if (flash_isset(info, sector, 0, FLASH_STATUS_ECLBS |
 					 FLASH_STATUS_PSLBS)) {
-				puts ("Command Sequence Error.\n");
-			} else if (flash_isset (info, sector, 0,
+				puts("Command Sequence Error.\n");
+			} else if (flash_isset(info, sector, 0,
 						FLASH_STATUS_ECLBS)) {
-				puts ("Block Erase Error.\n");
+				puts("Block Erase Error.\n");
 				retcode = ERR_NOT_ERASED;
-			} else if (flash_isset (info, sector, 0,
+			} else if (flash_isset(info, sector, 0,
 						FLASH_STATUS_PSLBS)) {
-				puts ("Locking Error\n");
+				puts("Locking Error\n");
 			}
-			if (flash_isset (info, sector, 0, FLASH_STATUS_DPS)) {
-				puts ("Block locked.\n");
+			if (flash_isset(info, sector, 0, FLASH_STATUS_DPS)) {
+				puts("Block locked.\n");
 				retcode = ERR_PROTECTED;
 			}
-			if (flash_isset (info, sector, 0, FLASH_STATUS_VPENS))
-				puts ("Vpp Low Error.\n");
+			if (flash_isset(info, sector, 0, FLASH_STATUS_VPENS))
+				puts("Vpp Low Error.\n");
 		}
-		flash_write_cmd (info, sector, 0, info->cmd_reset);
+		flash_write_cmd(info, sector, 0, info->cmd_reset);
 		udelay(1);
 		break;
 	default:
@@ -709,7 +709,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,

 /*-----------------------------------------------------------------------
  */
-static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c)
+static void flash_add_byte(flash_info_t * info, cfiword_t * cword, uchar c)
 {
 #if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 	unsigned short	w;
@@ -755,7 +755,7 @@ static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c)
  * Loop through the sector table starting from the previously found sector.
  * Searches forwards or backwards, dependent on the passed address.
  */
-static flash_sect_t find_sector (flash_info_t * info, ulong addr)
+static flash_sect_t find_sector(flash_info_t * info, ulong addr)
 {
 	static flash_sect_t saved_sector; /* previously found sector */
 	static flash_info_t *saved_info; /* previously used flash bank */
@@ -781,7 +781,7 @@ static flash_sect_t find_sector (flash_info_t * info, ulong addr)

 /*-----------------------------------------------------------------------
  */
-static int flash_write_cfiword (flash_info_t * info, ulong dest,
+static int flash_write_cfiword(flash_info_t * info, ulong dest,
 				cfiword_t cword)
 {
 	void *dstaddr = (void *)dest;
@@ -811,27 +811,27 @@ static int flash_write_cfiword (flash_info_t * info, ulong dest,
 		return ERR_NOT_ERASED;

 	/* Disable interrupts which might cause a timeout here */
-	flag = disable_interrupts ();
+	flag = disable_interrupts();

 	switch (info->vendor) {
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
 	case CFI_CMDSET_INTEL_EXTENDED:
 	case CFI_CMDSET_INTEL_STANDARD:
-		flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS);
-		flash_write_cmd (info, 0, 0, FLASH_CMD_WRITE);
+		flash_write_cmd(info, 0, 0, FLASH_CMD_CLEAR_STATUS);
+		flash_write_cmd(info, 0, 0, FLASH_CMD_WRITE);
 		break;
 	case CFI_CMDSET_AMD_EXTENDED:
 	case CFI_CMDSET_AMD_STANDARD:
 		sect = find_sector(info, dest);
-		flash_unlock_seq (info, sect);
-		flash_write_cmd (info, sect, info->addr_unlock1, AMD_CMD_WRITE);
+		flash_unlock_seq(info, sect);
+		flash_write_cmd(info, sect, info->addr_unlock1, AMD_CMD_WRITE);
 		sect_found = 1;
 		break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
 	case CFI_CMDSET_AMD_LEGACY:
 		sect = find_sector(info, dest);
-		flash_unlock_seq (info, 0);
-		flash_write_cmd (info, 0, info->addr_unlock1, AMD_CMD_WRITE);
+		flash_unlock_seq(info, 0);
+		flash_write_cmd(info, 0, info->addr_unlock1, AMD_CMD_WRITE);
 		sect_found = 1;
 		break;
 #endif
@@ -854,10 +854,10 @@ static int flash_write_cfiword (flash_info_t * info, ulong dest,

 	/* re-enable interrupts if necessary */
 	if (flag)
-		enable_interrupts ();
+		enable_interrupts();

 	if (!sect_found)
-		sect = find_sector (info, dest);
+		sect = find_sector(info, dest);

 	if (use_flash_status_poll(info))
 		return flash_status_poll(info, &cword, dstaddr,
@@ -869,7 +869,7 @@ static int flash_write_cfiword (flash_info_t * info, ulong dest,

 #ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE

-static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
+static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp,
 				  int len)
 {
 	flash_sect_t sector;
@@ -933,7 +933,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 	}

 	src = cp;
-	sector = find_sector (info, dest);
+	sector = find_sector(info, dest);

 	switch (info->vendor) {
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
@@ -941,17 +941,17 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 	case CFI_CMDSET_INTEL_EXTENDED:
 		write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ?
 					FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER;
-		flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-		flash_write_cmd (info, sector, 0, FLASH_CMD_READ_STATUS);
-		flash_write_cmd (info, sector, 0, write_cmd);
-		retcode = flash_status_check (info, sector,
+		flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
+		flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
+		flash_write_cmd(info, sector, 0, write_cmd);
+		retcode = flash_status_check(info, sector,
 					      info->buffer_write_tout,
 					      "write to buffer");
 		if (retcode == ERR_OK) {
 			/* reduce the number of loops by the width of
 			 * the port */
 			cnt = len >> shift;
-			flash_write_cmd (info, sector, 0, cnt - 1);
+			flash_write_cmd(info, sector, 0, cnt - 1);
 			while (cnt-- > 0) {
 				switch (info->portwidth) {
 				case FLASH_CFI_8BIT:
@@ -975,9 +975,9 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 					goto out_unmap;
 				}
 			}
-			flash_write_cmd (info, sector, 0,
+			flash_write_cmd(info, sector, 0,
 					 FLASH_CMD_WRITE_BUFFER_CONFIRM);
-			retcode = flash_full_status_check (
+			retcode = flash_full_status_check(
 				info, sector, info->buffer_write_tout,
 				"buffer write");
 		}
@@ -1025,7 +1025,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 			goto out_unmap;
 		}

-		flash_write_cmd (info, sector, 0, AMD_CMD_WRITE_BUFFER_CONFIRM);
+		flash_write_cmd(info, sector, 0, AMD_CMD_WRITE_BUFFER_CONFIRM);
 		if (use_flash_status_poll(info))
 			retcode = flash_status_poll(info, src - (1 << shift),
 						    dst - (1 << shift),
@@ -1038,7 +1038,7 @@ static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
 		break;

 	default:
-		debug ("Unknown Command Set\n");
+		debug("Unknown Command Set\n");
 		retcode = ERR_INVAL;
 		break;
 	}
@@ -1051,7 +1051,7 @@ out_unmap:

 /*-----------------------------------------------------------------------
  */
-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)
 {
 	int rcode = 0;
 	int prot;
@@ -1059,11 +1059,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 	int st;

 	if (info->flash_id != FLASH_MAN_CFI) {
-		puts ("Can't erase unknown flash type - aborted\n");
+		puts("Can't erase unknown flash type - aborted\n");
 		return 1;
 	}
 	if ((s_first < 0) || (s_first > s_last)) {
-		puts ("- no sectors to erase\n");
+		puts("- no sectors to erase\n");
 		return 1;
 	}

@@ -1074,10 +1074,10 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 		}
 	}
 	if (prot) {
-		printf ("- Warning: %d protected sectors will not be erased!\n",
+		printf("- Warning: %d protected sectors will not be erased!\n",
 			prot);
 	} else if (flash_verbose) {
-		putc ('\n');
+		putc('\n');
 	}


@@ -1118,35 +1118,35 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 			case CFI_CMDSET_INTEL_PROG_REGIONS:
 			case CFI_CMDSET_INTEL_STANDARD:
 			case CFI_CMDSET_INTEL_EXTENDED:
-				flash_write_cmd (info, sect, 0,
+				flash_write_cmd(info, sect, 0,
 						 FLASH_CMD_CLEAR_STATUS);
-				flash_write_cmd (info, sect, 0,
+				flash_write_cmd(info, sect, 0,
 						 FLASH_CMD_BLOCK_ERASE);
-				flash_write_cmd (info, sect, 0,
+				flash_write_cmd(info, sect, 0,
 						 FLASH_CMD_ERASE_CONFIRM);
 				break;
 			case CFI_CMDSET_AMD_STANDARD:
 			case CFI_CMDSET_AMD_EXTENDED:
-				flash_unlock_seq (info, sect);
-				flash_write_cmd (info, sect,
+				flash_unlock_seq(info, sect);
+				flash_write_cmd(info, sect,
 						info->addr_unlock1,
 						AMD_CMD_ERASE_START);
-				flash_unlock_seq (info, sect);
-				flash_write_cmd (info, sect, 0,
+				flash_unlock_seq(info, sect);
+				flash_write_cmd(info, sect, 0,
 						 info->cmd_erase_sector);
 				break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
 			case CFI_CMDSET_AMD_LEGACY:
-				flash_unlock_seq (info, 0);
-				flash_write_cmd (info, 0, info->addr_unlock1,
+				flash_unlock_seq(info, 0);
+				flash_write_cmd(info, 0, info->addr_unlock1,
 						AMD_CMD_ERASE_START);
-				flash_unlock_seq (info, 0);
-				flash_write_cmd (info, sect, 0,
+				flash_unlock_seq(info, 0);
+				flash_write_cmd(info, sect, 0,
 						AMD_CMD_ERASE_SECTOR);
 				break;
 #endif
 			default:
-				debug ("Unkown flash vendor %d\n",
+				debug("Unkown flash vendor %d\n",
 				       info->vendor);
 				break;
 			}
@@ -1166,12 +1166,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 			if (st)
 				rcode = 1;
 			else if (flash_verbose)
-				putc ('.');
+				putc('.');
 		}
 	}

 	if (flash_verbose)
-		puts (" done\n");
+		puts(" done\n");

 	return rcode;
 }
@@ -1200,53 +1200,53 @@ static int sector_erased(flash_info_t *info, int i)
 }
 #endif /* CONFIG_SYS_FLASH_EMPTY_INFO */

-void flash_print_info (flash_info_t * info)
+void flash_print_info(flash_info_t * info)
 {
 	int i;

 	if (info->flash_id != FLASH_MAN_CFI) {
-		puts ("missing or unknown FLASH type\n");
+		puts("missing or unknown FLASH type\n");
 		return;
 	}

-	printf ("%s flash (%d x %d)",
+	printf("%s flash (%d x %d)",
 		info->name,
 		(info->portwidth << 3), (info->chipwidth << 3));
 	if (info->size < 1024*1024)
-		printf ("  Size: %ld kB in %d Sectors\n",
+		printf("  Size: %ld kB in %d Sectors\n",
 			info->size >> 10, info->sector_count);
 	else
-		printf ("  Size: %ld MB in %d Sectors\n",
+		printf("  Size: %ld MB in %d Sectors\n",
 			info->size >> 20, info->sector_count);
-	printf ("  ");
+	printf("  ");
 	switch (info->vendor) {
 		case CFI_CMDSET_INTEL_PROG_REGIONS:
-			printf ("Intel Prog Regions");
+			printf("Intel Prog Regions");
 			break;
 		case CFI_CMDSET_INTEL_STANDARD:
-			printf ("Intel Standard");
+			printf("Intel Standard");
 			break;
 		case CFI_CMDSET_INTEL_EXTENDED:
-			printf ("Intel Extended");
+			printf("Intel Extended");
 			break;
 		case CFI_CMDSET_AMD_STANDARD:
-			printf ("AMD Standard");
+			printf("AMD Standard");
 			break;
 		case CFI_CMDSET_AMD_EXTENDED:
-			printf ("AMD Extended");
+			printf("AMD Extended");
 			break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
 		case CFI_CMDSET_AMD_LEGACY:
-			printf ("AMD Legacy");
+			printf("AMD Legacy");
 			break;
 #endif
 		default:
-			printf ("Unknown (%d)", info->vendor);
+			printf("Unknown (%d)", info->vendor);
 			break;
 	}
-	printf (" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
+	printf(" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
 		info->manufacturer_id);
-	printf (info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
+	printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
 		info->device_id);
 	if ((info->device_id & 0xff) == 0x7E) {
 		printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
@@ -1254,17 +1254,17 @@ void flash_print_info (flash_info_t * info)
 	}
 	if ((info->vendor == CFI_CMDSET_AMD_STANDARD) && (info->legacy_unlock))
 		printf("\n  Advanced Sector Protection (PPB) enabled");
-	printf ("\n  Erase timeout: %ld ms, write timeout: %ld ms\n",
+	printf("\n  Erase timeout: %ld ms, write timeout: %ld ms\n",
 		info->erase_blk_tout,
 		info->write_tout);
 	if (info->buffer_size > 1) {
-		printf ("  Buffer write timeout: %ld ms, "
+		printf("  Buffer write timeout: %ld ms, "
 			"buffer size: %d bytes\n",
 		info->buffer_write_tout,
 		info->buffer_size);
 	}

-	puts ("\n  Sector Start Addresses:");
+	puts("\n  Sector Start Addresses:");
 	for (i = 0; i < info->sector_count; ++i) {
 		if (ctrlc())
 			break;
@@ -1272,17 +1272,17 @@ void flash_print_info (flash_info_t * info)
 			putc('\n');
 #ifdef CONFIG_SYS_FLASH_EMPTY_INFO
 		/* print empty and read-only info */
-		printf ("  %08lX %c %s ",
+		printf("  %08lX %c %s ",
 			info->start[i],
 			sector_erased(info, i) ? 'E' : ' ',
 			info->protect[i] ? "RO" : "  ");
 #else	/* ! CONFIG_SYS_FLASH_EMPTY_INFO */
-		printf ("  %08lX   %s ",
+		printf("  %08lX   %s ",
 			info->start[i],
 			info->protect[i] ? "RO" : "  ");
 #endif
 	}
-	putc ('\n');
+	putc('\n');
 	return;
 }

@@ -1298,9 +1298,9 @@ void flash_print_info (flash_info_t * info)
 		dots -= dots_sub; \
 		if ((scale > 0) && (dots <= 0)) { \
 			if ((digit % 5) == 0) \
-				printf ("%d", digit / 5); \
+				printf("%d", digit / 5); \
 			else \
-				putc ('.'); \
+				putc('.'); \
 			digit--; \
 			dots += scale; \
 		} \
@@ -1315,7 +1315,7 @@ void flash_print_info (flash_info_t * info)
  * 1 - write timeout
  * 2 - Flash not erased
  */
-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 wp;
 	uchar *p;
@@ -1347,16 +1347,16 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 		cword.w32 = 0;
 		p = (uchar *)wp;
 		for (i = 0; i < aln; ++i)
-			flash_add_byte (info, &cword, flash_read8(p + i));
+			flash_add_byte(info, &cword, flash_read8(p + i));

 		for (; (i < info->portwidth) && (cnt > 0); i++) {
-			flash_add_byte (info, &cword, *src++);
+			flash_add_byte(info, &cword, *src++);
 			cnt--;
 		}
 		for (; (cnt == 0) && (i < info->portwidth); ++i)
-			flash_add_byte (info, &cword, flash_read8(p + i));
+			flash_add_byte(info, &cword, flash_read8(p + i));

-		rc = flash_write_cfiword (info, wp, cword);
+		rc = flash_write_cfiword(info, wp, cword);
 		if (rc != 0)
 			return rc;

@@ -1373,8 +1373,8 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 		if (info->buffer_size == 1) {
 			cword.w32 = 0;
 			for (i = 0; i < info->portwidth; i++)
-				flash_add_byte (info, &cword, *src++);
-			if ((rc = flash_write_cfiword (info, wp, cword)) != 0)
+				flash_add_byte(info, &cword, *src++);
+			if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
 				return rc;
 			wp += info->portwidth;
 			cnt -= info->portwidth;
@@ -1385,7 +1385,7 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 		i = buffered_size - (wp % buffered_size);
 		if (i > cnt)
 			i = cnt;
-		if ((rc = flash_write_cfibuffer (info, wp, src, i)) != ERR_OK)
+		if ((rc = flash_write_cfibuffer(info, wp, src, i)) != ERR_OK)
 			return rc;
 		i -= i & (info->portwidth - 1);
 		wp += i;
@@ -1400,9 +1400,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 	while (cnt >= info->portwidth) {
 		cword.w32 = 0;
 		for (i = 0; i < info->portwidth; i++) {
-			flash_add_byte (info, &cword, *src++);
+			flash_add_byte(info, &cword, *src++);
 		}
-		if ((rc = flash_write_cfiword (info, wp, cword)) != 0)
+		if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
 			return rc;
 		wp += info->portwidth;
 		cnt -= info->portwidth;
@@ -1423,13 +1423,13 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 	cword.w32 = 0;
 	p = (uchar *)wp;
 	for (i = 0; (i < info->portwidth) && (cnt > 0); ++i) {
-		flash_add_byte (info, &cword, *src++);
+		flash_add_byte(info, &cword, *src++);
 		--cnt;
 	}
 	for (; i < info->portwidth; ++i)
-		flash_add_byte (info, &cword, flash_read8(p + i));
+		flash_add_byte(info, &cword, flash_read8(p + i));

-	return flash_write_cfiword (info, wp, cword);
+	return flash_write_cfiword(info, wp, cword);
 }

 static inline int manufact_match(flash_info_t *info, u32 manu)
@@ -1475,7 +1475,7 @@ static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 	return 0;
 }

-int flash_real_protect (flash_info_t * info, long sector, int prot)
+int flash_real_protect(flash_info_t * info, long sector, int prot)
 {
 	int retcode = 0;

@@ -1502,19 +1502,19 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 			/* U-Boot only checks the first byte */
 			if (manufact_match(info, ATM_MANUFACT)) {
 				if (prot) {
-					flash_unlock_seq (info, 0);
-					flash_write_cmd (info, 0,
+					flash_unlock_seq(info, 0);
+					flash_write_cmd(info, 0,
 							info->addr_unlock1,
 							ATM_CMD_SOFTLOCK_START);
-					flash_unlock_seq (info, 0);
-					flash_write_cmd (info, sector, 0,
+					flash_unlock_seq(info, 0);
+					flash_write_cmd(info, sector, 0,
 							ATM_CMD_LOCK_SECT);
 				} else {
-					flash_write_cmd (info, 0,
+					flash_write_cmd(info, 0,
 							info->addr_unlock1,
 							AMD_CMD_UNLOCK_START);
 					if (info->device_id == ATM_ID_BV6416)
-						flash_write_cmd (info, sector,
+						flash_write_cmd(info, sector,
 							0, ATM_CMD_UNLOCK_SECT);
 				}
 			}
@@ -1562,12 +1562,12 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 			break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
 		case CFI_CMDSET_AMD_LEGACY:
-			flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-			flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT);
+			flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
+			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
 			if (prot)
-				flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_SET);
+				flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
 			else
-				flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
+				flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
 #endif
 	};

@@ -1577,7 +1577,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 	 */
 	flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
 	if ((retcode =
-	     flash_full_status_check (info, sector, info->erase_blk_tout,
+	     flash_full_status_check(info, sector, info->erase_blk_tout,
 				      prot ? "protect" : "unprotect")) == 0) {

 		info->protect[sector] = prot;
@@ -1591,7 +1591,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)

 			for (i = 0; i < info->sector_count; i++) {
 				if (info->protect[i])
-					flash_real_protect (info, i, 1);
+					flash_real_protect(info, i, 1);
 			}
 		}
 	}
@@ -1601,17 +1601,17 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 /*-----------------------------------------------------------------------
  * flash_read_user_serial - read the OneTimeProgramming cells
  */
-void flash_read_user_serial (flash_info_t * info, void *buffer, int offset,
+void flash_read_user_serial(flash_info_t * info, void *buffer, int offset,
 			     int len)
 {
 	uchar *src;
 	uchar *dst;

 	dst = buffer;
-	src = flash_map (info, 0, FLASH_OFFSET_USER_PROTECTION);
-	flash_write_cmd (info, 0, 0, FLASH_CMD_READ_ID);
-	memcpy (dst, src + offset, len);
-	flash_write_cmd (info, 0, 0, info->cmd_reset);
+	src = flash_map(info, 0, FLASH_OFFSET_USER_PROTECTION);
+	flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
+	memcpy(dst, src + offset, len);
+	flash_write_cmd(info, 0, 0, info->cmd_reset);
 	udelay(1);
 	flash_unmap(info, 0, FLASH_OFFSET_USER_PROTECTION, src);
 }
@@ -1619,15 +1619,15 @@ void flash_read_user_serial (flash_info_t * info, void *buffer, int offset,
 /*
  * flash_read_factory_serial - read the device Id from the protection area
  */
-void flash_read_factory_serial (flash_info_t * info, void *buffer, int offset,
+void flash_read_factory_serial(flash_info_t * info, void *buffer, int offset,
 				int len)
 {
 	uchar *src;

-	src = flash_map (info, 0, FLASH_OFFSET_INTEL_PROTECTION);
-	flash_write_cmd (info, 0, 0, FLASH_CMD_READ_ID);
-	memcpy (buffer, src + offset, len);
-	flash_write_cmd (info, 0, 0, info->cmd_reset);
+	src = flash_map(info, 0, FLASH_OFFSET_INTEL_PROTECTION);
+	flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
+	memcpy(buffer, src + offset, len);
+	flash_write_cmd(info, 0, 0, info->cmd_reset);
 	udelay(1);
 	flash_unmap(info, 0, FLASH_OFFSET_INTEL_PROTECTION, src);
 }
@@ -1664,11 +1664,11 @@ static void cmdset_intel_read_jedec_ids(flash_info_t *info)
 	udelay(1);
 	flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */
-	info->manufacturer_id = flash_read_uchar (info,
+	info->manufacturer_id = flash_read_uchar(info,
 					FLASH_OFFSET_MANUFACTURER_ID);
 	info->device_id = (info->chipwidth == FLASH_CFI_16BIT) ?
-			flash_read_word (info, FLASH_OFFSET_DEVICE_ID) :
-			flash_read_uchar (info, FLASH_OFFSET_DEVICE_ID);
+			flash_read_word(info, FLASH_OFFSET_DEVICE_ID) :
+			flash_read_uchar(info, FLASH_OFFSET_DEVICE_ID);
 	flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
 }

@@ -1682,7 +1682,7 @@ static int cmdset_intel_init(flash_info_t *info, struct cfi_qry *qry)
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 	/* read legacy lock/unlock bit from intel flash */
 	if (info->ext_addr) {
-		info->legacy_unlock = flash_read_uchar (info,
+		info->legacy_unlock = flash_read_uchar(info,
 				info->ext_addr + 5) & 0x08;
 	}
 #endif
@@ -1701,11 +1701,11 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */

-	manuId = flash_read_uchar (info, FLASH_OFFSET_MANUFACTURER_ID);
+	manuId = flash_read_uchar(info, FLASH_OFFSET_MANUFACTURER_ID);
 	/* JEDEC JEP106Z specifies ID codes up to bank 7 */
 	while (manuId == FLASH_CONTINUATION_CODE && bankId < 0x800) {
 		bankId += 0x100;
-		manuId = flash_read_uchar (info,
+		manuId = flash_read_uchar(info,
 			bankId | FLASH_OFFSET_MANUFACTURER_ID);
 	}
 	info->manufacturer_id = manuId;
@@ -1721,26 +1721,26 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)

 	switch (info->chipwidth){
 	case FLASH_CFI_8BIT:
-		info->device_id = flash_read_uchar (info,
+		info->device_id = flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID);
 		if (info->device_id == 0x7E) {
 			/* AMD 3-byte (expanded) device ids */
-			info->device_id2 = flash_read_uchar (info,
+			info->device_id2 = flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID2);
 			info->device_id2 <<= 8;
-			info->device_id2 |= flash_read_uchar (info,
+			info->device_id2 |= flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID3);
 		}
 		break;
 	case FLASH_CFI_16BIT:
-		info->device_id = flash_read_word (info,
+		info->device_id = flash_read_word(info,
 						FLASH_OFFSET_DEVICE_ID);
 		if ((info->device_id & 0xff) == 0x7E) {
 			/* AMD 3-byte (expanded) device ids */
-			info->device_id2 = flash_read_uchar (info,
+			info->device_id2 = flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID2);
 			info->device_id2 <<= 8;
-			info->device_id2 |= flash_read_uchar (info,
+			info->device_id2 |= flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID3);
 		}
 		break;
@@ -1771,7 +1771,7 @@ static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 }

 #ifdef CONFIG_FLASH_CFI_LEGACY
-static void flash_read_jedec_ids (flash_info_t * info)
+static void flash_read_jedec_ids(flash_info_t * info)
 {
 	info->manufacturer_id = 0;
 	info->device_id       = 0;
@@ -1866,7 +1866,7 @@ static inline int flash_detect_legacy(phys_addr_t base, int banknum)
  * detect if flash is compatible with the Common Flash Interface (CFI)
  * http://www.jedec.org/download/search/jesd68.pdf
  */
-static void flash_read_cfi (flash_info_t *info, void *buf,
+static void flash_read_cfi(flash_info_t *info, void *buf,
 		unsigned int start, size_t len)
 {
 	u8 *p = buf;
@@ -1890,7 +1890,7 @@ static void __flash_cmd_reset(flash_info_t *info)
 void flash_cmd_reset(flash_info_t *info)
 	__attribute__((weak,alias("__flash_cmd_reset")));

-static int __flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)
+static int __flash_detect_cfi(flash_info_t * info, struct cfi_qry *qry)
 {
 	int cfi_offset;

@@ -1899,21 +1899,21 @@ static int __flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)

 	for (cfi_offset = 0; cfi_offset < ARRAY_SIZE(flash_offset_cfi);
 	     cfi_offset++) {
-		flash_write_cmd (info, 0, flash_offset_cfi[cfi_offset],
+		flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
 				 FLASH_CMD_CFI);
-		if (flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
-		    && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
-		    && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
+		if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
+		    && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
+		    && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
 			flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
 					sizeof(struct cfi_qry));
 			info->interface	= le16_to_cpu(qry->interface_desc);

 			info->cfi_offset = flash_offset_cfi[cfi_offset];
-			debug ("device interface is %d\n",
+			debug("device interface is %d\n",
 			       info->interface);
-			debug ("found port %d chip %d ",
+			debug("found port %d chip %d ",
 			       info->portwidth, info->chipwidth);
-			debug ("port %d bits chip %d bits\n",
+			debug("port %d bits chip %d bits\n",
 			       info->portwidth << CFI_FLASH_SHIFT_WIDTH,
 			       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);

@@ -1944,9 +1944,9 @@ static int __flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)
 	return 0;
 }

-static int flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)
+static int flash_detect_cfi(flash_info_t * info, struct cfi_qry *qry)
 {
-	debug ("flash detect cfi\n");
+	debug("flash detect cfi\n");

 	for (info->portwidth = CONFIG_SYS_FLASH_CFI_WIDTH;
 	     info->portwidth <= FLASH_CFI_64BIT; info->portwidth <<= 1) {
@@ -1956,7 +1956,7 @@ static int flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)
 			if (__flash_detect_cfi(info, qry))
 				return 1;
 	}
-	debug ("not found\n");
+	debug("not found\n");
 	return 0;
 }

@@ -2063,7 +2063,7 @@ static void flash_fixup_num(flash_info_t *info, struct cfi_qry *qry)
  * The following code cannot be run from FLASH!
  *
  */
-ulong flash_get_size (phys_addr_t base, int banknum)
+ulong flash_get_size(phys_addr_t base, int banknum)
 {
 	flash_info_t *info = &flash_info[banknum];
 	int i, j;
@@ -2087,20 +2087,20 @@ ulong flash_get_size (phys_addr_t base, int banknum)

 	info->start[0] = (ulong)map_physmem(base, info->portwidth, MAP_NOCACHE);

-	if (flash_detect_cfi (info, &qry)) {
+	if (flash_detect_cfi(info, &qry)) {
 		info->vendor = le16_to_cpu(get_unaligned(&(qry.p_id)));
 		info->ext_addr = le16_to_cpu(get_unaligned(&(qry.p_adr)));
 		num_erase_regions = qry.num_erase_regions;

 		if (info->ext_addr) {
-			info->cfi_version = (ushort) flash_read_uchar (info,
+			info->cfi_version = (ushort) flash_read_uchar(info,
 						info->ext_addr + 3) << 8;
-			info->cfi_version |= (ushort) flash_read_uchar (info,
+			info->cfi_version |= (ushort) flash_read_uchar(info,
 						info->ext_addr + 4);
 		}

 #ifdef DEBUG
-		flash_printqry (&qry);
+		flash_printqry(&qry);
 #endif

 		switch (info->vendor) {
@@ -2145,11 +2145,11 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 			break;
 		}

-		debug ("manufacturer is %d\n", info->vendor);
-		debug ("manufacturer id is 0x%x\n", info->manufacturer_id);
-		debug ("device id is 0x%x\n", info->device_id);
-		debug ("device id2 is 0x%x\n", info->device_id2);
-		debug ("cfi version is 0x%04x\n", info->cfi_version);
+		debug("manufacturer is %d\n", info->vendor);
+		debug("manufacturer id is 0x%x\n", info->manufacturer_id);
+		debug("device id is 0x%x\n", info->device_id);
+		debug("device id2 is 0x%x\n", info->device_id2);
+		debug("cfi version is 0x%04x\n", info->cfi_version);

 		size_ratio = info->portwidth / info->chipwidth;
 		/* if the chip is x8/x16 reduce the ratio by half */
@@ -2157,7 +2157,7 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 		    && (info->chipwidth == FLASH_CFI_BY8)) {
 			size_ratio >>= 1;
 		}
-		debug ("size_ratio %d port %d bits chip %d bits\n",
+		debug("size_ratio %d port %d bits chip %d bits\n",
 		       size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
 		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		info->size = 1 << qry.dev_size;
@@ -2168,12 +2168,12 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 			debug("[truncated from %ldMiB]", info->size >> 20);
 			info->size = max_size;
 		}
-		debug ("found %d erase regions\n", num_erase_regions);
+		debug("found %d erase regions\n", num_erase_regions);
 		sect_cnt = 0;
 		sector = base;
 		for (i = 0; i < num_erase_regions; i++) {
 			if (i > NUM_ERASE_REGIONS) {
-				printf ("%d erase regions found, only %d used\n",
+				printf("%d erase regions found, only %d used\n",
 					num_erase_regions, NUM_ERASE_REGIONS);
 				break;
 			}
@@ -2186,7 +2186,7 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 			tmp >>= 16;
 			erase_region_size =
 				(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
-			debug ("erase_region_count = %d erase_region_size = %d\n",
+			debug("erase_region_count = %d erase_region_size = %d\n",
 				erase_region_count, erase_region_size);
 			for (j = 0; j < erase_region_count; j++) {
 				if (sector - base >= info->size)
@@ -2217,7 +2217,7 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 					flash_write_cmd(info, sect_cnt, 0,
 							FLASH_CMD_READ_ID);
 					info->protect[sect_cnt] =
-						flash_isset (info, sect_cnt,
+						flash_isset(info, sect_cnt,
 							     FLASH_OFFSET_PROTECT,
 							     FLASH_STATUS_PROTECT);
 					flash_write_cmd(info, sect_cnt, 0,
@@ -2274,7 +2274,7 @@ ulong flash_get_size (phys_addr_t base, int banknum)
 			info->portwidth >>= 1;
 		}

-		flash_write_cmd (info, 0, 0, info->cmd_reset);
+		flash_write_cmd(info, 0, 0, info->cmd_reset);
 	}

 	return (info->size);
@@ -2362,7 +2362,7 @@ static void flash_protect_default(void)
 #endif
 }

-unsigned long flash_init (void)
+unsigned long flash_init(void)
 {
 	unsigned long size = 0;
 	int i;
@@ -2390,7 +2390,7 @@ unsigned long flash_init (void)
 		size += flash_info[i].size;
 		if (flash_info[i].flash_id == FLASH_UNKNOWN) {
 #ifndef CONFIG_SYS_FLASH_QUIET_TEST
-			printf ("## Unknown flash on Bank %d "
+			printf("## Unknown flash on Bank %d "
 				"- Size = 0x%08lx = %ld MB\n",
 				i+1, flash_info[i].size,
 				flash_info[i].size >> 20);
@@ -2422,7 +2422,7 @@ unsigned long flash_init (void)
 				 * unlock only one sector. This will
 				 * unlock all sectors.
 				 */
-				flash_real_protect (&flash_info[i], 0, 0);
+				flash_real_protect(&flash_info[i], 0, 0);

 				flash_info[i].legacy_unlock = 1;

@@ -2436,7 +2436,7 @@ unsigned long flash_init (void)
 				/*
 				 * No legancy unlocking -> unlock all sectors
 				 */
-				flash_protect (FLAG_PROTECT_CLEAR,
+				flash_protect(FLAG_PROTECT_CLEAR,
 					       flash_info[i].start[0],
 					       flash_info[i].start[0]
 					       + flash_info[i].size - 1,
--
2.11.0

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

* [U-Boot] [PATCH v3 02/26] cfi_flash: Fix style of pointer declarations
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 03/26] cfi_flash: Fix Parenthesis spacing Mario Six
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

In a pointer declaration there should not be a space between the
asterisk and the pointer name. Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 0dc7f4a6ba..a1b217cc0c 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -204,7 +204,7 @@ unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect)
  * create an address based on the offset and the port width
  */
 static inline void *
-flash_map(flash_info_t * info, flash_sect_t sect, uint offset)
+flash_map(flash_info_t *info, flash_sect_t sect, uint offset)
 {
 	unsigned int byte_offset = offset * info->portwidth;

@@ -283,7 +283,7 @@ static void flash_printqry(struct cfi_qry *qry)
 /*-----------------------------------------------------------------------
  * read a character at a port width address
  */
-static inline uchar flash_read_uchar(flash_info_t * info, uint offset)
+static inline uchar flash_read_uchar(flash_info_t *info, uint offset)
 {
 	uchar *cp;
 	uchar retval;
@@ -301,7 +301,7 @@ static inline uchar flash_read_uchar(flash_info_t * info, uint offset)
 /*-----------------------------------------------------------------------
  * read a word at a port width address, assume 16bit bus
  */
-static inline ushort flash_read_word(flash_info_t * info, uint offset)
+static inline ushort flash_read_word(flash_info_t *info, uint offset)
 {
 	ushort *addr, retval;

@@ -316,7 +316,7 @@ static inline ushort flash_read_word(flash_info_t * info, uint offset)
  * read a long word by picking the least significant byte of each maximum
  * port size word. Swap for ppc format.
  */
-static ulong flash_read_long (flash_info_t * info, flash_sect_t sect,
+static ulong flash_read_long (flash_info_t *info, flash_sect_t sect,
 			      uint offset)
 {
 	uchar *addr;
@@ -402,7 +402,7 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 	flash_unmap(info, sect, offset, addr);
 }

-static void flash_unlock_seq(flash_info_t * info, flash_sect_t sect)
+static void flash_unlock_seq(flash_info_t *info, flash_sect_t sect)
 {
 	flash_write_cmd(info, sect, info->addr_unlock1, AMD_CMD_UNLOCK_START);
 	flash_write_cmd(info, sect, info->addr_unlock2, AMD_CMD_UNLOCK_ACK);
@@ -410,7 +410,7 @@ static void flash_unlock_seq(flash_info_t * info, flash_sect_t sect)

 /*-----------------------------------------------------------------------
  */
-static int flash_isequal(flash_info_t * info, flash_sect_t sect,
+static int flash_isequal(flash_info_t *info, flash_sect_t sect,
 			  uint offset, uchar cmd)
 {
 	void *addr;
@@ -458,7 +458,7 @@ static int flash_isequal(flash_info_t * info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_isset(flash_info_t * info, flash_sect_t sect,
+static int flash_isset(flash_info_t *info, flash_sect_t sect,
 			uint offset, uchar cmd)
 {
 	void *addr;
@@ -491,7 +491,7 @@ static int flash_isset(flash_info_t * info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_toggle(flash_info_t * info, flash_sect_t sect,
+static int flash_toggle(flash_info_t *info, flash_sect_t sect,
 			 uint offset, uchar cmd)
 {
 	void *addr;
@@ -529,7 +529,7 @@ static int flash_toggle(flash_info_t * info, flash_sect_t sect,
  * This routine checks the status of the chip and returns true if the
  * chip is busy.
  */
-static int flash_is_busy(flash_info_t * info, flash_sect_t sect)
+static int flash_is_busy(flash_info_t *info, flash_sect_t sect)
 {
 	int retval;

@@ -566,7 +566,7 @@ static int flash_is_busy(flash_info_t * info, flash_sect_t sect)
  *  wait for XSR.7 to be set. Time out with an error if it does not.
  *  This routine does not set the flash to read-array mode.
  */
-static int flash_status_check(flash_info_t * info, flash_sect_t sector,
+static int flash_status_check(flash_info_t *info, flash_sect_t sector,
 			       ulong tout, char *prompt)
 {
 	ulong start;
@@ -604,7 +604,7 @@ static int flash_status_check(flash_info_t * info, flash_sect_t sector,
  *
  * This routine sets the flash to read-array mode.
  */
-static int flash_full_status_check(flash_info_t * info, flash_sect_t sector,
+static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
 				    ulong tout, char *prompt)
 {
 	int retcode;
@@ -709,7 +709,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,

 /*-----------------------------------------------------------------------
  */
-static void flash_add_byte(flash_info_t * info, cfiword_t * cword, uchar c)
+static void flash_add_byte(flash_info_t *info, cfiword_t *cword, uchar c)
 {
 #if defined(__LITTLE_ENDIAN) && !defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 	unsigned short	w;
@@ -755,7 +755,7 @@ static void flash_add_byte(flash_info_t * info, cfiword_t * cword, uchar c)
  * Loop through the sector table starting from the previously found sector.
  * Searches forwards or backwards, dependent on the passed address.
  */
-static flash_sect_t find_sector(flash_info_t * info, ulong addr)
+static flash_sect_t find_sector(flash_info_t *info, ulong addr)
 {
 	static flash_sect_t saved_sector; /* previously found sector */
 	static flash_info_t *saved_info; /* previously used flash bank */
@@ -781,7 +781,7 @@ static flash_sect_t find_sector(flash_info_t * info, ulong addr)

 /*-----------------------------------------------------------------------
  */
-static int flash_write_cfiword(flash_info_t * info, ulong dest,
+static int flash_write_cfiword(flash_info_t *info, ulong dest,
 				cfiword_t cword)
 {
 	void *dstaddr = (void *)dest;
@@ -869,7 +869,7 @@ static int flash_write_cfiword(flash_info_t * info, ulong dest,

 #ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE

-static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp,
+static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 				  int len)
 {
 	flash_sect_t sector;
@@ -1051,7 +1051,7 @@ out_unmap:

 /*-----------------------------------------------------------------------
  */
-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)
 {
 	int rcode = 0;
 	int prot;
@@ -1200,7 +1200,7 @@ static int sector_erased(flash_info_t *info, int i)
 }
 #endif /* CONFIG_SYS_FLASH_EMPTY_INFO */

-void flash_print_info(flash_info_t * info)
+void flash_print_info(flash_info_t *info)
 {
 	int i;

@@ -1315,7 +1315,7 @@ void flash_print_info(flash_info_t * info)
  * 1 - write timeout
  * 2 - Flash not erased
  */
-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 wp;
 	uchar *p;
@@ -1475,7 +1475,7 @@ static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 	return 0;
 }

-int flash_real_protect(flash_info_t * info, long sector, int prot)
+int flash_real_protect(flash_info_t *info, long sector, int prot)
 {
 	int retcode = 0;

@@ -1601,7 +1601,7 @@ int flash_real_protect(flash_info_t * info, long sector, int prot)
 /*-----------------------------------------------------------------------
  * flash_read_user_serial - read the OneTimeProgramming cells
  */
-void flash_read_user_serial(flash_info_t * info, void *buffer, int offset,
+void flash_read_user_serial(flash_info_t *info, void *buffer, int offset,
 			     int len)
 {
 	uchar *src;
@@ -1619,7 +1619,7 @@ void flash_read_user_serial(flash_info_t * info, void *buffer, int offset,
 /*
  * flash_read_factory_serial - read the device Id from the protection area
  */
-void flash_read_factory_serial(flash_info_t * info, void *buffer, int offset,
+void flash_read_factory_serial(flash_info_t *info, void *buffer, int offset,
 				int len)
 {
 	uchar *src;
@@ -1771,7 +1771,7 @@ static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 }

 #ifdef CONFIG_FLASH_CFI_LEGACY
-static void flash_read_jedec_ids(flash_info_t * info)
+static void flash_read_jedec_ids(flash_info_t *info)
 {
 	info->manufacturer_id = 0;
 	info->device_id       = 0;
@@ -1890,7 +1890,7 @@ static void __flash_cmd_reset(flash_info_t *info)
 void flash_cmd_reset(flash_info_t *info)
 	__attribute__((weak,alias("__flash_cmd_reset")));

-static int __flash_detect_cfi(flash_info_t * info, struct cfi_qry *qry)
+static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 {
 	int cfi_offset;

@@ -1944,7 +1944,7 @@ static int __flash_detect_cfi(flash_info_t * info, struct cfi_qry *qry)
 	return 0;
 }

-static int flash_detect_cfi(flash_info_t * info, struct cfi_qry *qry)
+static int flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 {
 	debug("flash detect cfi\n");

--
2.11.0

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

* [U-Boot] [PATCH v3 03/26] cfi_flash: Fix Parenthesis spacing
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 02/26] cfi_flash: Fix style of pointer declarations Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 04/26] cfi_flash: Fix whitespace with casting Mario Six
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

There should not be additional spaces when nesting parentheses
("( (...) )"). Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index a1b217cc0c..e8f1739254 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -230,7 +230,7 @@ static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 	uchar val;
 	uchar *cp = (uchar *) cmdbuf;

-	for (i = info->portwidth; i > 0; i--){
+	for (i = info->portwidth; i > 0; i--) {
 		cword_offset = (info->portwidth-i)%info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 		cp_offset = info->portwidth - i;
@@ -511,8 +511,8 @@ static int flash_toggle(flash_info_t *info, flash_sect_t sect,
 		retval = flash_read32(addr) != flash_read32(addr);
 		break;
 	case FLASH_CFI_64BIT:
-		retval = ( (flash_read32( addr ) != flash_read32( addr )) ||
-			   (flash_read32(addr+4) != flash_read32(addr+4)) );
+		retval = ((flash_read32(addr) != flash_read32(addr)) ||
+			   (flash_read32(addr+4) != flash_read32(addr+4)));
 		break;
 	default:
 		retval = 0;
@@ -1719,7 +1719,7 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 		info->sr_supported = feature & 0x1;
 	}

-	switch (info->chipwidth){
+	switch (info->chipwidth) {
 	case FLASH_CFI_8BIT:
 		info->device_id = flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID);
@@ -1838,7 +1838,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 			}
 		}

-		switch(info->vendor) {
+		switch (info->vendor) {
 		case CFI_CMDSET_INTEL_PROG_REGIONS:
 		case CFI_CMDSET_INTEL_STANDARD:
 		case CFI_CMDSET_INTEL_EXTENDED:
@@ -1925,12 +1925,12 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 			 * modify the unlock address if we are
 			 * in compatibility mode
 			 */
-			if (	/* x8/x16 in x8 mode */
-				((info->chipwidth == FLASH_CFI_BY8) &&
-					(info->interface == FLASH_CFI_X8X16)) ||
-				/* x16/x32 in x16 mode */
-				((info->chipwidth == FLASH_CFI_BY16) &&
-					(info->interface == FLASH_CFI_X16X32)))
+			if (/* x8/x16 in x8 mode */
+			    ((info->chipwidth == FLASH_CFI_BY8) &&
+				(info->interface == FLASH_CFI_X8X16)) ||
+			    /* x16/x32 in x16 mode */
+			    ((info->chipwidth == FLASH_CFI_BY16) &&
+				(info->interface == FLASH_CFI_X16X32)))
 			{
 				info->addr_unlock1 = 0xaaa;
 				info->addr_unlock2 = 0x555;
--
2.11.0

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

* [U-Boot] [PATCH v3 04/26] cfi_flash: Fix whitespace with casting
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 02/26] cfi_flash: Fix style of pointer declarations Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 03/26] cfi_flash: Fix Parenthesis spacing Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 05/26] cfi_flash: Fix indent of case statements Mario Six
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

When casting to a pointer type, the asterisk should be attached to the
type name, not separated by a space. Fix all instances where this
occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e8f1739254..2dc6b09cd9 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -234,10 +234,10 @@ static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 		cword_offset = (info->portwidth-i)%info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 		cp_offset = info->portwidth - i;
-		val = *((uchar*)&cmd_le + cword_offset);
+		val = *((uchar *)&cmd_le + cword_offset);
 #else
 		cp_offset = i - 1;
-		val = *((uchar*)&cmd + sizeof(u32) - cword_offset - 1);
+		val = *((uchar *)&cmd + sizeof(u32) - cword_offset - 1);
 #endif
 		cp[cp_offset] = (cword_offset >= sizeof(u32)) ? 0x00 : val;
 	}
--
2.11.0

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

* [U-Boot] [PATCH v3 05/26] cfi_flash: Fix indent of case statements
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (2 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 04/26] cfi_flash: Fix whitespace with casting Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 06/26] cfi_flash: Fix spacing around casts/operators Mario Six
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

case statements should be at the same level of indent as the switch
keyword. Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 200 ++++++++++++++++++++++++------------------------
 1 file changed, 100 insertions(+), 100 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 2dc6b09cd9..b77fd3c0a2 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1220,29 +1220,29 @@ void flash_print_info(flash_info_t *info)
 			info->size >> 20, info->sector_count);
 	printf("  ");
 	switch (info->vendor) {
-		case CFI_CMDSET_INTEL_PROG_REGIONS:
-			printf("Intel Prog Regions");
-			break;
-		case CFI_CMDSET_INTEL_STANDARD:
-			printf("Intel Standard");
-			break;
-		case CFI_CMDSET_INTEL_EXTENDED:
-			printf("Intel Extended");
-			break;
-		case CFI_CMDSET_AMD_STANDARD:
-			printf("AMD Standard");
-			break;
-		case CFI_CMDSET_AMD_EXTENDED:
-			printf("AMD Extended");
-			break;
+	case CFI_CMDSET_INTEL_PROG_REGIONS:
+		printf("Intel Prog Regions");
+		break;
+	case CFI_CMDSET_INTEL_STANDARD:
+		printf("Intel Standard");
+		break;
+	case CFI_CMDSET_INTEL_EXTENDED:
+		printf("Intel Extended");
+		break;
+	case CFI_CMDSET_AMD_STANDARD:
+		printf("AMD Standard");
+		break;
+	case CFI_CMDSET_AMD_EXTENDED:
+		printf("AMD Extended");
+		break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
-		case CFI_CMDSET_AMD_LEGACY:
-			printf("AMD Legacy");
-			break;
+	case CFI_CMDSET_AMD_LEGACY:
+		printf("AMD Legacy");
+		break;
 #endif
-		default:
-			printf("Unknown (%d)", info->vendor);
-			break;
+	default:
+		printf("Unknown (%d)", info->vendor);
+		break;
 	}
 	printf(" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
 		info->manufacturer_id);
@@ -1480,94 +1480,94 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 	int retcode = 0;

 	switch (info->vendor) {
-		case CFI_CMDSET_INTEL_PROG_REGIONS:
-		case CFI_CMDSET_INTEL_STANDARD:
-		case CFI_CMDSET_INTEL_EXTENDED:
-			if (!cfi_protect_bugfix(info, sector, prot)) {
+	case CFI_CMDSET_INTEL_PROG_REGIONS:
+	case CFI_CMDSET_INTEL_STANDARD:
+	case CFI_CMDSET_INTEL_EXTENDED:
+		if (!cfi_protect_bugfix(info, sector, prot)) {
+			flash_write_cmd(info, sector, 0,
+				 FLASH_CMD_CLEAR_STATUS);
+			flash_write_cmd(info, sector, 0,
+				FLASH_CMD_PROTECT);
+			if (prot)
 				flash_write_cmd(info, sector, 0,
-					 FLASH_CMD_CLEAR_STATUS);
+					FLASH_CMD_PROTECT_SET);
+			else
 				flash_write_cmd(info, sector, 0,
-					FLASH_CMD_PROTECT);
-				if (prot)
-					flash_write_cmd(info, sector, 0,
-						FLASH_CMD_PROTECT_SET);
-				else
-					flash_write_cmd(info, sector, 0,
-						FLASH_CMD_PROTECT_CLEAR);
+					FLASH_CMD_PROTECT_CLEAR);

+		}
+		break;
+	case CFI_CMDSET_AMD_EXTENDED:
+	case CFI_CMDSET_AMD_STANDARD:
+		/* U-Boot only checks the first byte */
+		if (manufact_match(info, ATM_MANUFACT)) {
+			if (prot) {
+				flash_unlock_seq(info, 0);
+				flash_write_cmd(info, 0,
+						info->addr_unlock1,
+						ATM_CMD_SOFTLOCK_START);
+				flash_unlock_seq(info, 0);
+				flash_write_cmd(info, sector, 0,
+						ATM_CMD_LOCK_SECT);
+			} else {
+				flash_write_cmd(info, 0,
+						info->addr_unlock1,
+						AMD_CMD_UNLOCK_START);
+				if (info->device_id == ATM_ID_BV6416)
+					flash_write_cmd(info, sector,
+						0, ATM_CMD_UNLOCK_SECT);
 			}
-			break;
-		case CFI_CMDSET_AMD_EXTENDED:
-		case CFI_CMDSET_AMD_STANDARD:
-			/* U-Boot only checks the first byte */
-			if (manufact_match(info, ATM_MANUFACT)) {
-				if (prot) {
-					flash_unlock_seq(info, 0);
-					flash_write_cmd(info, 0,
-							info->addr_unlock1,
-							ATM_CMD_SOFTLOCK_START);
-					flash_unlock_seq(info, 0);
+		}
+		if (info->legacy_unlock) {
+			int flag = disable_interrupts();
+			int lock_flag;
+
+			flash_unlock_seq(info, 0);
+			flash_write_cmd(info, 0, info->addr_unlock1,
+					AMD_CMD_SET_PPB_ENTRY);
+			lock_flag = flash_isset(info, sector, 0, 0x01);
+			if (prot) {
+				if (lock_flag) {
 					flash_write_cmd(info, sector, 0,
-							ATM_CMD_LOCK_SECT);
-				} else {
-					flash_write_cmd(info, 0,
-							info->addr_unlock1,
-							AMD_CMD_UNLOCK_START);
-					if (info->device_id == ATM_ID_BV6416)
-						flash_write_cmd(info, sector,
-							0, ATM_CMD_UNLOCK_SECT);
+						AMD_CMD_PPB_LOCK_BC1);
+					flash_write_cmd(info, sector, 0,
+						AMD_CMD_PPB_LOCK_BC2);
 				}
-			}
-			if (info->legacy_unlock) {
-				int flag = disable_interrupts();
-				int lock_flag;
-
-				flash_unlock_seq(info, 0);
-				flash_write_cmd(info, 0, info->addr_unlock1,
-						AMD_CMD_SET_PPB_ENTRY);
-				lock_flag = flash_isset(info, sector, 0, 0x01);
-				if (prot) {
-					if (lock_flag) {
-						flash_write_cmd(info, sector, 0,
-							AMD_CMD_PPB_LOCK_BC1);
-						flash_write_cmd(info, sector, 0,
-							AMD_CMD_PPB_LOCK_BC2);
-					}
-					debug("sector %ld %slocked\n", sector,
-						lock_flag ? "" : "already ");
-				} else {
-					if (!lock_flag) {
-						debug("unlock %ld\n", sector);
-						flash_write_cmd(info, 0, 0,
-							AMD_CMD_PPB_UNLOCK_BC1);
-						flash_write_cmd(info, 0, 0,
-							AMD_CMD_PPB_UNLOCK_BC2);
-					}
-					debug("sector %ld %sunlocked\n", sector,
-						!lock_flag ? "" : "already ");
+				debug("sector %ld %slocked\n", sector,
+					lock_flag ? "" : "already ");
+			} else {
+				if (!lock_flag) {
+					debug("unlock %ld\n", sector);
+					flash_write_cmd(info, 0, 0,
+						AMD_CMD_PPB_UNLOCK_BC1);
+					flash_write_cmd(info, 0, 0,
+						AMD_CMD_PPB_UNLOCK_BC2);
 				}
-				if (flag)
-					enable_interrupts();
-
-				if (flash_status_check(info, sector,
-						info->erase_blk_tout,
-						prot ? "protect" : "unprotect"))
-					printf("status check error\n");
-
-				flash_write_cmd(info, 0, 0,
-						AMD_CMD_SET_PPB_EXIT_BC1);
-				flash_write_cmd(info, 0, 0,
-						AMD_CMD_SET_PPB_EXIT_BC2);
+				debug("sector %ld %sunlocked\n", sector,
+					!lock_flag ? "" : "already ");
 			}
-			break;
+			if (flag)
+				enable_interrupts();
+
+			if (flash_status_check(info, sector,
+					info->erase_blk_tout,
+					prot ? "protect" : "unprotect"))
+				printf("status check error\n");
+
+			flash_write_cmd(info, 0, 0,
+					AMD_CMD_SET_PPB_EXIT_BC1);
+			flash_write_cmd(info, 0, 0,
+					AMD_CMD_SET_PPB_EXIT_BC2);
+		}
+		break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
-		case CFI_CMDSET_AMD_LEGACY:
-			flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
-			if (prot)
-				flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
-			else
-				flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
+	case CFI_CMDSET_AMD_LEGACY:
+		flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
+		flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
+		if (prot)
+			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
+		else
+			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
 #endif
 	};

--
2.11.0

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

* [U-Boot] [PATCH v3 06/26] cfi_flash: Fix spacing around casts/operators
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (3 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 05/26] cfi_flash: Fix indent of case statements Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 07/26] cfi_flash: Fix missing/superfluous lines Mario Six
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

There should be spaces around operators, and no spaces between a cast
and the variable its being applied to. Fix all instances where this
occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index b77fd3c0a2..0d58914e44 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -231,7 +231,7 @@ static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 	uchar *cp = (uchar *) cmdbuf;

 	for (i = info->portwidth; i > 0; i--) {
-		cword_offset = (info->portwidth-i)%info->chipwidth;
+		cword_offset = (info->portwidth - i) % info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 		cp_offset = info->portwidth - i;
 		val = *((uchar *)&cmd_le + cword_offset);
@@ -252,7 +252,7 @@ static void print_longlong(char *str, unsigned long long data)
 	int i;
 	char *cp;

-	cp = (char *) &data;
+	cp = (char *)&data;
 	for (i = 0; i < 8; i++)
 		sprintf(&str[i * 2], "%2.2x", *cp++);
 }
@@ -512,7 +512,7 @@ static int flash_toggle(flash_info_t *info, flash_sect_t sect,
 		break;
 	case FLASH_CFI_64BIT:
 		retval = ((flash_read32(addr) != flash_read32(addr)) ||
-			   (flash_read32(addr+4) != flash_read32(addr+4)));
+			   (flash_read32(addr + 4) != flash_read32(addr + 4)));
 		break;
 	default:
 		retval = 0;
@@ -1212,7 +1212,7 @@ void flash_print_info(flash_info_t *info)
 	printf("%s flash (%d x %d)",
 		info->name,
 		(info->portwidth << 3), (info->chipwidth << 3));
-	if (info->size < 1024*1024)
+	if (info->size < 1024 * 1024)
 		printf("  Size: %ld kB in %d Sectors\n",
 			info->size >> 10, info->sector_count);
 	else
@@ -1888,7 +1888,7 @@ static void __flash_cmd_reset(flash_info_t *info)
 	flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
 }
 void flash_cmd_reset(flash_info_t *info)
-	__attribute__((weak,alias("__flash_cmd_reset")));
+	__attribute__((weak, alias("__flash_cmd_reset")));

 static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 {
@@ -2035,7 +2035,7 @@ static void flash_fixup_sst(flash_info_t *info, struct cfi_qry *qry)
 	if (info->device_id == 0x5D23 || /* SST39VF3201B */
 	    info->device_id == 0x5C23) { /* SST39VF3202B */
 		/* set sector granularity to 4KB */
-		info->cmd_erase_sector=0x50;
+		info->cmd_erase_sector = 0x50;
 	}
 }

@@ -2093,9 +2093,9 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 		num_erase_regions = qry.num_erase_regions;

 		if (info->ext_addr) {
-			info->cfi_version = (ushort) flash_read_uchar(info,
+			info->cfi_version = (ushort)flash_read_uchar(info,
 						info->ext_addr + 3) << 8;
-			info->cfi_version |= (ushort) flash_read_uchar(info,
+			info->cfi_version |= (ushort)flash_read_uchar(info,
 						info->ext_addr + 4);
 		}

@@ -2392,7 +2392,7 @@ unsigned long flash_init(void)
 #ifndef CONFIG_SYS_FLASH_QUIET_TEST
 			printf("## Unknown flash on Bank %d "
 				"- Size = 0x%08lx = %ld MB\n",
-				i+1, flash_info[i].size,
+				i + 1, flash_info[i].size,
 				flash_info[i].size >> 20);
 #endif /* CONFIG_SYS_FLASH_QUIET_TEST */
 		}
--
2.11.0

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

* [U-Boot] [PATCH v3 07/26] cfi_flash: Fix missing/superfluous lines
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (4 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 06/26] cfi_flash: Fix spacing around casts/operators Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 08/26] cfi_flash: Remove braces for single-statement blocks Mario Six
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

There should be no consecutive blank lines, and no blank lines at the
end of blocks. But there should be blank lines between variable
declarations and code. Fix all instances where either occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 0d58914e44..9cc1b2b16f 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -269,6 +269,7 @@ static void flash_printqry(struct cfi_qry *qry)
 		debug(" ");
 		for (y = 0; y < 16; y++) {
 			unsigned char c = p[x + y];
+
 			if (c >= 0x20 && c <= 0x7e)
 				debug("%c", c);
 			else
@@ -279,7 +280,6 @@ static void flash_printqry(struct cfi_qry *qry)
 }
 #endif

-
 /*-----------------------------------------------------------------------
  * read a character@a port width address
  */
@@ -311,7 +311,6 @@ static inline ushort flash_read_word(flash_info_t *info, uint offset)
 	return retval;
 }

-
 /*-----------------------------------------------------------------------
  * read a long word by picking the least significant byte of each maximum
  * port size word. Swap for ppc format.
@@ -356,7 +355,6 @@ static ulong flash_read_long (flash_info_t *info, flash_sect_t sect,
 static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 			    uint offset, u32 cmd)
 {
-
 	void *addr;
 	cfiword_t cword;

@@ -1048,7 +1046,6 @@ out_unmap:
 }
 #endif /* CONFIG_SYS_FLASH_USE_BUFFER_WRITE */

-
 /*-----------------------------------------------------------------------
  */
 int flash_erase(flash_info_t *info, int s_first, int s_last)
@@ -1080,7 +1077,6 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 		putc('\n');
 	}

-
 	for (sect = s_first; sect <= s_last; sect++) {
 		if (ctrlc()) {
 			printf("\n");
@@ -1154,6 +1150,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 			if (use_flash_status_poll(info)) {
 				cfiword_t cword;
 				void *dest;
+
 				cword.w64 = 0xffffffffffffffffULL;
 				dest = flash_map(info, sect, 0);
 				st = flash_status_poll(info, &cword, dest,
@@ -1494,7 +1491,6 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 			else
 				flash_write_cmd(info, sector, 0,
 					FLASH_CMD_PROTECT_CLEAR);
-
 		}
 		break;
 	case CFI_CMDSET_AMD_EXTENDED:
@@ -1579,7 +1575,6 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 	if ((retcode =
 	     flash_full_status_check(info, sector, info->erase_blk_tout,
 				      prot ? "protect" : "unprotect")) == 0) {
-
 		info->protect[sector] = prot;

 		/*
@@ -1887,6 +1882,7 @@ static void __flash_cmd_reset(flash_info_t *info)
 	udelay(1);
 	flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
 }
+
 void flash_cmd_reset(flash_info_t *info)
 	__attribute__((weak, alias("__flash_cmd_reset")));

@@ -2370,6 +2366,7 @@ unsigned long flash_init(void)
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 	/* read environment from EEPROM */
 	char s[64];
+
 	env_get_f("unlock", s, sizeof(s));
 #endif

--
2.11.0

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

* [U-Boot] [PATCH v3 08/26] cfi_flash: Remove braces for single-statement blocks
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (5 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 07/26] cfi_flash: Fix missing/superfluous lines Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 09/26] cfi_flash: Fix logical continuations Mario Six
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

Blocks with a single statement should not be enclosed in braces. Fix all
instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 9cc1b2b16f..e2469055b8 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -329,9 +329,8 @@ static ulong flash_read_long (flash_info_t *info, flash_sect_t sect,
 #ifdef DEBUG
 	debug("long addr is at %p info->portwidth = %d\n", addr,
 	       info->portwidth);
-	for (x = 0; x < 4 * info->portwidth; x++) {
+	for (x = 0; x < 4 * info->portwidth; x++)
 		debug("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
-	}
 #endif
 #if defined(__LITTLE_ENDIAN) || defined(CONFIG_SYS_WRITE_SWAPPED_DATA)
 	retval = ((flash_read8(addr) << 16) |
@@ -1065,11 +1064,9 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 	}

 	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",
 			prot);
@@ -1396,9 +1393,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 #else
 	while (cnt >= info->portwidth) {
 		cword.w32 = 0;
-		for (i = 0; i < info->portwidth; i++) {
+		for (i = 0; i < info->portwidth; i++)
 			flash_add_byte(info, &cword, *src++);
-		}
 		if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
 			return rc;
 		wp += info->portwidth;
@@ -1410,9 +1406,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 	}
 #endif /* CONFIG_SYS_FLASH_USE_BUFFER_WRITE */

-	if (cnt == 0) {
+	if (cnt == 0)
 		return (0);
-	}

 	/*
 	 * handle unaligned tail bytes
--
2.11.0

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

* [U-Boot] [PATCH v3 09/26] cfi_flash: Fix logical continuations
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (6 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 08/26] cfi_flash: Remove braces for single-statement blocks Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 10/26] cfi_flash: Use __func__ macro instead of function name Mario Six
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

When splitting long logical statements across multiple lines, the
logical operators should be at the end of the lines. Fix all instances
where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e2469055b8..eebd641e36 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -611,8 +611,8 @@ static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
 	case CFI_CMDSET_INTEL_EXTENDED:
 	case CFI_CMDSET_INTEL_STANDARD:
-		if ((retcode == ERR_OK)
-		    && !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
+		if ((retcode == ERR_OK) &&
+			!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
 			retcode = ERR_INVAL;
 			printf("Flash %s error at address %lx\n", prompt,
 				info->start[sector]);
@@ -761,8 +761,8 @@ static flash_sect_t find_sector(flash_info_t *info, ulong addr)
 	if ((info != saved_info) || (sector >= info->sector_count))
 		sector = 0;

-	while ((info->start[sector] < addr)
-			&& (sector < info->sector_count - 1))
+	while ((info->start[sector] < addr) &&
+		(sector < info->sector_count - 1))
 		sector++;
 	while ((info->start[sector] > addr) && (sector > 0))
 		/*
@@ -1435,8 +1435,8 @@ static inline int manufact_match(flash_info_t *info, u32 manu)

 static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 {
-	if (manufact_match(info, INTEL_MANUFACT)
-	    && info->device_id == NUMONYX_256MBIT) {
+	if (manufact_match(info, INTEL_MANUFACT) &&
+		info->device_id == NUMONYX_256MBIT) {
 		/*
 		 * see errata called
 		 * "Numonyx Axcell P33/P30 Specification Update" :)
@@ -1807,8 +1807,8 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 					(ulong)map_physmem(base,
 							   info->portwidth,
 							   MAP_NOCACHE);
-				if (info->portwidth == FLASH_CFI_8BIT
-					&& info->interface == FLASH_CFI_X8X16) {
+				if (info->portwidth == FLASH_CFI_8BIT &&
+					info->interface == FLASH_CFI_X8X16) {
 					info->addr_unlock1 = 0x2AAA;
 					info->addr_unlock2 = 0x5555;
 				} else {
@@ -1892,9 +1892,9 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 	     cfi_offset++) {
 		flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
 				 FLASH_CMD_CFI);
-		if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
-		    && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
-		    && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
+		if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q') &&
+			flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R') &&
+			flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
 			flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
 					sizeof(struct cfi_qry));
 			info->interface	= le16_to_cpu(qry->interface_desc);
@@ -2144,8 +2144,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)

 		size_ratio = info->portwidth / info->chipwidth;
 		/* if the chip is x8/x16 reduce the ratio by half */
-		if ((info->interface == FLASH_CFI_X8X16)
-		    && (info->chipwidth == FLASH_CFI_BY8)) {
+		if ((info->interface == FLASH_CFI_X8X16) &&
+			(info->chipwidth == FLASH_CFI_BY8)) {
 			size_ratio >>= 1;
 		}
 		debug("size_ratio %d port %d bits chip %d bits\n",
--
2.11.0

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

* [U-Boot] [PATCH v3 10/26] cfi_flash: Use __func__ macro instead of function name
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (7 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 09/26] cfi_flash: Fix logical continuations Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 11/26] cfi_flash: Fix comment style Mario Six
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

printf/debug statements should not include the file name as a hardcoded
string, but instead use the __func__ macro. Fix all instances where this
occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index eebd641e36..6ae1ac871f 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -555,7 +555,7 @@ static int flash_is_busy(flash_info_t *info, flash_sect_t sect)
 	default:
 		retval = 0;
 	}
-	debug("flash_is_busy: %d\n", retval);
+	debug("%s: %d\n", __func__, retval);
 	return retval;
 }

--
2.11.0

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

* [U-Boot] [PATCH v3 11/26] cfi_flash: Fix comment style
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (8 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 10/26] cfi_flash: Use __func__ macro instead of function name Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 12/26] cfi_flash: Remove unnecessary braces Mario Six
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

Comment blocks should end with a "*/" on a separate line, not with the
"*/" attached to the end of the last line of text. Fix all instances
where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 6ae1ac871f..a21c407ed7 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -946,7 +946,8 @@ static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 					      "write to buffer");
 		if (retcode == ERR_OK) {
 			/* reduce the number of loops by the width of
-			 * the port */
+			 * the port
+			 */
 			cnt = len >> shift;
 			flash_write_cmd(info, sector, 0, cnt - 1);
 			while (cnt-- > 0) {
@@ -1793,7 +1794,8 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)

 	if (board_flash_get_legacy(base, banknum, info)) {
 		/* board code may have filled info completely. If not, we
-		   use JEDEC ID probing. */
+		 * use JEDEC ID probing.
+		 */
 		if (!info->vendor) {
 			int modes[] = {
 				CFI_CMDSET_AMD_STANDARD,
--
2.11.0

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

* [U-Boot] [PATCH v3 12/26] cfi_flash: Remove unnecessary braces
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (9 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 11/26] cfi_flash: Fix comment style Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 13/26] cfi_flash: Add missing braces in blocks Mario Six
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

"==" and "!=" bind tighter than the boolean operators, so parentheses
around them in compound logical statements are unnecessary. Fix all
instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index a21c407ed7..0a24e9173a 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -611,7 +611,7 @@ static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
 	case CFI_CMDSET_INTEL_EXTENDED:
 	case CFI_CMDSET_INTEL_STANDARD:
-		if ((retcode == ERR_OK) &&
+		if (retcode == ERR_OK &&
 			!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
 			retcode = ERR_INVAL;
 			printf("Flash %s error at address %lx\n", prompt,
@@ -758,7 +758,7 @@ static flash_sect_t find_sector(flash_info_t *info, ulong addr)
 	static flash_info_t *saved_info; /* previously used flash bank */
 	flash_sect_t sector = saved_sector;

-	if ((info != saved_info) || (sector >= info->sector_count))
+	if (info != saved_info || sector >= info->sector_count)
 		sector = 0;

 	while ((info->start[sector] < addr) &&
@@ -1059,7 +1059,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 		puts("Can't erase unknown flash type - aborted\n");
 		return 1;
 	}
-	if ((s_first < 0) || (s_first > s_last)) {
+	if (s_first < 0 || s_first > s_last) {
 		puts("- no sectors to erase\n");
 		return 1;
 	}
@@ -1247,7 +1247,7 @@ void flash_print_info(flash_info_t *info)
 		printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
 		info->device_id2);
 	}
-	if ((info->vendor == CFI_CMDSET_AMD_STANDARD) && (info->legacy_unlock))
+	if (info->vendor == CFI_CMDSET_AMD_STANDARD && info->legacy_unlock)
 		printf("\n  Advanced Sector Protection (PPB) enabled");
 	printf("\n  Erase timeout: %ld ms, write timeout: %ld ms\n",
 		info->erase_blk_tout,
@@ -1291,7 +1291,7 @@ void flash_print_info(flash_info_t *info)
 #define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
 	if (flash_verbose) { \
 		dots -= dots_sub; \
-		if ((scale > 0) && (dots <= 0)) { \
+		if (scale > 0 && dots <= 0) { \
 			if ((digit % 5) == 0) \
 				printf("%d", digit / 5); \
 			else \
@@ -1577,7 +1577,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 		 * On some of Intel's flash chips (marked via legacy_unlock)
 		 * unprotect unprotects all locking.
 		 */
-		if ((prot == 0) && (info->legacy_unlock)) {
+		if (prot == 0 && info->legacy_unlock) {
 			flash_sect_t i;

 			for (i = 0; i < info->sector_count; i++) {
@@ -1636,10 +1636,10 @@ static void cfi_reverse_geometry(struct cfi_qry *qry)
 	u32 tmp;

 	for (i = 0, j = qry->num_erase_regions - 1; i < j; i++, j--) {
-		tmp = get_unaligned(&(qry->erase_region_info[i]));
-		put_unaligned(get_unaligned(&(qry->erase_region_info[j])),
-			      &(qry->erase_region_info[i]));
-		put_unaligned(tmp, &(qry->erase_region_info[j]));
+		tmp = get_unaligned(&qry->erase_region_info[i]);
+		put_unaligned(get_unaligned(&qry->erase_region_info[j]),
+			      &qry->erase_region_info[i]);
+		put_unaligned(tmp, &qry->erase_region_info[j]);
 	}
 }

@@ -1919,11 +1919,11 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 			 * in compatibility mode
 			 */
 			if (/* x8/x16 in x8 mode */
-			    ((info->chipwidth == FLASH_CFI_BY8) &&
-				(info->interface == FLASH_CFI_X8X16)) ||
+			    (info->chipwidth == FLASH_CFI_BY8 &&
+				info->interface == FLASH_CFI_X8X16) ||
 			    /* x16/x32 in x16 mode */
-			    ((info->chipwidth == FLASH_CFI_BY16) &&
-				(info->interface == FLASH_CFI_X16X32)))
+			    (info->chipwidth == FLASH_CFI_BY16 &&
+				info->interface == FLASH_CFI_X16X32))
 			{
 				info->addr_unlock1 = 0xaaa;
 				info->addr_unlock2 = 0x555;
@@ -2040,8 +2040,8 @@ static void flash_fixup_num(flash_info_t *info, struct cfi_qry *qry)
 	 * There's an app note from Numonyx on this issue.
 	 * So adjust the buffer size for M29EW while operating in 8-bit mode
 	 */
-	if (((qry->max_buf_write_size) > 0x8) &&
-			(info->device_id == 0x7E) &&
+	if (qry->max_buf_write_size > 0x8 &&
+			info->device_id == 0x7E &&
 			(info->device_id2 == 0x2201 ||
 			info->device_id2 == 0x2301 ||
 			info->device_id2 == 0x2801 ||
@@ -2081,8 +2081,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 	info->start[0] = (ulong)map_physmem(base, info->portwidth, MAP_NOCACHE);

 	if (flash_detect_cfi(info, &qry)) {
-		info->vendor = le16_to_cpu(get_unaligned(&(qry.p_id)));
-		info->ext_addr = le16_to_cpu(get_unaligned(&(qry.p_adr)));
+		info->vendor = le16_to_cpu(get_unaligned(&qry.p_id));
+		info->ext_addr = le16_to_cpu(get_unaligned(&qry.p_adr));
 		num_erase_regions = qry.num_erase_regions;

 		if (info->ext_addr) {
@@ -2146,8 +2146,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)

 		size_ratio = info->portwidth / info->chipwidth;
 		/* if the chip is x8/x16 reduce the ratio by half */
-		if ((info->interface == FLASH_CFI_X8X16) &&
-			(info->chipwidth == FLASH_CFI_BY8)) {
+		if (info->interface == FLASH_CFI_X8X16 &&
+			info->chipwidth == FLASH_CFI_BY8) {
 			size_ratio >>= 1;
 		}
 		debug("size_ratio %d port %d bits chip %d bits\n",
@@ -2157,7 +2157,7 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 		/* multiply the size by the number of chips */
 		info->size *= size_ratio;
 		max_size = cfi_flash_bank_size(banknum);
-		if (max_size && (info->size > max_size)) {
+		if (max_size && info->size > max_size) {
 			debug("[truncated from %ldMiB]", info->size >> 20);
 			info->size = max_size;
 		}
@@ -2172,7 +2172,7 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 			}

 			tmp = le32_to_cpu(get_unaligned(
-						&(qry.erase_region_info[i])));
+						&qry.erase_region_info[i]));
 			debug("erase region %u: 0x%08lx\n", i, tmp);

 			erase_region_count = (tmp & 0xffff) + 1;
@@ -2261,8 +2261,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 		/* round up when converting to ms */
 		info->write_tout = (tmp + 999) / 1000;
 		info->flash_id = FLASH_MAN_CFI;
-		if ((info->interface == FLASH_CFI_X8X16) &&
-		    (info->chipwidth == FLASH_CFI_BY8)) {
+		if (info->interface == FLASH_CFI_X8X16 &&
+		    info->chipwidth == FLASH_CFI_BY8) {
 			/* XXX - Need to test on x8/x16 in parallel. */
 			info->portwidth >>= 1;
 		}
--
2.11.0

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

* [U-Boot] [PATCH v3 13/26] cfi_flash: Add missing braces in blocks
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (10 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 12/26] cfi_flash: Remove unnecessary braces Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 14/26] cfi_flash: Fix spelling of "Unknown" Mario Six
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

In if/else statements, either both blocks (if and else) should have
braces or both blocks should not have braces, but mixed configurations
are discouraged. Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 0a24e9173a..53842443eb 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1154,10 +1154,12 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 				st = flash_status_poll(info, &cword, dest,
 						       info->erase_blk_tout, "erase");
 				flash_unmap(info, sect, 0, dest);
-			} else
+			} else {
 				st = flash_full_status_check(info, sect,
 							     info->erase_blk_tout,
 							     "erase");
+			}
+
 			if (st)
 				rcode = 1;
 			else if (flash_verbose)
--
2.11.0

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

* [U-Boot] [PATCH v3 14/26] cfi_flash: Fix spelling of "Unknown"
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (11 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 13/26] cfi_flash: Add missing braces in blocks Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 15/26] cfi_flash: Fix else after break Mario Six
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

"Unkown" should be spelled "Unknown".

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 53842443eb..4c5e1568e6 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1140,7 +1140,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 				break;
 #endif
 			default:
-				debug("Unkown flash vendor %d\n",
+				debug("Unknown flash vendor %d\n",
 				       info->vendor);
 				break;
 			}
--
2.11.0

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

* [U-Boot] [PATCH v3 15/26] cfi_flash: Fix else after break
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (12 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 14/26] cfi_flash: Fix spelling of "Unknown" Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 16/26] cfi_flash: Fix placement of brace Mario Six
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

If in a loop, the if block in a if/else statement ends in a break, the
statements in the else blockcan be extracted, since the break stops the
execution.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 4c5e1568e6..5b3c071b30 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1826,9 +1826,9 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 						info->device_id2);
 				if (jedec_flash_match(info, info->start[0]))
 					break;
-				else
-					unmap_physmem((void *)info->start[0],
-						      info->portwidth);
+
+				unmap_physmem((void *)info->start[0],
+					      info->portwidth);
 			}
 		}

--
2.11.0

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

* [U-Boot] [PATCH v3 16/26] cfi_flash: Fix placement of brace
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (13 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 15/26] cfi_flash: Fix else after break Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 17/26] cfi_flash: Remove return from void function Mario Six
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

The opening brace of block statements should be attached to the
statement itself, and not be on a separate line.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 5b3c071b30..7aa379b0d8 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1925,8 +1925,7 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 				info->interface == FLASH_CFI_X8X16) ||
 			    /* x16/x32 in x16 mode */
 			    (info->chipwidth == FLASH_CFI_BY16 &&
-				info->interface == FLASH_CFI_X16X32))
-			{
+				info->interface == FLASH_CFI_X16X32)) {
 				info->addr_unlock1 = 0xaaa;
 				info->addr_unlock2 = 0x555;
 			}
--
2.11.0

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

* [U-Boot] [PATCH v3 17/26] cfi_flash: Remove return from void function
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (14 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 16/26] cfi_flash: Fix placement of brace Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 18/26] cfi_flash: Remove assignments from if conditions Mario Six
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

void functions don't need an explicit return at the end.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 7aa379b0d8..d16357343f 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1280,7 +1280,6 @@ void flash_print_info(flash_info_t *info)
 #endif
 	}
 	putc('\n');
-	return;
 }

 /*-----------------------------------------------------------------------
--
2.11.0

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

* [U-Boot] [PATCH v3 18/26] cfi_flash: Remove assignments from if conditions
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (15 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 17/26] cfi_flash: Remove return from void function Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 19/26] cfi_flash: Use u8 pointers instead of void pointers Mario Six
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

The condition in if statements should not be used for variable
assignment. Instead, the assignment should be done in a separate step
beforehand. Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index d16357343f..48086ded5c 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1339,7 +1339,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 	wp = (addr & ~(info->portwidth - 1));

 	/* handle unaligned start */
-	if ((aln = addr - wp) != 0) {
+	aln = addr - wp;
+	if (aln != 0) {
 		cword.w32 = 0;
 		p = (uchar *)wp;
 		for (i = 0; i < aln; ++i)
@@ -1370,7 +1371,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 			cword.w32 = 0;
 			for (i = 0; i < info->portwidth; i++)
 				flash_add_byte(info, &cword, *src++);
-			if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
+			rc = flash_write_cfiword(info, wp, cword);
+			if (rc != 0)
 				return rc;
 			wp += info->portwidth;
 			cnt -= info->portwidth;
@@ -1381,7 +1383,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 		i = buffered_size - (wp % buffered_size);
 		if (i > cnt)
 			i = cnt;
-		if ((rc = flash_write_cfibuffer(info, wp, src, i)) != ERR_OK)
+		rc = flash_write_cfibuffer(info, wp, src, i);
+		if (rc != ERR_OK)
 			return rc;
 		i -= i & (info->portwidth - 1);
 		wp += i;
@@ -1397,7 +1400,8 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 		cword.w32 = 0;
 		for (i = 0; i < info->portwidth; i++)
 			flash_add_byte(info, &cword, *src++);
-		if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
+		rc = flash_write_cfiword(info, wp, cword);
+		if (rc != 0)
 			return rc;
 		wp += info->portwidth;
 		cnt -= info->portwidth;
@@ -1569,9 +1573,9 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 	 * flash_full_status_check() to work correctly
 	 */
 	flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
-	if ((retcode =
-	     flash_full_status_check(info, sector, info->erase_blk_tout,
-				      prot ? "protect" : "unprotect")) == 0) {
+	retcode = flash_full_status_check(info, sector, info->erase_blk_tout,
+				      prot ? "protect" : "unprotect");
+	if (retcode == 0) {
 		info->protect[sector] = prot;

 		/*
--
2.11.0

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

* [U-Boot] [PATCH v3 19/26] cfi_flash: Use u8 pointers instead of void pointers
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (16 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 18/26] cfi_flash: Remove assignments from if conditions Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 20/26] cfi_flash: Fix strings split across lines Mario Six
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

According to the C standard, pointer arithmetic for pointers of type
void is undefined behavior (the assumption that they're 8-bit wide is a
GCC-specific assumption). In the interest of keeping the code
standards-compliant, and also better communicate intent, switch all
void* variables where pointer arithmetic is used to u8* variables.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 48086ded5c..fced9847ef 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -491,7 +491,7 @@ static int flash_isset(flash_info_t *info, flash_sect_t sect,
 static int flash_toggle(flash_info_t *info, flash_sect_t sect,
 			 uint offset, uchar cmd)
 {
-	void *addr;
+	u8 *addr;
 	cfiword_t cword;
 	int retval;

@@ -872,9 +872,9 @@ static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 	flash_sect_t sector;
 	int cnt;
 	int retcode;
-	void *src = cp;
-	void *dst = (void *)dest;
-	void *dst2 = dst;
+	u8 *src = cp;
+	u8 *dst = (u8 *)dest;
+	u8 *dst2 = dst;
 	int flag = 1;
 	uint offset = 0;
 	unsigned int shift;
--
2.11.0

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

* [U-Boot] [PATCH v3 20/26] cfi_flash: Fix strings split across lines
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (17 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 19/26] cfi_flash: Use u8 pointers instead of void pointers Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 21/26] cfi_flash: Rename camel-case variables Mario Six
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

Strings should not be split accross multiple lines. Where possible and
not detrimental to readability, fix the instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index fced9847ef..8040e43de7 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1255,10 +1255,9 @@ void flash_print_info(flash_info_t *info)
 		info->erase_blk_tout,
 		info->write_tout);
 	if (info->buffer_size > 1) {
-		printf("  Buffer write timeout: %ld ms, "
-			"buffer size: %d bytes\n",
-		info->buffer_write_tout,
-		info->buffer_size);
+		printf("  Buffer write timeout: %ld ms, ",
+			info->buffer_write_tout);
+		printf("buffer size: %d bytes\n", info->buffer_size);
 	}

 	puts("\n  Sector Start Addresses:");
@@ -2050,8 +2049,8 @@ static void flash_fixup_num(flash_info_t *info, struct cfi_qry *qry)
 			info->device_id2 == 0x2301 ||
 			info->device_id2 == 0x2801 ||
 			info->device_id2 == 0x4801)) {
-		debug("Adjusted buffer size on Numonyx flash"
-			" M29EW family in 8 bit mode\n");
+		debug("Adjusted buffer size on Numonyx flash");
+		debug(" M29EW family in 8 bit mode\n");
 		qry->max_buf_write_size = 0x8;
 	}
 }
@@ -2388,9 +2387,9 @@ unsigned long flash_init(void)
 		size += flash_info[i].size;
 		if (flash_info[i].flash_id == FLASH_UNKNOWN) {
 #ifndef CONFIG_SYS_FLASH_QUIET_TEST
-			printf("## Unknown flash on Bank %d "
-				"- Size = 0x%08lx = %ld MB\n",
-				i + 1, flash_info[i].size,
+			printf("## Unknown flash on Bank %d ", i + 1);
+			printf("- Size = 0x%08lx = %ld MB\n",
+				flash_info[i].size,
 				flash_info[i].size >> 20);
 #endif /* CONFIG_SYS_FLASH_QUIET_TEST */
 		}
--
2.11.0

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

* [U-Boot] [PATCH v3 21/26] cfi_flash: Rename camel-case variables
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (18 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 20/26] cfi_flash: Fix strings split across lines Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 22/26] flash: Fix spelling of "ERR_TIMOUT" Mario Six
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

Camel-case naming should be avoided. Rename two camel-case variables,
and fix their usage accordingly.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 8040e43de7..e94a7269e1 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1687,8 +1687,8 @@ static int cmdset_intel_init(flash_info_t *info, struct cfi_qry *qry)

 static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 {
-	ushort bankId = 0;
-	uchar  manuId;
+	ushort bank_id = 0;
+	uchar  manu_id;
 	uchar  feature;

 	flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
@@ -1696,14 +1696,14 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	flash_write_cmd(info, 0, info->addr_unlock1, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */

-	manuId = flash_read_uchar(info, FLASH_OFFSET_MANUFACTURER_ID);
+	manu_id = flash_read_uchar(info, FLASH_OFFSET_MANUFACTURER_ID);
 	/* JEDEC JEP106Z specifies ID codes up to bank 7 */
-	while (manuId == FLASH_CONTINUATION_CODE && bankId < 0x800) {
-		bankId += 0x100;
-		manuId = flash_read_uchar(info,
-			bankId | FLASH_OFFSET_MANUFACTURER_ID);
+	while (manu_id == FLASH_CONTINUATION_CODE && bank_id < 0x800) {
+		bank_id += 0x100;
+		manu_id = flash_read_uchar(info,
+			bank_id | FLASH_OFFSET_MANUFACTURER_ID);
 	}
-	info->manufacturer_id = manuId;
+	info->manufacturer_id = manu_id;

 	debug("info->ext_addr = 0x%x, cfi_version = 0x%x\n",
 	      info->ext_addr, info->cfi_version);
--
2.11.0

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

* [U-Boot] [PATCH v3 22/26] flash: Fix spelling of "ERR_TIMOUT"
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (19 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 21/26] cfi_flash: Rename camel-case variables Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 23/26] cfi_flash: Bound-check index before array access Mario Six
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

checkpatch.pl complains about the spelling of ERR_TIMOUT. Since the
error is only used in a handful of files, we rename the error to
ERR_TIMEOUT.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 board/cobra5272/flash.c   | 2 +-
 common/flash.c            | 4 ++--
 drivers/mtd/cfi_flash.c   | 4 ++--
 drivers/mtd/pic32_flash.c | 6 +++---
 include/flash.h           | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c
index 4fac6880f1..ca27b49a3b 100644
--- a/board/cobra5272/flash.c
+++ b/board/cobra5272/flash.c
@@ -216,7 +216,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 				goto outahere;
 			}
 			if (chip1 == TMO) {
-				rc = ERR_TIMOUT;
+				rc = ERR_TIMEOUT;
 				goto outahere;
 			}

diff --git a/common/flash.c b/common/flash.c
index 587ef60158..876677493f 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -112,7 +112,7 @@ addr2info (ulong addr)
  * and no protected sectors are hit.
  * Returns:
  * ERR_OK          0 - OK
- * ERR_TIMOUT      1 - write timeout
+ * ERR_TIMEOUT     1 - write timeout
  * ERR_NOT_ERASED  2 - Flash not erased
  * ERR_PROTECTED   4 - target range includes protected sectors
  * ERR_INVAL       8 - target address not in Flash memory
@@ -185,7 +185,7 @@ void flash_perror (int err)
 	switch (err) {
 	case ERR_OK:
 		break;
-	case ERR_TIMOUT:
+	case ERR_TIMEOUT:
 		puts ("Timeout writing to Flash\n");
 		break;
 	case ERR_NOT_ERASED:
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e94a7269e1..5ba0c5fdec 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -588,7 +588,7 @@ static int flash_status_check(flash_info_t *info, flash_sect_t sector,
 				flash_read_long(info, sector, 0));
 			flash_write_cmd(info, sector, 0, info->cmd_reset);
 			udelay(1);
-			return ERR_TIMOUT;
+			return ERR_TIMEOUT;
 		}
 		udelay(1);		/* also triggers watchdog */
 	}
@@ -696,7 +696,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 		if (get_timer(start) > tout) {
 			printf("Flash %s timeout at address %lx data %lx\n",
 			       prompt, (ulong)dst, (ulong)flash_read8(dst));
-			return ERR_TIMOUT;
+			return ERR_TIMEOUT;
 		}
 		udelay(1);		/* also triggers watchdog */
 	}
diff --git a/drivers/mtd/pic32_flash.c b/drivers/mtd/pic32_flash.c
index e1a8d3bc4b..a6a5d1cc2e 100644
--- a/drivers/mtd/pic32_flash.c
+++ b/drivers/mtd/pic32_flash.c
@@ -69,7 +69,7 @@ static int flash_wait_till_busy(const char *func, ulong timeout)
 	int ret = wait_for_bit(__func__, &nvm_regs_p->ctrl.raw,
 			       NVM_WR, false, timeout, false);

-	return ret ? ERR_TIMOUT : ERR_OK;
+	return ret ? ERR_TIMEOUT : ERR_OK;
 }

 static inline int flash_complete_operation(void)
@@ -99,7 +99,7 @@ static inline int flash_complete_operation(void)
  * Erase flash sectors, returns:
  * ERR_OK - OK
  * ERR_INVAL - invalid sector arguments
- * ERR_TIMOUT - write timeout
+ * ERR_TIMEOUT - write timeout
  * ERR_NOT_ERASED - Flash not erased
  * ERR_UNKNOWN_FLASH_VENDOR - incorrect flash
  */
@@ -217,7 +217,7 @@ static int write_word(flash_info_t *info, ulong dest, ulong word)
 /*
  * Copy memory to flash, returns:
  * ERR_OK - OK
- * ERR_TIMOUT - write timeout
+ * ERR_TIMEOUT - write timeout
  * ERR_NOT_ERASED - Flash not erased
  */
 int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
diff --git a/include/flash.h b/include/flash.h
index dc67cb2df6..1a4e879009 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -122,7 +122,7 @@ extern int jedec_flash_match(flash_info_t *info, ulong base);
  * return codes from flash_write():
  */
 #define ERR_OK				0
-#define ERR_TIMOUT			1
+#define ERR_TIMEOUT			1
 #define ERR_NOT_ERASED			2
 #define ERR_PROTECTED			4
 #define ERR_INVAL			8
--
2.11.0

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

* [U-Boot] [PATCH v3 23/26] cfi_flash: Bound-check index before array access
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (20 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 22/26] flash: Fix spelling of "ERR_TIMOUT" Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 24/26] cfi_flash: Fix long lines Mario Six
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

In a while loop in cfi_flash.c the array "start" is accessed at the index
"sector" before the index variable "sector" is bounds-checked, which
might lead to accesses beyond the bounds of the array.

Swap the order of the checks in the "&&" expression, so that the
short-circuit evaluation prevents out-of-bounds array accesses.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 5ba0c5fdec..61c2e6379d 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -761,8 +761,8 @@ static flash_sect_t find_sector(flash_info_t *info, ulong addr)
 	if (info != saved_info || sector >= info->sector_count)
 		sector = 0;

-	while ((info->start[sector] < addr) &&
-		(sector < info->sector_count - 1))
+	while ((sector < info->sector_count - 1) &&
+		(info->start[sector] < addr))
 		sector++;
 	while ((info->start[sector] > addr) && (sector > 0))
 		/*
--
2.11.0

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

* [U-Boot] [PATCH v3 24/26] cfi_flash: Fix long lines
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (21 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 23/26] cfi_flash: Bound-check index before array access Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 25/26] cfi_flash: Fix indention Mario Six
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

Long lines (>80 characters) should be avoided where possible. Break up
some long lines where it's not detrimental to readability.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 61c2e6379d..88c47cad90 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -175,7 +175,8 @@ __maybe_weak u64 flash_read64(void *addr)

 /*-----------------------------------------------------------------------
  */
-#if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
+#if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || \
+	(CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
 static flash_info_t *flash_get_info(ulong base)
 {
 	int i;
@@ -569,8 +570,9 @@ static int flash_status_check(flash_info_t *info, flash_sect_t sector,
 	ulong start;

 #if CONFIG_SYS_HZ != 1000
+	/* Avoid overflow for large HZ */
 	if ((ulong)CONFIG_SYS_HZ > 100000)
-		tout *= (ulong)CONFIG_SYS_HZ / 1000;  /* for a big HZ, avoid overflow */
+		tout *= (ulong)CONFIG_SYS_HZ / 1000;
 	else
 		tout = DIV_ROUND_UP(tout * (ulong)CONFIG_SYS_HZ, 1000);
 #endif
@@ -661,8 +663,9 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 	int ready;

 #if CONFIG_SYS_HZ != 1000
+	/* Avoid overflow for large HZ */
 	if ((ulong)CONFIG_SYS_HZ > 100000)
-		tout *= (ulong)CONFIG_SYS_HZ / 1000;  /* for a big HZ, avoid overflow */
+		tout *= (ulong)CONFIG_SYS_HZ / 1000;
 	else
 		tout = DIV_ROUND_UP(tout * (ulong)CONFIG_SYS_HZ, 1000);
 #endif
@@ -937,7 +940,8 @@ static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 	case CFI_CMDSET_INTEL_STANDARD:
 	case CFI_CMDSET_INTEL_EXTENDED:
 		write_cmd = (info->vendor == CFI_CMDSET_INTEL_PROG_REGIONS) ?
-					FLASH_CMD_WRITE_BUFFER_PROG : FLASH_CMD_WRITE_TO_BUFFER;
+			    FLASH_CMD_WRITE_BUFFER_PROG :
+			    FLASH_CMD_WRITE_TO_BUFFER;
 		flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
 		flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
 		flash_write_cmd(info, sector, 0, write_cmd);
@@ -1152,7 +1156,8 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 				cword.w64 = 0xffffffffffffffffULL;
 				dest = flash_map(info, sect, 0);
 				st = flash_status_poll(info, &cword, dest,
-						       info->erase_blk_tout, "erase");
+						       info->erase_blk_tout,
+						       "erase");
 				flash_unmap(info, sect, 0, dest);
 			} else {
 				st = flash_full_status_check(info, sect,
@@ -1561,9 +1566,11 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 		flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
 		flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
 		if (prot)
-			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
+			flash_write_cmd(info, sector, 0,
+					FLASH_CMD_PROTECT_SET);
 		else
-			flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
+			flash_write_cmd(info, sector, 0,
+					FLASH_CMD_PROTECT_CLEAR);
 #endif
 	};

@@ -1899,9 +1906,9 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 		flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
 				 FLASH_CMD_CFI);
 		if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q') &&
-			flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R') &&
-			flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
-			flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
+		    flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R') &&
+		    flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
+		    flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
 					sizeof(struct cfi_qry));
 			info->interface	= le16_to_cpu(qry->interface_desc);

@@ -2182,8 +2189,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 			tmp >>= 16;
 			erase_region_size =
 				(tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
-			debug("erase_region_count = %d erase_region_size = %d\n",
-				erase_region_count, erase_region_size);
+			debug("erase_region_count = %d ", erase_region_count);
+			debug("erase_region_size = %d\n", erase_region_size);
 			for (j = 0; j < erase_region_count; j++) {
 				if (sector - base >= info->size)
 					break;
--
2.11.0

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

* [U-Boot] [PATCH v3 25/26] cfi_flash: Fix indention
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (22 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 24/26] cfi_flash: Fix long lines Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 26/26] cfi_flash: Always define cfi_flash_num_flash_banks Mario Six
  2018-01-29 12:30 ` [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Stefan Roese
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

When long expressions surrounded by parentheses are split into multiple
lines, each consecutive line should be aligned with the corresponding
parenthesis. Fix all instances where this occurs.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 238 ++++++++++++++++++++++++------------------------
 1 file changed, 118 insertions(+), 120 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 88c47cad90..347382f529 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -213,7 +213,7 @@ flash_map(flash_info_t *info, flash_sect_t sect, uint offset)
 }

 static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
-		unsigned int offset, void *addr)
+			       unsigned int offset, void *addr)
 {
 }

@@ -329,7 +329,7 @@ static ulong flash_read_long (flash_info_t *info, flash_sect_t sect,

 #ifdef DEBUG
 	debug("long addr is at %p info->portwidth = %d\n", addr,
-	       info->portwidth);
+	      info->portwidth);
 	for (x = 0; x < 4 * info->portwidth; x++)
 		debug("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
 #endif
@@ -363,19 +363,19 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
 		debug("fwc addr %p cmd %x %x 8bit x %d bit\n", addr, cmd,
-		       cword.w8, info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+		      cword.w8, info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write8(cword.w8, addr);
 		break;
 	case FLASH_CFI_16BIT:
 		debug("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr,
-		       cmd, cword.w16,
-		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+		      cmd, cword.w16,
+		      info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write16(cword.w16, addr);
 		break;
 	case FLASH_CFI_32BIT:
 		debug("fwc addr %p cmd %x %8.8x 32bit x %d bit\n", addr,
-		       cmd, cword.w32,
-		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+		      cmd, cword.w32,
+		      info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		flash_write32(cword.w32, addr);
 		break;
 	case FLASH_CFI_64BIT:
@@ -386,8 +386,8 @@ static void flash_write_cmd(flash_info_t *info, flash_sect_t sect,
 			print_longlong(str, cword.w64);

 			debug("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
-			       addr, cmd, str,
-			       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+			      addr, cmd, str,
+			      info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		}
 #endif
 		flash_write64(cword.w64, addr);
@@ -408,8 +408,8 @@ static void flash_unlock_seq(flash_info_t *info, flash_sect_t sect)

 /*-----------------------------------------------------------------------
  */
-static int flash_isequal(flash_info_t *info, flash_sect_t sect,
-			  uint offset, uchar cmd)
+static int flash_isequal(flash_info_t *info, flash_sect_t sect, uint offset,
+			 uchar cmd)
 {
 	void *addr;
 	cfiword_t cword;
@@ -456,8 +456,8 @@ static int flash_isequal(flash_info_t *info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_isset(flash_info_t *info, flash_sect_t sect,
-			uint offset, uchar cmd)
+static int flash_isset(flash_info_t *info, flash_sect_t sect, uint offset,
+		       uchar cmd)
 {
 	void *addr;
 	cfiword_t cword;
@@ -489,8 +489,8 @@ static int flash_isset(flash_info_t *info, flash_sect_t sect,

 /*-----------------------------------------------------------------------
  */
-static int flash_toggle(flash_info_t *info, flash_sect_t sect,
-			 uint offset, uchar cmd)
+static int flash_toggle(flash_info_t *info, flash_sect_t sect, uint offset,
+			uchar cmd)
 {
 	u8 *addr;
 	cfiword_t cword;
@@ -544,12 +544,12 @@ static int flash_is_busy(flash_info_t *info, flash_sect_t sect)
 #endif
 		if (info->sr_supported) {
 			flash_write_cmd(info, sect, info->addr_unlock1,
-					 FLASH_CMD_READ_STATUS);
+					FLASH_CMD_READ_STATUS);
 			retval = !flash_isset(info, sect, 0,
-					       FLASH_STATUS_DONE);
+					      FLASH_STATUS_DONE);
 		} else {
 			retval = flash_toggle(info, sect, 0,
-					       AMD_STATUS_TOGGLE);
+					      AMD_STATUS_TOGGLE);
 		}

 		break;
@@ -565,7 +565,7 @@ static int flash_is_busy(flash_info_t *info, flash_sect_t sect)
  *  This routine does not set the flash to read-array mode.
  */
 static int flash_status_check(flash_info_t *info, flash_sect_t sector,
-			       ulong tout, char *prompt)
+			      ulong tout, char *prompt)
 {
 	ulong start;

@@ -586,8 +586,8 @@ static int flash_status_check(flash_info_t *info, flash_sect_t sector,
 	while (flash_is_busy(info, sector)) {
 		if (get_timer(start) > tout) {
 			printf("Flash %s timeout at address %lx data %lx\n",
-				prompt, info->start[sector],
-				flash_read_long(info, sector, 0));
+			       prompt, info->start[sector],
+			       flash_read_long(info, sector, 0));
 			flash_write_cmd(info, sector, 0, info->cmd_reset);
 			udelay(1);
 			return ERR_TIMEOUT;
@@ -604,7 +604,7 @@ static int flash_status_check(flash_info_t *info, flash_sect_t sector,
  * This routine sets the flash to read-array mode.
  */
 static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
-				    ulong tout, char *prompt)
+				   ulong tout, char *prompt)
 {
 	int retcode;

@@ -614,10 +614,10 @@ static int flash_full_status_check(flash_info_t *info, flash_sect_t sector,
 	case CFI_CMDSET_INTEL_EXTENDED:
 	case CFI_CMDSET_INTEL_STANDARD:
 		if (retcode == ERR_OK &&
-			!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
+		    !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
 			retcode = ERR_INVAL;
 			printf("Flash %s error at address %lx\n", prompt,
-				info->start[sector]);
+			       info->start[sector]);
 			if (flash_isset(info, sector, 0, FLASH_STATUS_ECLBS |
 					 FLASH_STATUS_PSLBS)) {
 				puts("Command Sequence Error.\n");
@@ -765,7 +765,7 @@ static flash_sect_t find_sector(flash_info_t *info, ulong addr)
 		sector = 0;

 	while ((sector < info->sector_count - 1) &&
-		(info->start[sector] < addr))
+	       (info->start[sector] < addr))
 		sector++;
 	while ((info->start[sector] > addr) && (sector > 0))
 		/*
@@ -781,8 +781,7 @@ static flash_sect_t find_sector(flash_info_t *info, ulong addr)

 /*-----------------------------------------------------------------------
  */
-static int flash_write_cfiword(flash_info_t *info, ulong dest,
-				cfiword_t cword)
+static int flash_write_cfiword(flash_info_t *info, ulong dest, cfiword_t cword)
 {
 	void *dstaddr = (void *)dest;
 	int flag;
@@ -870,7 +869,7 @@ static int flash_write_cfiword(flash_info_t *info, ulong dest,
 #ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE

 static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
-				  int len)
+				 int len)
 {
 	flash_sect_t sector;
 	int cnt;
@@ -946,8 +945,8 @@ static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 		flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
 		flash_write_cmd(info, sector, 0, write_cmd);
 		retcode = flash_status_check(info, sector,
-					      info->buffer_write_tout,
-					      "write to buffer");
+					     info->buffer_write_tout,
+					     "write to buffer");
 		if (retcode == ERR_OK) {
 			/* reduce the number of loops by the width of
 			 * the port
@@ -978,7 +977,7 @@ static int flash_write_cfibuffer(flash_info_t *info, ulong dest, uchar *cp,
 				}
 			}
 			flash_write_cmd(info, sector, 0,
-					 FLASH_CMD_WRITE_BUFFER_CONFIRM);
+					FLASH_CMD_WRITE_BUFFER_CONFIRM);
 			retcode = flash_full_status_check(
 				info, sector, info->buffer_write_tout,
 				"buffer write");
@@ -1074,7 +1073,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 			prot++;
 	if (prot) {
 		printf("- Warning: %d protected sectors will not be erased!\n",
-			prot);
+		       prot);
 	} else if (flash_verbose) {
 		putc('\n');
 	}
@@ -1117,11 +1116,11 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 			case CFI_CMDSET_INTEL_STANDARD:
 			case CFI_CMDSET_INTEL_EXTENDED:
 				flash_write_cmd(info, sect, 0,
-						 FLASH_CMD_CLEAR_STATUS);
+						FLASH_CMD_CLEAR_STATUS);
 				flash_write_cmd(info, sect, 0,
-						 FLASH_CMD_BLOCK_ERASE);
+						FLASH_CMD_BLOCK_ERASE);
 				flash_write_cmd(info, sect, 0,
-						 FLASH_CMD_ERASE_CONFIRM);
+						FLASH_CMD_ERASE_CONFIRM);
 				break;
 			case CFI_CMDSET_AMD_STANDARD:
 			case CFI_CMDSET_AMD_EXTENDED:
@@ -1131,7 +1130,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 						AMD_CMD_ERASE_START);
 				flash_unlock_seq(info, sect);
 				flash_write_cmd(info, sect, 0,
-						 info->cmd_erase_sector);
+						info->cmd_erase_sector);
 				break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
 			case CFI_CMDSET_AMD_LEGACY:
@@ -1145,7 +1144,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
 #endif
 			default:
 				debug("Unknown flash vendor %d\n",
-				       info->vendor);
+				      info->vendor);
 				break;
 			}

@@ -1212,14 +1211,14 @@ void flash_print_info(flash_info_t *info)
 	}

 	printf("%s flash (%d x %d)",
-		info->name,
-		(info->portwidth << 3), (info->chipwidth << 3));
+	       info->name,
+	       (info->portwidth << 3), (info->chipwidth << 3));
 	if (info->size < 1024 * 1024)
 		printf("  Size: %ld kB in %d Sectors\n",
-			info->size >> 10, info->sector_count);
+		       info->size >> 10, info->sector_count);
 	else
 		printf("  Size: %ld MB in %d Sectors\n",
-			info->size >> 20, info->sector_count);
+		       info->size >> 20, info->sector_count);
 	printf("  ");
 	switch (info->vendor) {
 	case CFI_CMDSET_INTEL_PROG_REGIONS:
@@ -1247,21 +1246,20 @@ void flash_print_info(flash_info_t *info)
 		break;
 	}
 	printf(" command set, Manufacturer ID: 0x%02X, Device ID: 0x",
-		info->manufacturer_id);
+	       info->manufacturer_id);
 	printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
-		info->device_id);
+	       info->device_id);
 	if ((info->device_id & 0xff) == 0x7E) {
 		printf(info->chipwidth == FLASH_CFI_16BIT ? "%04X" : "%02X",
-		info->device_id2);
+		       info->device_id2);
 	}
 	if (info->vendor == CFI_CMDSET_AMD_STANDARD && info->legacy_unlock)
 		printf("\n  Advanced Sector Protection (PPB) enabled");
 	printf("\n  Erase timeout: %ld ms, write timeout: %ld ms\n",
-		info->erase_blk_tout,
-		info->write_tout);
+	       info->erase_blk_tout, info->write_tout);
 	if (info->buffer_size > 1) {
 		printf("  Buffer write timeout: %ld ms, ",
-			info->buffer_write_tout);
+		       info->buffer_write_tout);
 		printf("buffer size: %d bytes\n", info->buffer_size);
 	}

@@ -1274,13 +1272,13 @@ void flash_print_info(flash_info_t *info)
 #ifdef CONFIG_SYS_FLASH_EMPTY_INFO
 		/* print empty and read-only info */
 		printf("  %08lX %c %s ",
-			info->start[i],
-			sector_erased(info, i) ? 'E' : ' ',
-			info->protect[i] ? "RO" : "  ");
+		       info->start[i],
+		       sector_erased(info, i) ? 'E' : ' ',
+		       info->protect[i] ? "RO" : "  ");
 #else	/* ! CONFIG_SYS_FLASH_EMPTY_INFO */
 		printf("  %08lX   %s ",
-			info->start[i],
-			info->protect[i] ? "RO" : "  ");
+		       info->start[i],
+		       info->protect[i] ? "RO" : "  ");
 #endif
 	}
 	putc('\n');
@@ -1446,7 +1444,7 @@ static inline int manufact_match(flash_info_t *info, u32 manu)
 static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 {
 	if (manufact_match(info, INTEL_MANUFACT) &&
-		info->device_id == NUMONYX_256MBIT) {
+	    info->device_id == NUMONYX_256MBIT) {
 		/*
 		 * see errata called
 		 * "Numonyx Axcell P33/P30 Specification Update" :)
@@ -1487,15 +1485,15 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 	case CFI_CMDSET_INTEL_EXTENDED:
 		if (!cfi_protect_bugfix(info, sector, prot)) {
 			flash_write_cmd(info, sector, 0,
-				 FLASH_CMD_CLEAR_STATUS);
+					FLASH_CMD_CLEAR_STATUS);
 			flash_write_cmd(info, sector, 0,
-				FLASH_CMD_PROTECT);
+					FLASH_CMD_PROTECT);
 			if (prot)
 				flash_write_cmd(info, sector, 0,
-					FLASH_CMD_PROTECT_SET);
+						FLASH_CMD_PROTECT_SET);
 			else
 				flash_write_cmd(info, sector, 0,
-					FLASH_CMD_PROTECT_CLEAR);
+						FLASH_CMD_PROTECT_CLEAR);
 		}
 		break;
 	case CFI_CMDSET_AMD_EXTENDED:
@@ -1516,7 +1514,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 						AMD_CMD_UNLOCK_START);
 				if (info->device_id == ATM_ID_BV6416)
 					flash_write_cmd(info, sector,
-						0, ATM_CMD_UNLOCK_SECT);
+							0, ATM_CMD_UNLOCK_SECT);
 			}
 		}
 		if (info->legacy_unlock) {
@@ -1530,29 +1528,29 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 			if (prot) {
 				if (lock_flag) {
 					flash_write_cmd(info, sector, 0,
-						AMD_CMD_PPB_LOCK_BC1);
+							AMD_CMD_PPB_LOCK_BC1);
 					flash_write_cmd(info, sector, 0,
-						AMD_CMD_PPB_LOCK_BC2);
+							AMD_CMD_PPB_LOCK_BC2);
 				}
 				debug("sector %ld %slocked\n", sector,
-					lock_flag ? "" : "already ");
+				      lock_flag ? "" : "already ");
 			} else {
 				if (!lock_flag) {
 					debug("unlock %ld\n", sector);
 					flash_write_cmd(info, 0, 0,
-						AMD_CMD_PPB_UNLOCK_BC1);
+							AMD_CMD_PPB_UNLOCK_BC1);
 					flash_write_cmd(info, 0, 0,
-						AMD_CMD_PPB_UNLOCK_BC2);
+							AMD_CMD_PPB_UNLOCK_BC2);
 				}
 				debug("sector %ld %sunlocked\n", sector,
-					!lock_flag ? "" : "already ");
+				      !lock_flag ? "" : "already ");
 			}
 			if (flag)
 				enable_interrupts();

 			if (flash_status_check(info, sector,
-					info->erase_blk_tout,
-					prot ? "protect" : "unprotect"))
+					       info->erase_blk_tout,
+					       prot ? "protect" : "unprotect"))
 				printf("status check error\n");

 			flash_write_cmd(info, 0, 0,
@@ -1580,7 +1578,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
 	 */
 	flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
 	retcode = flash_full_status_check(info, sector, info->erase_blk_tout,
-				      prot ? "protect" : "unprotect");
+					  prot ? "protect" : "unprotect");
 	if (retcode == 0) {
 		info->protect[sector] = prot;

@@ -1604,7 +1602,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
  * flash_read_user_serial - read the OneTimeProgramming cells
  */
 void flash_read_user_serial(flash_info_t *info, void *buffer, int offset,
-			     int len)
+			    int len)
 {
 	uchar *src;
 	uchar *dst;
@@ -1622,7 +1620,7 @@ void flash_read_user_serial(flash_info_t *info, void *buffer, int offset,
  * flash_read_factory_serial - read the device Id from the protection area
  */
 void flash_read_factory_serial(flash_info_t *info, void *buffer, int offset,
-				int len)
+			       int len)
 {
 	uchar *src;

@@ -1667,7 +1665,7 @@ static void cmdset_intel_read_jedec_ids(flash_info_t *info)
 	flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
 	udelay(1000); /* some flash are slow to respond */
 	info->manufacturer_id = flash_read_uchar(info,
-					FLASH_OFFSET_MANUFACTURER_ID);
+						 FLASH_OFFSET_MANUFACTURER_ID);
 	info->device_id = (info->chipwidth == FLASH_CFI_16BIT) ?
 			flash_read_word(info, FLASH_OFFSET_DEVICE_ID) :
 			flash_read_uchar(info, FLASH_OFFSET_DEVICE_ID);
@@ -1684,8 +1682,8 @@ static int cmdset_intel_init(flash_info_t *info, struct cfi_qry *qry)
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 	/* read legacy lock/unlock bit from intel flash */
 	if (info->ext_addr) {
-		info->legacy_unlock = flash_read_uchar(info,
-				info->ext_addr + 5) & 0x08;
+		info->legacy_unlock =
+			flash_read_uchar(info, info->ext_addr + 5) & 0x08;
 	}
 #endif

@@ -1708,7 +1706,7 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	while (manu_id == FLASH_CONTINUATION_CODE && bank_id < 0x800) {
 		bank_id += 0x100;
 		manu_id = flash_read_uchar(info,
-			bank_id | FLASH_OFFSET_MANUFACTURER_ID);
+					   bank_id | FLASH_OFFSET_MANUFACTURER_ID);
 	}
 	info->manufacturer_id = manu_id;

@@ -1724,11 +1722,11 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 	switch (info->chipwidth) {
 	case FLASH_CFI_8BIT:
 		info->device_id = flash_read_uchar(info,
-						FLASH_OFFSET_DEVICE_ID);
+						   FLASH_OFFSET_DEVICE_ID);
 		if (info->device_id == 0x7E) {
 			/* AMD 3-byte (expanded) device ids */
 			info->device_id2 = flash_read_uchar(info,
-						FLASH_OFFSET_DEVICE_ID2);
+							    FLASH_OFFSET_DEVICE_ID2);
 			info->device_id2 <<= 8;
 			info->device_id2 |= flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID3);
@@ -1736,11 +1734,11 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 		break;
 	case FLASH_CFI_16BIT:
 		info->device_id = flash_read_word(info,
-						FLASH_OFFSET_DEVICE_ID);
+						  FLASH_OFFSET_DEVICE_ID);
 		if ((info->device_id & 0xff) == 0x7E) {
 			/* AMD 3-byte (expanded) device ids */
 			info->device_id2 = flash_read_uchar(info,
-						FLASH_OFFSET_DEVICE_ID2);
+							    FLASH_OFFSET_DEVICE_ID2);
 			info->device_id2 <<= 8;
 			info->device_id2 |= flash_read_uchar(info,
 						FLASH_OFFSET_DEVICE_ID3);
@@ -1821,7 +1819,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 							   info->portwidth,
 							   MAP_NOCACHE);
 				if (info->portwidth == FLASH_CFI_8BIT &&
-					info->interface == FLASH_CFI_X8X16) {
+				    info->interface == FLASH_CFI_X8X16) {
 					info->addr_unlock1 = 0x2AAA;
 					info->addr_unlock2 = 0x5555;
 				} else {
@@ -1830,9 +1828,9 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 				}
 				flash_read_jedec_ids(info);
 				debug("JEDEC PROBE: ID %x %x %x\n",
-						info->manufacturer_id,
-						info->device_id,
-						info->device_id2);
+				      info->manufacturer_id,
+				      info->device_id,
+				      info->device_id2);
 				if (jedec_flash_match(info, info->start[0]))
 					break;

@@ -1869,8 +1867,8 @@ static inline int flash_detect_legacy(phys_addr_t base, int banknum)
  * detect if flash is compatible with the Common Flash Interface (CFI)
  * http://www.jedec.org/download/search/jesd68.pdf
  */
-static void flash_read_cfi(flash_info_t *info, void *buf,
-		unsigned int start, size_t len)
+static void flash_read_cfi(flash_info_t *info, void *buf, unsigned int start,
+			   size_t len)
 {
 	u8 *p = buf;
 	unsigned int i;
@@ -1904,22 +1902,22 @@ static int __flash_detect_cfi(flash_info_t *info, struct cfi_qry *qry)
 	for (cfi_offset = 0; cfi_offset < ARRAY_SIZE(flash_offset_cfi);
 	     cfi_offset++) {
 		flash_write_cmd(info, 0, flash_offset_cfi[cfi_offset],
-				 FLASH_CMD_CFI);
+				FLASH_CMD_CFI);
 		if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q') &&
 		    flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R') &&
 		    flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
-		    flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
-					sizeof(struct cfi_qry));
+			flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
+				       sizeof(struct cfi_qry));
 			info->interface	= le16_to_cpu(qry->interface_desc);

 			info->cfi_offset = flash_offset_cfi[cfi_offset];
 			debug("device interface is %d\n",
-			       info->interface);
+			      info->interface);
 			debug("found port %d chip %d ",
-			       info->portwidth, info->chipwidth);
+			      info->portwidth, info->chipwidth);
 			debug("port %d bits chip %d bits\n",
-			       info->portwidth << CFI_FLASH_SHIFT_WIDTH,
-			       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+			      info->portwidth << CFI_FLASH_SHIFT_WIDTH,
+			      info->chipwidth << CFI_FLASH_SHIFT_WIDTH);

 			/* calculate command offsets as in the Linux driver */
 			info->addr_unlock1 = 0x555;
@@ -2051,11 +2049,11 @@ static void flash_fixup_num(flash_info_t *info, struct cfi_qry *qry)
 	 * So adjust the buffer size for M29EW while operating in 8-bit mode
 	 */
 	if (qry->max_buf_write_size > 0x8 &&
-			info->device_id == 0x7E &&
-			(info->device_id2 == 0x2201 ||
-			info->device_id2 == 0x2301 ||
-			info->device_id2 == 0x2801 ||
-			info->device_id2 == 0x4801)) {
+	    info->device_id == 0x7E &&
+	    (info->device_id2 == 0x2201 ||
+	     info->device_id2 == 0x2301 ||
+	     info->device_id2 == 0x2801 ||
+	     info->device_id2 == 0x4801)) {
 		debug("Adjusted buffer size on Numonyx flash");
 		debug(" M29EW family in 8 bit mode\n");
 		qry->max_buf_write_size = 0x8;
@@ -2118,7 +2116,7 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 			break;
 		default:
 			printf("CFI: Unknown command set 0x%x\n",
-					info->vendor);
+			       info->vendor);
 			/*
 			 * Unfortunately, this means we don't know how
 			 * to get the chip back to Read mode. Might
@@ -2157,12 +2155,12 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 		size_ratio = info->portwidth / info->chipwidth;
 		/* if the chip is x8/x16 reduce the ratio by half */
 		if (info->interface == FLASH_CFI_X8X16 &&
-			info->chipwidth == FLASH_CFI_BY8) {
+		    info->chipwidth == FLASH_CFI_BY8) {
 			size_ratio >>= 1;
 		}
 		debug("size_ratio %d port %d bits chip %d bits\n",
-		       size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
-		       info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
+		      size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
+		      info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
 		info->size = 1 << qry.dev_size;
 		/* multiply the size by the number of chips */
 		info->size *= size_ratio;
@@ -2177,7 +2175,7 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 		for (i = 0; i < num_erase_regions; i++) {
 			if (i > NUM_ERASE_REGIONS) {
 				printf("%d erase regions found, only %d used\n",
-					num_erase_regions, NUM_ERASE_REGIONS);
+				       num_erase_regions, NUM_ERASE_REGIONS);
 				break;
 			}

@@ -2221,8 +2219,8 @@ ulong flash_get_size(phys_addr_t base, int banknum)
 							FLASH_CMD_READ_ID);
 					info->protect[sect_cnt] =
 						flash_isset(info, sect_cnt,
-							     FLASH_OFFSET_PROTECT,
-							     FLASH_STATUS_PROTECT);
+							    FLASH_OFFSET_PROTECT,
+							    FLASH_STATUS_PROTECT);
 					flash_write_cmd(info, sect_cnt, 0,
 							FLASH_CMD_RESET);
 					break;
@@ -2332,25 +2330,25 @@ static void flash_protect_default(void)
 #if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
 	(!defined(CONFIG_MONITOR_IS_IN_RAM))
 	flash_protect(FLAG_PROTECT_SET,
-		       CONFIG_SYS_MONITOR_BASE,
-		       CONFIG_SYS_MONITOR_BASE + monitor_flash_len  - 1,
-		       flash_get_info(CONFIG_SYS_MONITOR_BASE));
+		      CONFIG_SYS_MONITOR_BASE,
+		      CONFIG_SYS_MONITOR_BASE + monitor_flash_len  - 1,
+		      flash_get_info(CONFIG_SYS_MONITOR_BASE));
 #endif

 	/* Environment protection ON by default */
 #ifdef CONFIG_ENV_IS_IN_FLASH
 	flash_protect(FLAG_PROTECT_SET,
-		       CONFIG_ENV_ADDR,
-		       CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
-		       flash_get_info(CONFIG_ENV_ADDR));
+		      CONFIG_ENV_ADDR,
+		      CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
+		      flash_get_info(CONFIG_ENV_ADDR));
 #endif

 	/* Redundant environment protection ON by default */
 #ifdef CONFIG_ENV_ADDR_REDUND
 	flash_protect(FLAG_PROTECT_SET,
-		       CONFIG_ENV_ADDR_REDUND,
-		       CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
-		       flash_get_info(CONFIG_ENV_ADDR_REDUND));
+		      CONFIG_ENV_ADDR_REDUND,
+		      CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
+		      flash_get_info(CONFIG_ENV_ADDR_REDUND));
 #endif

 #if defined(CONFIG_SYS_FLASH_AUTOPROTECT_LIST)
@@ -2358,9 +2356,9 @@ static void flash_protect_default(void)
 		debug("autoprotecting from %08lx to %08lx\n",
 		      apl[i].start, apl[i].start + apl[i].size - 1);
 		flash_protect(FLAG_PROTECT_SET,
-			       apl[i].start,
-			       apl[i].start + apl[i].size - 1,
-			       flash_get_info(apl[i].start));
+			      apl[i].start,
+			      apl[i].start + apl[i].size - 1,
+			      flash_get_info(apl[i].start));
 	}
 #endif
 }
@@ -2396,8 +2394,8 @@ unsigned long flash_init(void)
 #ifndef CONFIG_SYS_FLASH_QUIET_TEST
 			printf("## Unknown flash on Bank %d ", i + 1);
 			printf("- Size = 0x%08lx = %ld MB\n",
-				flash_info[i].size,
-				flash_info[i].size >> 20);
+			       flash_info[i].size,
+			       flash_info[i].size >> 20);
 #endif /* CONFIG_SYS_FLASH_QUIET_TEST */
 		}
 #ifdef CONFIG_SYS_FLASH_PROTECTION
@@ -2441,10 +2439,10 @@ unsigned long flash_init(void)
 				 * No legancy unlocking -> unlock all sectors
 				 */
 				flash_protect(FLAG_PROTECT_CLEAR,
-					       flash_info[i].start[0],
-					       flash_info[i].start[0]
-					       + flash_info[i].size - 1,
-					       &flash_info[i]);
+					      flash_info[i].start[0],
+					      flash_info[i].start[0]
+					      + flash_info[i].size - 1,
+					      &flash_info[i]);
 			}
 		}
 #endif /* CONFIG_SYS_FLASH_PROTECTION */
--
2.11.0

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

* [U-Boot] [PATCH v3 26/26] cfi_flash: Always define cfi_flash_num_flash_banks
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (23 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 25/26] cfi_flash: Fix indention Mario Six
@ 2018-01-26 13:43 ` Mario Six
  2018-01-29 12:30 ` [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Stefan Roese
  25 siblings, 0 replies; 27+ messages in thread
From: Mario Six @ 2018-01-26 13:43 UTC (permalink / raw)
  To: u-boot

The variable cfi_flash_num_flash_banks is defined iff
CONFIG_SYS_MAX_FLASH_BANKS_DETECT is defined, but it is used
unconditionally in the function cfi_flash_init_dm. This leads to a
undefined variable compile error when CONFIG_SYS_MAX_FLASH_BANKS_DETECT
is not defined, but DM is enabled.

Fix this by always defining the cfi_flash_num_flash_banks variable.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

v2 -> v3:
* Added proper commit message

v1 -> v2:
None

---
 drivers/mtd/cfi_flash.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 347382f529..da44e6184e 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -91,6 +91,8 @@ static u16 cfi_flash_config_reg(int i)

 #if defined(CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
 int cfi_flash_num_flash_banks = CONFIG_SYS_MAX_FLASH_BANKS_DETECT;
+#else
+int cfi_flash_num_flash_banks;
 #endif

 #ifdef CONFIG_CFI_FLASH /* for driver model */
--
2.11.0

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

* [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis
  2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
                   ` (24 preceding siblings ...)
  2018-01-26 13:43 ` [U-Boot] [PATCH v3 26/26] cfi_flash: Always define cfi_flash_num_flash_banks Mario Six
@ 2018-01-29 12:30 ` Stefan Roese
  25 siblings, 0 replies; 27+ messages in thread
From: Stefan Roese @ 2018-01-29 12:30 UTC (permalink / raw)
  To: u-boot

On 26.01.2018 14:43, Mario Six wrote:
> There should not be a space between a function name and a parenthesis
> ("func (...)"). Fix all instances where this occurs.
> 
> Signed-off-by: Mario Six <mario.six@gdsys.cc>
> ---
> 
> v2 -> v3:
> * Added proper commit message
> 
> v1 -> v2:
> None

Many thanks Mario. Travis build is now clean. I've applied all
CFI related to the u-boot-cfi-flash/master branch.

Thanks,
Stefan

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

end of thread, other threads:[~2018-01-29 12:30 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 13:43 [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 02/26] cfi_flash: Fix style of pointer declarations Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 03/26] cfi_flash: Fix Parenthesis spacing Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 04/26] cfi_flash: Fix whitespace with casting Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 05/26] cfi_flash: Fix indent of case statements Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 06/26] cfi_flash: Fix spacing around casts/operators Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 07/26] cfi_flash: Fix missing/superfluous lines Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 08/26] cfi_flash: Remove braces for single-statement blocks Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 09/26] cfi_flash: Fix logical continuations Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 10/26] cfi_flash: Use __func__ macro instead of function name Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 11/26] cfi_flash: Fix comment style Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 12/26] cfi_flash: Remove unnecessary braces Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 13/26] cfi_flash: Add missing braces in blocks Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 14/26] cfi_flash: Fix spelling of "Unknown" Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 15/26] cfi_flash: Fix else after break Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 16/26] cfi_flash: Fix placement of brace Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 17/26] cfi_flash: Remove return from void function Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 18/26] cfi_flash: Remove assignments from if conditions Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 19/26] cfi_flash: Use u8 pointers instead of void pointers Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 20/26] cfi_flash: Fix strings split across lines Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 21/26] cfi_flash: Rename camel-case variables Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 22/26] flash: Fix spelling of "ERR_TIMOUT" Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 23/26] cfi_flash: Bound-check index before array access Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 24/26] cfi_flash: Fix long lines Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 25/26] cfi_flash: Fix indention Mario Six
2018-01-26 13:43 ` [U-Boot] [PATCH v3 26/26] cfi_flash: Always define cfi_flash_num_flash_banks Mario Six
2018-01-29 12:30 ` [U-Boot] [PATCH v3 01/26] cfi_flash: Fix space between function name and parenthesis Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.