X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fflash%2Fflash.c;h=464b8760b54db8cdd2d8b51564f9dbdcf5a81b26;hp=b6188a07a3340d05def3b73300d2c39d201deb0a;hb=48ca02faa9816b158cb6fa56a4107701143cb212;hpb=a6bb8cc856f43730ee04f2bae7d974551560a420 diff --git a/lib/flash/flash.c b/lib/flash/flash.c index b6188a0..464b876 100644 --- a/lib/flash/flash.c +++ b/lib/flash/flash.c @@ -36,7 +36,7 @@ struct flash_info { /* Device information */ struct blocklevel_device *bl; struct ffs_handle *ffs; - uint32_t size; /* raw size of partition */ + uint64_t size; /* raw size of partition */ const char *path; bool ecc; uint32_t erase_granule; @@ -82,26 +82,26 @@ static struct flash_info *flash_setup_buffer(void *ctx, const char *partition) rc = arch_flash_init(&info->bl, NULL, true); if (rc) { pb_log("Failed to init mtd device\n"); - return NULL; + goto out; } rc = blocklevel_get_info(info->bl, &info->path, &info->size, &info->erase_granule); if (rc) { pb_log("Failed to retrieve blocklevel info\n"); - return NULL; + goto out_flash; } rc = ffs_init(0, info->size, info->bl, &info->ffs, 1); if (rc) { pb_log("%s: Failed to init ffs\n", __func__); - goto out; + goto out_flash; } rc = partition_info(info, partition); if (rc) { pb_log("Failed to retrieve partition info\n"); - goto out; + goto out_ffs; } /* Check if there is a second flash side. If there is not, or @@ -124,7 +124,7 @@ static struct flash_info *flash_setup_buffer(void *ctx, const char *partition) pb_debug("%s Details\n", partition); pb_debug("\tName\t\t%s\n", info->path); - pb_debug("\tFlash Size\t%u\n", info->size); + pb_debug("\tFlash Size\t%lu\n", info->size); pb_debug("\tGranule\t\t%u\n", info->erase_granule); pb_debug("\tECC\t\t%s\n", info->ecc ? "Protected" : "Unprotected"); pb_debug("\tCurrent Side info:\n"); @@ -139,8 +139,11 @@ static struct flash_info *flash_setup_buffer(void *ctx, const char *partition) } return info; -out: +out_ffs: + ffs_close(info->ffs); +out_flash: arch_flash_close(info->bl, NULL); +out: talloc_free(info); return NULL; }