spl: Refactor spl_load_info->read to use units of bytes
Simplify things a bit for callers of spl_load_info->read by refactoring it to use units of bytes instead of bl_len. This generally simplifies the logic, as MMC is the only loader which actually works in sectors. It will also allow further refactoring to remove the special-case handling of filename. spl_load_legacy_img already works in units of bytes (oops) so it doesn't need to be changed. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -16,14 +16,13 @@ struct text_ctx {
|
||||
int fd;
|
||||
};
|
||||
|
||||
static ulong read_fit_image(struct spl_load_info *load, ulong sector,
|
||||
ulong count, void *buf)
|
||||
static ulong read_fit_image(struct spl_load_info *load, ulong offset,
|
||||
ulong size, void *buf)
|
||||
{
|
||||
struct text_ctx *text_ctx = load->priv;
|
||||
off_t offset, ret;
|
||||
off_t ret;
|
||||
ssize_t res;
|
||||
|
||||
offset = sector * load->bl_len;
|
||||
ret = os_lseek(text_ctx->fd, offset, OS_SEEK_SET);
|
||||
if (ret != offset) {
|
||||
printf("Failed to seek to %zx, got %zx (errno=%d)\n", offset,
|
||||
@@ -31,14 +30,14 @@ static ulong read_fit_image(struct spl_load_info *load, ulong sector,
|
||||
return 0;
|
||||
}
|
||||
|
||||
res = os_read(text_ctx->fd, buf, count * load->bl_len);
|
||||
res = os_read(text_ctx->fd, buf, size);
|
||||
if (res == -1) {
|
||||
printf("Failed to read %lx bytes, got %ld (errno=%d)\n",
|
||||
count * load->bl_len, res, errno);
|
||||
size, res, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
return size;
|
||||
}
|
||||
|
||||
static int spl_test_load(struct unit_test_state *uts)
|
||||
|
||||
Reference in New Issue
Block a user