1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

fastboot: Refactor fastboot_okay/fail to take response

Add the response string as a parameter to fastboot_okay/fail, instead
of modifying a global, to match the contract expected by the AOSP
U-Boot code.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
Alex Kiernan
2018-05-29 15:30:40 +00:00
committed by Marek Vasut
parent 312a10f16b
commit c4ded03ef6
9 changed files with 105 additions and 97 deletions

View File

@@ -31,7 +31,8 @@ __weak int board_fastboot_write_partition_setup(char *name)
static int fb_nand_lookup(const char *partname,
struct mtd_info **mtd,
struct part_info **part)
struct part_info **part,
char *response)
{
struct mtd_device *dev;
int ret;
@@ -40,21 +41,21 @@ static int fb_nand_lookup(const char *partname,
ret = mtdparts_init();
if (ret) {
pr_err("Cannot initialize MTD partitions\n");
fastboot_fail("cannot init mtdparts");
fastboot_fail("cannot init mtdparts", response);
return ret;
}
ret = find_dev_and_part(partname, &dev, &pnum, part);
if (ret) {
pr_err("cannot find partition: '%s'", partname);
fastboot_fail("cannot find partition");
fastboot_fail("cannot find partition", response);
return ret;
}
if (dev->id->type != MTD_DEV_TYPE_NAND) {
pr_err("partition '%s' is not stored on a NAND device",
partname);
fastboot_fail("not a NAND device");
fastboot_fail("not a NAND device", response);
return -EINVAL;
}
@@ -145,16 +146,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
}
void fb_nand_flash_write(const char *cmd, void *download_buffer,
unsigned int download_bytes)
unsigned int download_bytes, char *response)
{
struct part_info *part;
struct mtd_info *mtd = NULL;
int ret;
ret = fb_nand_lookup(cmd, &mtd, &part);
ret = fb_nand_lookup(cmd, &mtd, &part, response);
if (ret) {
pr_err("invalid NAND device");
fastboot_fail("invalid NAND device");
fastboot_fail("invalid NAND device", response);
return;
}
@@ -180,9 +181,10 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
sparse.start);
sparse.priv = &sparse_priv;
ret = write_sparse_image(&sparse, cmd, download_buffer);
ret = write_sparse_image(&sparse, cmd, download_buffer,
response);
if (!ret)
fastboot_okay("");
fastboot_okay(NULL, response);
} else {
printf("Flashing raw image at offset 0x%llx\n",
part->offset);
@@ -195,23 +197,23 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
}
if (ret) {
fastboot_fail("error writing the image");
fastboot_fail("error writing the image", response);
return;
}
fastboot_okay("");
fastboot_okay(NULL, response);
}
void fb_nand_erase(const char *cmd)
void fb_nand_erase(const char *cmd, char *response)
{
struct part_info *part;
struct mtd_info *mtd = NULL;
int ret;
ret = fb_nand_lookup(cmd, &mtd, &part);
ret = fb_nand_lookup(cmd, &mtd, &part, response);
if (ret) {
pr_err("invalid NAND device");
fastboot_fail("invalid NAND device");
fastboot_fail("invalid NAND device", response);
return;
}
@@ -222,9 +224,9 @@ void fb_nand_erase(const char *cmd)
ret = _fb_nand_erase(mtd, part);
if (ret) {
pr_err("failed erasing from device %s", mtd->name);
fastboot_fail("failed erasing from device");
fastboot_fail("failed erasing from device", response);
return;
}
fastboot_okay("");
fastboot_okay(NULL, response);
}