diff mbox

[U-Boot,2/3] spl: fit: Detect a FS load using filename

Message ID 1463653677-24006-3-git-send-email-lokeshvutla@ti.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Lokesh Vutla May 19, 2016, 10:27 a.m. UTC
Right now a FS load for fit is being detected using the priv field. But
this can be used by others media. So, introduce a filename field to
detect a FS load.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 common/spl/spl_fat.c | 4 ++--
 common/spl/spl_fit.c | 6 +++---
 include/spl.h        | 2 ++
 3 files changed, 7 insertions(+), 5 deletions(-)

Comments

Tom Rini May 19, 2016, 1:50 p.m. UTC | #1
On Thu, May 19, 2016 at 03:57:56PM +0530, Lokesh Vutla wrote:

> Right now a FS load for fit is being detected using the priv field. But
> this can be used by others media. So, introduce a filename field to
> detect a FS load.
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox

Patch

diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index cdb9811..9df2fc2 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -45,7 +45,7 @@  static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
 {
 	loff_t actread;
 	int ret;
-	char *filename = (char *)load->priv;
+	const char *filename = load->filename;
 
 	ret = fat_read_file(filename, buf, file_offset, size, &actread);
 	if (ret)
@@ -79,7 +79,7 @@  int spl_load_image_fat(struct blk_desc *block_dev,
 		debug("Found FIT\n");
 		load.read = spl_fit_read;
 		load.bl_len = 1;
-		load.priv = (void *)filename;
+		load.filename = filename;
 
 		return spl_load_simple_fit(&load, 0, header);
 	} else {
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index a0ea44c..78ce15f 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -87,7 +87,7 @@  static int get_aligned_image_offset(struct spl_load_info *info, int offset)
 	 * aligned to ARCH_DMA_MINALIGN. If it is raw read return the
 	 * block number to which offset belongs.
 	 */
-	if (info->priv)
+	if (info->filename)
 		return offset & ~(ARCH_DMA_MINALIGN - 1);
 
 	return offset / info->bl_len;
@@ -101,7 +101,7 @@  static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
 	 * ARCH_DMA_MINALIGN. If it is raw read return the offset within the
 	 * block.
 	 */
-	if (info->priv)
+	if (info->filename)
 		return offset & (ARCH_DMA_MINALIGN - 1);
 
 	return offset % info->bl_len;
@@ -110,7 +110,7 @@  static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
 static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 				  int offset)
 {
-	if (info->priv)
+	if (info->filename)
 		return data_size + get_aligned_image_overhead(info, offset);
 
 	return (data_size + info->bl_len - 1) / info->bl_len;
diff --git a/include/spl.h b/include/spl.h
index 358e81b..af02a6d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -35,12 +35,14 @@  struct spl_image_info {
  * @dev: Pointer to the device, e.g. struct mmc *
  * @priv: Private data for the device
  * @bl_len: Block length for reading in bytes
+ * @filename: Name of the fit image file.
  * @read: Function to call to read from the device
  */
 struct spl_load_info {
 	void *dev;
 	void *priv;
 	int bl_len;
+	const char *filename;
 	ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
 		      void *buf);
 };