All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: fat: Use do_save() for fatwrite
@ 2020-09-29  7:13 Lad Prabhakar
  2020-10-14 17:41 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Lad Prabhakar @ 2020-09-29  7:13 UTC (permalink / raw)
  To: u-boot

do_save() function defined in fs.c also supports FAT file system
re-use the same for fatwrite command.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 cmd/fat.c | 43 +------------------------------------------
 1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/cmd/fat.c b/cmd/fat.c
index b438ce16c9..69ce1fa530 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -98,48 +98,7 @@ U_BOOT_CMD(
 static int do_fat_fswrite(struct cmd_tbl *cmdtp, int flag, int argc,
 			  char *const argv[])
 {
-	loff_t size;
-	int ret;
-	unsigned long addr;
-	unsigned long count;
-	long offset;
-	struct blk_desc *dev_desc = NULL;
-	struct disk_partition info;
-	int dev = 0;
-	int part = 1;
-	void *buf;
-
-	if (argc < 5)
-		return cmd_usage(cmdtp);
-
-	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
-	if (part < 0)
-		return 1;
-
-	dev = dev_desc->devnum;
-
-	if (fat_set_blk_dev(dev_desc, &info) != 0) {
-		printf("\n** Unable to use %s %d:%d for fatwrite **\n",
-			argv[1], dev, part);
-		return 1;
-	}
-	addr = simple_strtoul(argv[3], NULL, 16);
-	count = (argc <= 5) ? 0 : simple_strtoul(argv[5], NULL, 16);
-	/* offset should be a hex, but "-1" is allowed */
-	offset = (argc <= 6) ? 0 : simple_strtol(argv[6], NULL, 16);
-
-	buf = map_sysmem(addr, count);
-	ret = file_fat_write(argv[4], buf, offset, count, &size);
-	unmap_sysmem(buf);
-	if (ret < 0) {
-		printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
-			argv[4], argv[1], dev, part);
-		return 1;
-	}
-
-	printf("%llu bytes written\n", size);
-
-	return 0;
+	return do_save(cmdtp, flag, argc, argv, FS_TYPE_FAT);
 }
 
 U_BOOT_CMD(
-- 
2.17.1

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

* [PATCH] cmd: fat: Use do_save() for fatwrite
  2020-09-29  7:13 [PATCH] cmd: fat: Use do_save() for fatwrite Lad Prabhakar
@ 2020-10-14 17:41 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-10-14 17:41 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 29, 2020 at 08:13:00AM +0100, Lad Prabhakar wrote:

> do_save() function defined in fs.c also supports FAT file system
> re-use the same for fatwrite command.
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  cmd/fat.c | 43 +------------------------------------------
>  1 file changed, 1 insertion(+), 42 deletions(-)

This causes a bunch of the FAT tests in test/py/ to fail, please
investigate and re-post, thanks.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201014/3a358ea7/attachment.sig>

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

end of thread, other threads:[~2020-10-14 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29  7:13 [PATCH] cmd: fat: Use do_save() for fatwrite Lad Prabhakar
2020-10-14 17:41 ` Tom Rini

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.