From patchwork Thu Jun 12 05:57:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 359015 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D3BBE140080 for ; Thu, 12 Jun 2014 16:07:29 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 79B504B8DB; Thu, 12 Jun 2014 08:07:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xmkTYuy9pwfu; Thu, 12 Jun 2014 08:07:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EA5024B8D9; Thu, 12 Jun 2014 08:07:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EA4C54B8D9 for ; Thu, 12 Jun 2014 08:07:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ec8WkMj1b6MY for ; Thu, 12 Jun 2014 08:07:19 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from DVREDG01.corp.atmel.com (nasmtp01.atmel.com [192.199.1.245]) by theia.denx.de (Postfix) with ESMTPS id 651D84B8D8 for ; Thu, 12 Jun 2014 08:07:15 +0200 (CEST) Received: from apsmtp01.atmel.com (10.168.254.31) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 12 Jun 2014 00:06:58 -0600 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.2.347.0; Thu, 12 Jun 2014 14:08:39 +0800 From: Josh Wu To: Date: Thu, 12 Jun 2014 13:57:23 +0800 Message-ID: <1402552643-13297-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Cc: trini@ti.com, swarren@nvidia.com Subject: [U-Boot] [PATCH] fs/fat: add a parameter: allow_whole_dev to fat_register_device() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de For SPL in FAT and envrionment load/save in FAT, to support no partition table device (whole device is FAT partition). We need specify the partition number as 0. But in FAT SPL and environment case, when we specify the partition number as 1, it is reasonable to support the device has no partition table and only a FAT partition. This patch add a parameter: allow_whole_dev for fat_register_device(). If allow_whole_dev is true, it will enable no partition table device. In FAT SPL and FAT file environment, we call fat_register_device() with allow_whole_dev as true. Other cases we call it with false. Signed-off-by: Josh Wu --- board/cm5200/fwupdate.c | 2 +- board/esd/common/auto_update.c | 3 +-- board/mcc200/auto_update.c | 4 ++-- common/env_fat.c | 4 ++-- common/spl/spl_fat.c | 2 +- fs/fat/fat.c | 15 +++++++++++---- include/fat.h | 3 ++- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/board/cm5200/fwupdate.c b/board/cm5200/fwupdate.c index 06d5023..801d82a 100644 --- a/board/cm5200/fwupdate.c +++ b/board/cm5200/fwupdate.c @@ -120,7 +120,7 @@ static int load_rescue_image(ulong addr) /* Detect partition */ for (partno = -1, i = 0; i < 6; i++) { if (get_partition_info(stor_dev, i, &info) == 0) { - if (fat_register_device(stor_dev, i) == 0) { + if (fat_register_device(stor_dev, i, false) == 0) { /* Check if rescue image is present */ FW_DEBUG("Looking for firmware directory '%s'" " on partition %d\n", fwdir, i); diff --git a/board/esd/common/auto_update.c b/board/esd/common/auto_update.c index 85c3567..d2dd76a 100644 --- a/board/esd/common/auto_update.c +++ b/board/esd/common/auto_update.c @@ -30,7 +30,6 @@ extern int N_AU_IMAGES; #define MAX_LOADSZ 0x1c00000 /* externals */ -extern int fat_register_device(block_dev_desc_t *, int); extern int file_fat_detectfs(void); extern long file_fat_read(const char *, void *, unsigned long); long do_fat_read (const char *filename, void *buffer, @@ -390,7 +389,7 @@ int do_auto_update(void) } } - if (fat_register_device (stor_dev, 1) != 0) { + if (fat_register_device(stor_dev, 1, false) != 0) { debug ("Unable to register ide disk 0:1\n"); return -1; } diff --git a/board/mcc200/auto_update.c b/board/mcc200/auto_update.c index 43173ce..6cc12d5 100644 --- a/board/mcc200/auto_update.c +++ b/board/mcc200/auto_update.c @@ -106,7 +106,7 @@ ulong totsize; #define KEYPAD_MASK_HI ((1<<(KEYPAD_COL-1+(KEYPAD_ROW*3-3)))>>8) /* externals */ -extern int fat_register_device(block_dev_desc_t *, int); +extern int fat_register_device(block_dev_desc_t *, int, bool); extern int file_fat_detectfs(void); extern long file_fat_read(const char *, void *, unsigned long); extern int i2c_read (unsigned char, unsigned int, int , unsigned char* , int); @@ -373,7 +373,7 @@ int do_auto_update(void) res = -1; goto xit; } - if (fat_register_device(stor_dev, 1) != 0) { + if (fat_register_device(stor_dev, 1, false) != 0) { debug ("Unable to use USB %d:%d for fatls\n", au_usb_stor_curr_dev, 1); res = -1; diff --git a/common/env_fat.c b/common/env_fat.c index aad0487..b36e08e 100644 --- a/common/env_fat.c +++ b/common/env_fat.c @@ -67,7 +67,7 @@ int saveenv(void) return 1; } - err = fat_register_device(dev_desc, part); + err = fat_register_device(dev_desc, part, true); if (err) { printf("Failed to register %s%d:%d\n", FAT_ENV_INTERFACE, dev, part); @@ -117,7 +117,7 @@ void env_relocate_spec(void) return; } - err = fat_register_device(dev_desc, part); + err = fat_register_device(dev_desc, part, true); if (err) { printf("Failed to register %s%d:%d\n", FAT_ENV_INTERFACE, dev, part); diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index 56be943..c7a4fd6 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -25,7 +25,7 @@ static int spl_register_fat_device(block_dev_desc_t *block_dev, int partition) if (fat_registered) return err; - err = fat_register_device(block_dev, partition); + err = fat_register_device(block_dev, partition, true); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: fat register err - %d\n", __func__, err); diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 54f42ea..ad08cde 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -81,7 +81,8 @@ int fat_set_blk_dev(block_dev_desc_t *dev_desc, disk_partition_t *info) return -1; } -int fat_register_device(block_dev_desc_t *dev_desc, int part_no) +int fat_register_device(block_dev_desc_t *dev_desc, int part_no, + bool allow_whole_dev) { disk_partition_t info; @@ -91,9 +92,15 @@ int fat_register_device(block_dev_desc_t *dev_desc, int part_no) /* Read the partition table, if present */ if (get_partition_info(dev_desc, part_no, &info)) { if (part_no != 0) { - printf("** Partition %d not valid on device %d **\n", - part_no, dev_desc->dev); - return -1; + /* + * If part_no = 1, we will support whole partition + * device if allow_whole_dev is true + */ + if (!(allow_whole_dev && part_no == 1)) { + printf("** Partition %d not valid on device %d **\n", + part_no, dev_desc->dev); + return -1; + } } info.start = 0; diff --git a/include/fat.h b/include/fat.h index 63cf787..df15945 100644 --- a/include/fat.h +++ b/include/fat.h @@ -203,7 +203,8 @@ long file_fat_read_at(const char *filename, unsigned long pos, void *buffer, long file_fat_read(const char *filename, void *buffer, unsigned long maxsize); const char *file_getfsname(int idx); int fat_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info); -int fat_register_device(block_dev_desc_t *dev_desc, int part_no); +int fat_register_device(block_dev_desc_t *dev_desc, int part_no, + bool allow_whole_dev); int file_fat_write(const char *filename, void *buffer, unsigned long maxsize); int fat_read_file(const char *filename, void *buf, int offset, int len);