diff options
| author | Simon Glass <[email protected]> | 2024-08-22 07:55:02 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-08-23 15:58:42 -0600 |
| commit | 3fd11278ff43a5039e33a8cf04dc822711ea9694 (patch) | |
| tree | 62818649b8a5605cefe4795c0fb4a24b8a087e39 /include/spl.h | |
| parent | 50a1ed4335045c57d9073a3fcd265edd89da924a (diff) | |
spl: Create a function to init spl_load_info
Rather than having every caller set this up individually, create a
common init function. This allows new fields to be added without the
risk of them being left uninited.
Signed-off-by: Simon Glass <[email protected]>
Reviewed-by: Michael Trimarchi <[email protected]>
Diffstat (limited to 'include/spl.h')
| -rw-r--r-- | include/spl.h | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/include/spl.h b/include/spl.h index fb26e3f5537..de808ccd413 100644 --- a/include/spl.h +++ b/include/spl.h @@ -282,28 +282,32 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info) #endif } +struct spl_load_info; + +/** + * spl_load_reader() - Read from device + * + * @load: Information about the load state + * @offset: Offset to read from in bytes. This must be a multiple of + * @load->bl_len. + * @count: Number of bytes to read. This must be a multiple of + * @load->bl_len. + * @buf: Buffer to read into + * @return number of bytes read, 0 on error + */ +typedef ulong (*spl_load_reader)(struct spl_load_info *load, ulong sector, + ulong count, void *buf); + /** * Information required to load data from a device * + * @read: Function to call to read from the device * @priv: Private data for the device * @bl_len: Block length for reading in bytes - * @read: Function to call to read from the device */ struct spl_load_info { + spl_load_reader read; void *priv; - /** - * read() - Read from device - * - * @load: Information about the load state - * @offset: Offset to read from in bytes. This must be a multiple of - * @load->bl_len. - * @count: Number of bytes to read. This must be a multiple of - * @load->bl_len. - * @buf: Buffer to read into - * @return number of bytes read, 0 on error - */ - ulong (*read)(struct spl_load_info *load, ulong sector, ulong count, - void *buf); #if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK) int bl_len; #endif @@ -328,6 +332,18 @@ static inline void spl_set_bl_len(struct spl_load_info *info, int bl_len) #endif } +/** + * spl_load_init() - Set up a new spl_load_info structure + */ +static inline void spl_load_init(struct spl_load_info *load, + spl_load_reader h_read, void *priv, + uint bl_len) +{ + load->read = h_read; + load->priv = priv; + spl_set_bl_len(load, bl_len); +} + /* * We need to know the position of U-Boot in memory so we can jump to it. We * allow any U-Boot binary to be used (u-boot.bin, u-boot-nodtb.bin, |
