summaryrefslogtreecommitdiffstats
path: root/op-flasher
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2016-11-03 12:35:03 +1030
committerJoel Stanley <joel@jms.id.au>2016-11-04 11:08:15 +1030
commit93dafe84bd10b7fbaf34f92ed31e174714a24e6b (patch)
treeddb90aef88cceebf744f188ece3af189c5fda402 /op-flasher
parente0209488390f8aca0367446128182d84de8d401b (diff)
downloadtalos-skeleton-93dafe84bd10b7fbaf34f92ed31e174714a24e6b.tar.gz
talos-skeleton-93dafe84bd10b7fbaf34f92ed31e174714a24e6b.zip
flasher: Unify flash setup functions
They almost perform the same codepath, so unify them. This is in preparation for the upcoming libflash API change, they will call the same setup function. Change-Id: If41592f3dc0c5d98db34e7a25ef2f884b031695c Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'op-flasher')
-rw-r--r--op-flasher/flasher_obj.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/op-flasher/flasher_obj.c b/op-flasher/flasher_obj.c
index c87b305..bf6e3c9 100644
--- a/op-flasher/flasher_obj.c
+++ b/op-flasher/flasher_obj.c
@@ -166,34 +166,23 @@ flash_access_cleanup(void)
}
static int
-flash_access_setup_bmc(void)
+flash_access_setup(enum bmc_access chip)
{
int rc;
- printf("Setting up BMC flash\n");
+ printf("Setting up flash\n");
- if(arch_flash_bmc(bl, BMC_MTD) != BMC_MTD) {
- fprintf(stderr, "Failed to init flash chip\n");
- return FLASH_SETUP_ERROR;
- }
-
- /* Setup cleanup function */
- atexit(flash_access_cleanup);
- return FLASH_OK;
-}
-
-static int
-flash_access_setup_pnor(void)
-{
- int rc;
- printf("Setting up BIOS flash\n");
-
- /* Create the AST flash controller */
-
- /* Open flash chip */
- rc = arch_flash_init(&bl, NULL, true);
- if(rc) {
- fprintf(stderr, "Failed to open flash chip\n");
- return FLASH_SETUP_ERROR;
+ if (chip == BMC_MTD) {
+ rc = arch_flash_bmc(bl, chip);
+ if (rc != BMC_MTD) {
+ fprintf(stderr, "Failed to init flash chip\n");
+ return FLASH_SETUP_ERROR;
+ }
+ } else {
+ rc = arch_flash_init(&bl, NULL, true);
+ if(rc) {
+ fprintf(stderr, "Failed to init flash chip\n");
+ return FLASH_SETUP_ERROR;
+ }
}
/* Setup cleanup function */
@@ -208,16 +197,9 @@ flash(FlashControl* flash_control, enum bmc_access chip, uint32_t address, char*
printf("flasher: %s, BMC = %d, address = 0x%x\n", write_file, chip, address);
/* Prepare for access */
- if(chip == BMC_MTD) {
- rc = flash_access_setup_bmc();
- if(rc) {
- return FLASH_SETUP_ERROR;
- }
- } else {
- rc = flash_access_setup_pnor();
- if(rc) {
- return FLASH_SETUP_ERROR;
- }
+ rc = flash_access_setup(chip);
+ if(rc) {
+ return FLASH_SETUP_ERROR;
}
if(strcmp(write_file,"")!=0)
OpenPOWER on IntegriCloud