diff mbox series

[RFC,5/7] spl: Convert net to spl_load

Message ID 20220401190405.1932697-6-sean.anderson@seco.com
State RFC
Delegated to: Tom Rini
Headers show
Series spl: Use common function for loading/parsing images | expand

Commit Message

Sean Anderson April 1, 2022, 7:04 p.m. UTC
This converts the net load method to use spl_load. As a result, it also
adds support for LOAD_FIT_FULL and IMX images.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 common/spl/spl_net.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

Comments

Stefan Roese April 6, 2022, 5:32 a.m. UTC | #1
On 4/1/22 21:04, Sean Anderson wrote:
> This converts the net load method to use spl_load. As a result, it also
> adds support for LOAD_FIT_FULL and IMX images.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> 
>   common/spl/spl_net.c | 24 +++++-------------------
>   1 file changed, 5 insertions(+), 19 deletions(-)
> 
> diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
> index a853e6aead..3b4374add6 100644
> --- a/common/spl/spl_net.c
> +++ b/common/spl/spl_net.c
> @@ -29,6 +29,10 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
>   			      struct spl_boot_device *bootdev)
>   {
>   	struct image_header *header = (struct image_header *)image_load_addr;
> +	struct spl_load_info load = {
> +		.bl_len = 1,
> +		.read = spl_net_load_read,
> +	};
>   	int rv;
>   
>   	env_init();
> @@ -47,25 +51,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
>   		return rv;
>   	}
>   
> -	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
> -	    image_get_magic(header) == FDT_MAGIC) {
> -		struct spl_load_info load;
> -
> -		debug("Found FIT\n");
> -		load.bl_len = 1;
> -		load.read = spl_net_load_read;
> -		rv = spl_load_simple_fit(spl_image, &load, 0, header);
> -	} else {
> -		debug("Legacy image\n");
> -
> -		rv = spl_parse_image_header(spl_image, bootdev, header);
> -		if (rv)
> -			return rv;
> -
> -		memcpy((void *)spl_image->load_addr, header, spl_image->size);
> -	}
> -
> -	return rv;
> +	return spl_load(spl_image, bootdev, &load, header, 0, 0);
>   }
>   #endif
>   

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index a853e6aead..3b4374add6 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -29,6 +29,10 @@  static int spl_net_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
 	struct image_header *header = (struct image_header *)image_load_addr;
+	struct spl_load_info load = {
+		.bl_len = 1,
+		.read = spl_net_load_read,
+	};
 	int rv;
 
 	env_init();
@@ -47,25 +51,7 @@  static int spl_net_load_image(struct spl_image_info *spl_image,
 		return rv;
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
-	    image_get_magic(header) == FDT_MAGIC) {
-		struct spl_load_info load;
-
-		debug("Found FIT\n");
-		load.bl_len = 1;
-		load.read = spl_net_load_read;
-		rv = spl_load_simple_fit(spl_image, &load, 0, header);
-	} else {
-		debug("Legacy image\n");
-
-		rv = spl_parse_image_header(spl_image, bootdev, header);
-		if (rv)
-			return rv;
-
-		memcpy((void *)spl_image->load_addr, header, spl_image->size);
-	}
-
-	return rv;
+	return spl_load(spl_image, bootdev, &load, header, 0, 0);
 }
 #endif