summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-01-15 13:42:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-15 13:42:54 +0100
commit05cb1e23acbbb0ef8cad0c368981460251725d72 (patch)
treee779c6f005d93b636a4351713e01c7e4b7c1825f /common
parent595cdd17b7906ac6945d2b543af31a01b0a51173 (diff)
parent29841dfa4b3b31189c5ec28d17ca52f7a5d2d522 (diff)
downloadbarebox-05cb1e23acbbb0ef8cad0c368981460251725d72.tar.gz
Merge branch 'for-next/imx'
Diffstat (limited to 'common')
-rw-r--r--common/imx-bbu-nand-fcb.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 8c276a4..a29a1bf 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -1198,9 +1198,8 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
int ret, i;
struct fcb_block *fcb = NULL;
void *fw = NULL, *fw_orig = NULL;
- unsigned fw_size, partition_size;
enum filetype filetype;
- unsigned num_blocks_fw;
+ unsigned num_blocks_fw, fw_size;
int used = 0;
int fw_orig_len;
int used_refresh = 0, unused_refresh = 0;
@@ -1222,7 +1221,12 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
}
mtd = bcb_cdev->mtd;
- partition_size = mtd->size;
+
+ num_blocks_fw = imx_bbu_firmware_max_blocks(mtd);
+ if (num_blocks_fw < 1) {
+ pr_err("Not enough space for firmware\n");
+ return -ENOSPC;
+ }
for (i = 0; i < 4; i++) {
read_fcb(mtd, i, &fcb);
@@ -1329,8 +1333,6 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
pr_info("Refreshing existing firmware\n");
}
- num_blocks_fw = imx_bbu_firmware_max_blocks(mtd);
-
if (num_blocks_fw * mtd->erasesize < fw_size) {
pr_err("Not enough space for update\n");
return -ENOSPC;