[OpenWrt-Devel] [PATCH] kernel: mtdsplit_uimage: use more generic header verify function

Felix Fietkau nbd at openwrt.org
Tue Dec 16 11:01:39 EST 2014


On 2014-12-14 00:41, Rafał Miłecki wrote:
> Some devices have uImage headers after some extra headers (e.g. Edimax
> devices). To support such cases our verify callback function should be
> allowed to return header offset, not just a boolean value.
> 
> Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
> ---
> Hi Tomasz,
> 
> I was looking at the patch you submitted
> PATCH [kernel]: proper support for Edimax uimages
> http://patchwork.openwrt.org/patch/6555/
> and was thinking about some better solution.
> 
> I didn't like the fact that you added Edimax specific workaround to the
> supposed-to-be-generic __mtdsplit_parse_uimage.
> 
> So I came with the idea of modifying our callback function. With this
> patch you should be able to re-write your uimage_verify_edimax to simply
> return 20 instead of true.
> 
> Of course we will also need to do something like:
> header_offset = find_header(buf, buf_size);
> header = offset + header_offset;
> ---
>  .../generic/files/drivers/mtd/mtdsplit_uimage.c    | 37 +++++++++++++++-------
>  1 file changed, 26 insertions(+), 11 deletions(-)
> 
> diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c
> index 7dad63c..2f723bd 100644
> --- a/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c
> +++ b/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c
> @@ -71,10 +71,16 @@ read_uimage_header(struct mtd_info *mtd, size_t offset,
>  	return 0;
>  }
>  
> +/**
> + * __mtdsplit_parse_uimage - scan partition and create kernel + rootfs parts
> + *
> + * @find_header: function to call for a block of data that will return offset
> + *      of a valid uImage header if found
> + */
>  static int __mtdsplit_parse_uimage(struct mtd_info *master,
>  				   struct mtd_partition **pparts,
>  				   struct mtd_part_parser_data *data,
> -				   bool (*verify)(struct uimage_header *hdr))
> +				   size_t (*find_header)(u_char *buf, size_t len))
I believe the return type you're looking for is ssize_t, not size_t.

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list