diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-02-26 11:46:09 +0800 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-02-26 16:34:27 +1100 |
commit | 6c26bc72093a317a7018bafbece55393d9e222f5 (patch) | |
tree | 1264c7dd0f123d48e2387dffbb1f9d332f7d41eb /libflash/libffs.c | |
parent | 4ddba54145f2c6056cc0236774429825f5ba84d9 (diff) | |
download | skiboot-6c26bc72093a317a7018bafbece55393d9e222f5.zip skiboot-6c26bc72093a317a7018bafbece55393d9e222f5.tar.gz skiboot-6c26bc72093a317a7018bafbece55393d9e222f5.tar.bz2 |
libflash: move ffs_flash_read into libflash
We have ffs_flash_read to do optionally-ecc-ed reads of flash data.
However, this isn't really related to the ffs partitioning.
This change moves ffs_flash_read into libflash.c, named
flash_read_corrected. The function itself isn't changed.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash/libffs.c')
-rw-r--r-- | libflash/libffs.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/libflash/libffs.c b/libflash/libffs.c index bce4ac4..109ac40 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -22,11 +22,6 @@ #include <ccan/endian/endian.h> #include "libffs.h" -#include "ecc.h" - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif enum ffs_type { ffs_type_flash, @@ -292,53 +287,3 @@ int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx, return flash_smart_write(ffs->chip, offset, ent, FFS_ENTRY_SIZE); } -#define COPY_BUFFER_LENGTH 4096 - -/* - * This provides a wrapper around flash_read on ECCed data - * len is length of data without ECC attached - */ -int ffs_flash_read(struct flash_chip *c, uint32_t pos, void *buf, uint32_t len, - bool ecc) -{ - uint64_t *bufecc; - uint32_t copylen; - int rc; - uint8_t ret; - - if (!ecc) - return flash_read(c, pos, buf, len); - - /* Copy the buffer in chunks */ - bufecc = malloc(ECC_BUFFER_SIZE(COPY_BUFFER_LENGTH)); - if (!bufecc) - return FLASH_ERR_MALLOC_FAILED; - - while (len > 0) { - /* What's left to copy? */ - copylen = MIN(len, COPY_BUFFER_LENGTH); - - /* Read ECCed data from flash */ - rc = flash_read(c, pos, bufecc, ECC_BUFFER_SIZE(copylen)); - if (rc) - goto err; - - /* Extract data from ECCed data */ - ret = eccmemcpy(buf, bufecc, copylen); - if (ret == UE) { - rc = FLASH_ERR_ECC_INVALID; - goto err; - } - - /* Update for next copy */ - len -= copylen; - buf = (uint8_t *)buf + copylen; - pos += ECC_BUFFER_SIZE(copylen); - } - - return 0; - -err: - free(bufecc); - return rc; -} |