mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-21 03:55:06 +00:00
kernel: mtdsplit_uimage: read more data to match Edimax needs
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 44415
This commit is contained in:
parent
072759ff39
commit
30d6bc1026
@ -20,6 +20,12 @@
|
|||||||
|
|
||||||
#include "mtdsplit.h"
|
#include "mtdsplit.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* uimage_header itself is only 64B, but it may be prepended with another data.
|
||||||
|
* Currently the biggest size is for Edimax devices: 20B + 64B
|
||||||
|
*/
|
||||||
|
#define MAX_HEADER_LEN 84
|
||||||
|
|
||||||
#define IH_MAGIC 0x27051956 /* Image Magic Number */
|
#define IH_MAGIC 0x27051956 /* Image Magic Number */
|
||||||
#define IH_NMLEN 32 /* Image Name Length */
|
#define IH_NMLEN 32 /* Image Name Length */
|
||||||
|
|
||||||
@ -48,15 +54,12 @@ struct uimage_header {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_uimage_header(struct mtd_info *mtd, size_t offset,
|
read_uimage_header(struct mtd_info *mtd, size_t offset, u_char *buf,
|
||||||
u_char *buf)
|
size_t header_len)
|
||||||
{
|
{
|
||||||
struct uimage_header *header;
|
|
||||||
size_t header_len;
|
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
header_len = sizeof(*header);
|
|
||||||
ret = mtd_read(mtd, offset, header_len, &retlen, buf);
|
ret = mtd_read(mtd, offset, header_len, &retlen, buf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_debug("read error in \"%s\"\n", mtd->name);
|
pr_debug("read error in \"%s\"\n", mtd->name);
|
||||||
@ -84,7 +87,6 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
|
|||||||
{
|
{
|
||||||
struct mtd_partition *parts;
|
struct mtd_partition *parts;
|
||||||
u_char *buf;
|
u_char *buf;
|
||||||
struct uimage_header *header;
|
|
||||||
int nr_parts;
|
int nr_parts;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
size_t uimage_offset;
|
size_t uimage_offset;
|
||||||
@ -99,7 +101,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
|
|||||||
if (!parts)
|
if (!parts)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
buf = vmalloc(sizeof(*header));
|
buf = vmalloc(MAX_HEADER_LEN);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_free_parts;
|
goto err_free_parts;
|
||||||
@ -107,9 +109,11 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
|
|||||||
|
|
||||||
/* find uImage on erase block boundaries */
|
/* find uImage on erase block boundaries */
|
||||||
for (offset = 0; offset < master->size; offset += master->erasesize) {
|
for (offset = 0; offset < master->size; offset += master->erasesize) {
|
||||||
|
struct uimage_header *header;
|
||||||
|
|
||||||
uimage_size = 0;
|
uimage_size = 0;
|
||||||
|
|
||||||
ret = read_uimage_header(master, offset, buf);
|
ret = read_uimage_header(master, offset, buf, sizeof(*buf));
|
||||||
if (ret)
|
if (ret)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user