spl: Set FAT bl_len to ARCH_DMA_MINALIGN
Instead of relying on the presence of filename to determine whether we are
dealing with a FAT filesystem (and should DMA-align the buffer), have FAT set
bl_len to ARCH_DMA_MINALIGN instead. With this done, we can remove the
special-case logic checking for the presence of filename.
Because filesystems are not block-based, we may read less than the size passed
to spl_load_info.read. This can happen if the file size is not DMA-aligned. This
is fine as long as we read the amount we originally wanted to. Modify the
conditions for callers of spl_load_info.read to check against the original,
unaligned size to avoid failing spuriously.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/common/spl/spl_imx_container.c b/common/spl/spl_imx_container.c
index ad89a99..7cd674f 100644
--- a/common/spl/spl_imx_container.c
+++ b/common/spl/spl_imx_container.c
@@ -45,7 +45,8 @@
container, offset, size);
if (info->read(info, offset, size,
map_sysmem(images[image_index].dst - overhead,
- images[image_index].size)) != size) {
+ images[image_index].size)) <
+ images[image_index].size) {
printf("%s wrong\n", __func__);
return NULL;
}
@@ -77,7 +78,8 @@
debug("%s: container: %p offset: %lu size: %u\n", __func__,
container, offset, size);
- if (info->read(info, offset, size, container) != size) {
+ if (info->read(info, offset, size, container) <
+ CONTAINER_HDR_ALIGNMENT) {
ret = -EIO;
goto end;
}
@@ -107,7 +109,7 @@
debug("%s: container: %p offset: %lu size: %u\n",
__func__, container, offset, size);
- if (info->read(info, offset, size, container) != size) {
+ if (info->read(info, offset, size, container) < length) {
ret = -EIO;
goto end;
}