From patchwork Sun May 10 17:39:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1287257 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FJbZ+XDa; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49KrvH3rBlz9sPB for ; Mon, 11 May 2020 03:40:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F33280679; Sun, 10 May 2020 19:40:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FJbZ+XDa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1268804AB; Sun, 10 May 2020 19:40:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 98D908047E for ; Sun, 10 May 2020 19:40:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id s10so7098332iog.7 for ; Sun, 10 May 2020 10:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cioLzyx6024N7w3phtMrakHYpt6NUbcV0LImtqsVoEs=; b=FJbZ+XDa75jOytTA/LmahQ2KbC1Fx6OYbrQjtqJjKQMXLuUcb9qRq3lChKvrFXzn1n yqb1U24R9wu6l3cALe0NRLnJy8cFaZn2lngX20yqC82HhUNhw83vTebEXdwZxpn1J0Nk WivzIlGRHSAnpO0bxkJcK/A4YTTjorNMcgSfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cioLzyx6024N7w3phtMrakHYpt6NUbcV0LImtqsVoEs=; b=Mx5zXWOtd6QU1OkixUs3RIVJtGhWD4cQppHZOeAmVvHI5Lpuz2E97nEehACEr7AQqv PIwGHHX8UztG1ZqPN9d1s7fviuKRkWQz3LExhrMhtfzD8KiygetEUwPxs1UicaNOb/tg FYp0opkRHtUX/+vqCuibpFMzJi6yGzuxisP+xMyp40T1K7dSjUmXH0e44l8LTT1oU/0S WYB4ekjImLe4eHyg6KtNioi9h8mAQvzgd/GR494dkjZWBy5y0TdolQVeWT3sBjfxeMnV h+c7lT9/LN61fLe0CwSc0+dlRSYEmXDXCdODVGXKfYRZWjrQ41DJ01V8tEJWybHCGeEj kc4w== X-Gm-Message-State: AGi0PuawzEEX3m+l4I7TvtiHhvGBxvyMXt2D65Mg7Wp0i6XIyBFHIETX pK2e5gMLBoNWWMmMu3NMhI+dTq46Di8= X-Google-Smtp-Source: APiQypIMZGhANbPsY+yEwVroLosyMz9qR/714PN14lmpipXmnL8VdXacYu27m2CQy8+oH7g4QqgeXA== X-Received: by 2002:a6b:7203:: with SMTP id n3mr12107812ioc.23.1589132419029; Sun, 10 May 2020 10:40:19 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id n4sm4004314ilh.83.2020.05.10.10.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 10:40:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Masahiro Yamada , Tom Rini , Simon Glass Subject: [PATCH v3 02/22] flash: Tidy up coding style for flash functions Date: Sun, 10 May 2020 11:39:53 -0600 Message-Id: <20200510174013.145466-2-sjg@chromium.org> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog In-Reply-To: <20200510174013.145466-1-sjg@chromium.org> References: <20200510174013.145466-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Some functions use the wrong code style and generate checkpatch errors. Fix these. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Split out code-style changes for flash functions into a new patch arch/arm/mach-at91/arm926ejs/eflash.c | 8 ++++---- board/cobra5272/flash.c | 16 ++++++++-------- board/socrates/socrates.c | 27 ++++++++++++++------------- cmd/flash.c | 22 ++++++++++++---------- common/flash.c | 10 +++++----- include/flash.h | 24 ++++++++++++------------ 6 files changed, 55 insertions(+), 52 deletions(-) diff --git a/arch/arm/mach-at91/arm926ejs/eflash.c b/arch/arm/mach-at91/arm926ejs/eflash.c index 7b61fa7226..cfd6490d9d 100644 --- a/arch/arm/mach-at91/arm926ejs/eflash.c +++ b/arch/arm/mach-at91/arm926ejs/eflash.c @@ -58,7 +58,7 @@ flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; static u32 pagesize; -unsigned long flash_init (void) +unsigned long flash_init(void) { at91_eefc_t *eefc = (at91_eefc_t *) ATMEL_BASE_EEFC; at91_dbu_t *dbu = (at91_dbu_t *) ATMEL_BASE_DBGU; @@ -127,7 +127,7 @@ unsigned long flash_init (void) return size; } -void flash_print_info (flash_info_t *info) +void flash_print_info(flash_info_t *info) { int i; @@ -202,7 +202,7 @@ static u32 erase_write_page (u32 pagenum) & (AT91_EEFC_FSR_FCMDE | AT91_EEFC_FSR_FLOCKE); } -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) { debug("erase first=%d last=%d\n", s_first, s_last); puts("this flash does not need and support erasing!\n"); @@ -215,7 +215,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) * 1 - write timeout */ -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) { u32 pagenum; u32 *src32, *dst32; diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 1d3c5acddf..e601ed8e72 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -14,7 +14,7 @@ flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; -void flash_print_info (flash_info_t * info) +void flash_print_info(flash_info_t *info) { int i; @@ -55,7 +55,7 @@ Done: } -unsigned long flash_init (void) +unsigned long flash_init(void) { int i, j; ulong size = 0; @@ -98,9 +98,9 @@ unsigned long flash_init (void) size += flash_info[i].size; } - flash_protect (FLAG_PROTECT_SET, - CONFIG_SYS_FLASH_BASE, - CONFIG_SYS_FLASH_BASE + 0x3ffff, &flash_info[0]); + flash_protect(FLAG_PROTECT_SET, + CONFIG_SYS_FLASH_BASE, + CONFIG_SYS_FLASH_BASE + 0x3ffff, &flash_info[0]); return size; } @@ -127,7 +127,7 @@ unsigned long flash_init (void) #define TMO 4 -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) { ulong result; int iflag, cflag, prot, sect; @@ -244,7 +244,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) return rc; } -static int write_word (flash_info_t * info, ulong dest, ulong data) +static int write_word(flash_info_t *info, ulong dest, ulong data) { volatile u16 *addr = (volatile u16 *) dest; ulong result; @@ -311,7 +311,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) } -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, data; int rc; diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c index b0ddee7906..bd214acc80 100644 --- a/board/socrates/socrates.c +++ b/board/socrates/socrates.c @@ -105,25 +105,26 @@ int misc_init_r (void) /* * Re-do flash protection upon new addresses */ - flash_protect (FLAG_PROTECT_CLEAR, - gd->bd->bi_flashstart, 0xffffffff, - &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); + flash_protect(FLAG_PROTECT_CLEAR, + gd->bd->bi_flashstart, 0xffffffff, + &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); /* Monitor protection ON by default */ - flash_protect (FLAG_PROTECT_SET, - CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1, - &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); + flash_protect(FLAG_PROTECT_SET, + CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_BASE + + monitor_flash_len - 1, + &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); /* Environment protection ON by default */ - flash_protect (FLAG_PROTECT_SET, - CONFIG_ENV_ADDR, - CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, - &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); + flash_protect(FLAG_PROTECT_SET, + CONFIG_ENV_ADDR, + CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, + &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); /* Redundant environment protection ON by default */ - flash_protect (FLAG_PROTECT_SET, - CONFIG_ENV_ADDR_REDUND, - CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, + flash_protect(FLAG_PROTECT_SET, + CONFIG_ENV_ADDR_REDUND, + CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]); } diff --git a/cmd/flash.c b/cmd/flash.c index cd1758d7e2..230d8408a4 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; diff --git a/common/flash.c b/common/flash.c index 5f155aefd1..9601716c3a 100644 --- a/common/flash.c +++ b/common/flash.c @@ -24,7 +24,7 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ * If necessary you have to map the second bank at lower addresses. */ void -flash_protect (int flag, ulong from, ulong to, flash_info_t *info) +flash_protect(int flag, ulong from, ulong to, flash_info_t *info) { ulong b_end; short s_end; @@ -84,7 +84,7 @@ flash_protect (int flag, ulong from, ulong to, flash_info_t *info) */ flash_info_t * -addr2info (ulong addr) +addr2info(ulong addr) { flash_info_t *info; int i; @@ -119,12 +119,12 @@ addr2info (ulong addr) * (only some targets require alignment) */ int -flash_write (char *src, ulong addr, ulong cnt) +flash_write(char *src, ulong addr, ulong cnt) { int i; ulong end = addr + cnt - 1; - flash_info_t *info_first = addr2info (addr); - flash_info_t *info_last = addr2info (end ); + flash_info_t *info_first = addr2info(addr); + flash_info_t *info_last = addr2info(end); flash_info_t *info; __maybe_unused char *src_orig = src; __maybe_unused char *addr_orig = (char *)addr; diff --git a/include/flash.h b/include/flash.h index 2655c72087..3bf6b22399 100644 --- a/include/flash.h +++ b/include/flash.h @@ -84,20 +84,20 @@ typedef unsigned long flash_sect_t; /* Prototypes */ -extern unsigned long flash_init (void); -extern void flash_print_info (flash_info_t *); -extern int flash_erase (flash_info_t *, int, int); -extern int flash_sect_erase (ulong addr_first, ulong addr_last); -extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last); -extern int flash_sect_roundb (ulong *addr); -extern unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect); -extern void flash_set_verbose(uint); +unsigned long flash_init(void); +void flash_print_info(flash_info_t *info); +int flash_erase(flash_info_t *info, int s_first, int s_last); +int flash_sect_erase(ulong addr_first, ulong addr_last); +int flash_sect_protect(int flag, ulong addr_first, ulong addr_last); +int flash_sect_roundb(ulong *addr); +unsigned long flash_sector_size(flash_info_t *info, flash_sect_t sect); +void flash_set_verbose(uint v); /* common/flash.c */ -extern void flash_protect (int flag, ulong from, ulong to, flash_info_t *info); -extern int flash_write (char *, ulong, ulong); -extern flash_info_t *addr2info (ulong); -extern int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt); +void flash_protect(int flag, ulong from, ulong to, flash_info_t *info); +int flash_write(char *src, ulong addr, ulong cnt); +flash_info_t *addr2info(ulong addr); +int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt); /* drivers/mtd/cfi_mtd.c */ #ifdef CONFIG_FLASH_CFI_MTD