diff options
Diffstat (limited to 'drivers/dfu')
-rw-r--r-- | drivers/dfu/dfu_sf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index 7e64ab772f0..b72493ced86 100644 --- a/drivers/dfu/dfu_sf.c +++ b/drivers/dfu/dfu_sf.c @@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size) static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset, - *len, buf); + long seglen = *len; + int ret; + + if (seglen > (16 << 20)) + seglen = (16 << 20); + + ret = spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset, + seglen, buf); + if (!ret) + *len = seglen; + + return ret; } static u64 find_sector(struct dfu_entity *dfu, u64 start, u64 offset) |