From a595a0e910960ccd4611719d5fb5c279859efaee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 May 2020 11:39:53 -0600 Subject: flash: Tidy up coding style for flash functions Some functions use the wrong code style and generate checkpatch errors. Fix these. Signed-off-by: Simon Glass --- cmd/flash.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'cmd/flash.c') diff --git a/cmd/flash.c b/cmd/flash.c index cd1758d7e2e..230d8408a4d 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -88,7 +88,7 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl) /* * Take *addr in Flash and adjust it to fall on the end of its sector */ -int flash_sect_roundb (ulong *addr) +int flash_sect_roundb(ulong *addr) { flash_info_t *info; ulong bank, sector_end_addr; @@ -279,7 +279,7 @@ static int do_flinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) for (bank=0; bank sector_count-1); + rcode = flash_erase(info, 0, info->sector_count - 1); } return rcode; } @@ -370,7 +370,7 @@ static int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; - rcode = flash_erase (info, 0, info->sector_count-1); + rcode = flash_erase(info, 0, info->sector_count - 1); return rcode; } @@ -390,7 +390,7 @@ static int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #ifdef CONFIG_MTD_NOR_FLASH -int flash_sect_erase (ulong addr_first, ulong addr_last) +int flash_sect_erase(ulong addr_first, ulong addr_last) { flash_info_t *info; ulong bank; @@ -415,7 +415,8 @@ int flash_sect_erase (ulong addr_first, ulong addr_last) info->start[0] + info->size - 1: info->start[s_last[bank]+1] - 1, bank+1); - rcode = flash_erase (info, s_first[bank], s_last[bank]); + rcode = flash_erase(info, s_first[bank], + s_last[bank]); } } if (rcode == 0) @@ -526,7 +527,8 @@ static int do_protect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) p ? "" : "Un", argv[1], bank, addr_first, addr_last); - rcode = flash_sect_protect (p, addr_first, addr_last); + rcode = flash_sect_protect(p, addr_first, + addr_last); return rcode; } @@ -580,13 +582,13 @@ static int do_protect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (addr_first >= addr_last) return CMD_RET_USAGE; - rcode = flash_sect_protect (p, addr_first, addr_last); + rcode = flash_sect_protect(p, addr_first, addr_last); #endif /* CONFIG_MTD_NOR_FLASH */ return rcode; } #ifdef CONFIG_MTD_NOR_FLASH -int flash_sect_protect (int p, ulong addr_first, ulong addr_last) +int flash_sect_protect(int p, ulong addr_first, ulong addr_last) { flash_info_t *info; ulong bank; -- cgit v1.2.3 From b79fdc76978515fba2c4f3b5b4f2e679c5ff1463 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 May 2020 11:39:54 -0600 Subject: common: Drop flash.h from common header Move this uncommon header out of the common header. Fix up some style problems in flash.h while we are here. Signed-off-by: Simon Glass --- cmd/flash.c | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/flash.c') diff --git a/cmd/flash.c b/cmd/flash.c index 230d8408a4d..df97fe740d8 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -9,6 +9,7 @@ */ #include #include +#include #if defined(CONFIG_CMD_MTDPARTS) #include -- cgit v1.2.3 From 09140113108541b95d340f3c7b6ee597d31ccc73 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 May 2020 11:40:03 -0600 Subject: command: Remove the cmd_tbl_t typedef We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass --- cmd/flash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cmd/flash.c') diff --git a/cmd/flash.c b/cmd/flash.c index df97fe740d8..452b040dbca 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -269,7 +269,8 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last, } #endif /* CONFIG_MTD_NOR_FLASH */ -static int do_flinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { #ifdef CONFIG_MTD_NOR_FLASH ulong bank; @@ -297,7 +298,8 @@ static int do_flinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } -static int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { #ifdef CONFIG_MTD_NOR_FLASH flash_info_t *info = NULL; @@ -431,7 +433,8 @@ int flash_sect_erase(ulong addr_first, ulong addr_last) } #endif /* CONFIG_MTD_NOR_FLASH */ -static int do_protect(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_protect(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { int rcode = 0; #ifdef CONFIG_MTD_NOR_FLASH -- cgit v1.2.3 From 3c7dded8e179ee213c8267c892720b84a7a59fd5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 May 2020 11:40:04 -0600 Subject: Fix some checkpatch warnings in calls to debug() Fix up some incorrect code style in calls to functions in the log.h header, mostly debug(). Signed-off-by: Simon Glass --- cmd/flash.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'cmd/flash.c') diff --git a/cmd/flash.c b/cmd/flash.c index 452b040dbca..77979e44129 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -411,13 +411,12 @@ int flash_sect_erase(ulong addr_first, ulong addr_last) ++bank, ++info) { if (s_first[bank]>=0) { erased += s_last[bank] - s_first[bank] + 1; - debug ("Erase Flash from 0x%08lx to 0x%08lx " - "in Bank # %ld ", - info->start[s_first[bank]], - (s_last[bank] == info->sector_count) ? - info->start[0] + info->size - 1: - info->start[s_last[bank]+1] - 1, - bank+1); + debug("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ", + info->start[s_first[bank]], + (s_last[bank] == info->sector_count) ? + info->start[0] + info->size - 1 : + info->start[s_last[bank] + 1] - 1, + bank + 1); rcode = flash_erase(info, s_first[bank], s_last[bank]); } @@ -612,9 +611,9 @@ int flash_sect_protect(int p, ulong addr_first, ulong addr_last) } if (s_first[bank]>=0 && s_first[bank]<=s_last[bank]) { - debug ("%sProtecting sectors %d..%d in bank %ld\n", - p ? "" : "Un-", - s_first[bank], s_last[bank], bank+1); + debug("%sProtecting sectors %d..%d in bank %ld\n", + p ? "" : "Un-", s_first[bank], + s_last[bank], bank + 1); protected += s_last[bank] - s_first[bank] + 1; for (i=s_first[bank]; i<=s_last[bank]; ++i) { #if defined(CONFIG_SYS_FLASH_PROTECTION) -- cgit v1.2.3 From f7ae49fc4f363a803dab3be078e93ead8e75a8e9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 May 2020 11:40:05 -0600 Subject: common: Drop log.h from common header Move this header out of the common header. Signed-off-by: Simon Glass --- cmd/flash.c | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/flash.c') diff --git a/cmd/flash.c b/cmd/flash.c index 77979e44129..240871e8089 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #if defined(CONFIG_CMD_MTDPARTS) -- cgit v1.2.3