changeset 993:84c9869a3659

flash PPB erase: make internal API more consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 04:58:50 +0000
parents c4c400c1b10c
children ad3041e19884
files loadtools/flamdsec.c
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flamdsec.c	Sun Dec 03 04:47:31 2023 +0000
+++ b/loadtools/flamdsec.c	Sun Dec 03 04:58:50 2023 +0000
@@ -334,9 +334,9 @@
 	return(-1);
 }
 
-plj_ppb_erase_all_single(bank, raw_mode)
+plj_ppb_erase_all_single(bi, raw_mode)
+	struct flash_bank_info *bi;
 {
-	struct flash_bank_info *bi = flash_bank_info + bank;
 	unsigned pulsecnt;
 	uint16_t stat;
 	int rc;
@@ -376,21 +376,23 @@
 	return(0);
 }
 
-plj_ppb_erase_all_dualbank(reqbank, raw_mode)
+plj_ppb_erase_all_dualbank(dummy_bi, raw_mode)
+	void *dummy_bi;
 {
-	int altbank = !reqbank;
 	unsigned pulsecnt;
 	uint16_t stat;
 	int rc;
 
-	if (flash_detect(altbank, 0) < 0)
+	if (flash_detect(0, 0) < 0)
+		return(-1);
+	if (flash_detect(1, 0) < 0)
 		return(-1);
 	if (flash_bank_info[0].device != flash_bank_info[1].device) {
 		fprintf(stderr, "error: mismatch between two flash banks\n");
 		return(-1);
 	}
 	if (raw_mode)
-		return plj_ppb_erase_cycle(flash_bank_info + reqbank);
+		return plj_ppb_erase_cycle(&flash_bank_info[0]);
 	printf("Programming all PPBs in flash bank 0\n");
 	rc = plj_ppb_program_all(&flash_bank_info[0]);
 	if (rc < 0)
@@ -534,5 +536,5 @@
 			"Operation not supported for this flash chip type\n");
 		return(-1);
 	}
-	return li->ppb_erase_all(bank, raw_mode);
+	return li->ppb_erase_all(bi, raw_mode);
 }