summaryrefslogtreecommitdiffstats
path: root/common/ratp/md.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-13 20:31:47 +0100
commit314ad8e28161be580af1271bdaf05a4c6e7f6bd1 (patch)
treea98f1b35cddef99c60fc255bc1ae5408974fc19f /common/ratp/md.c
parent3fe0effd52c960dc3dce0b731ef266113f2d1893 (diff)
parent504ac299a531a0bd601e6db05dc1c2d3b86a9700 (diff)
downloadbarebox-314ad8e28161be580af1271bdaf05a4c6e7f6bd1.tar.gz
Merge branch 'for-next/lseek'
Diffstat (limited to 'common/ratp/md.c')
-rw-r--r--common/ratp/md.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/ratp/md.c b/common/ratp/md.c
index ce343d7..a25cbf1 100644
--- a/common/ratp/md.c
+++ b/common/ratp/md.c
@@ -59,8 +59,6 @@ struct ratp_bb_md_response {
uint8_t buffer[];
} __packed;
-extern char *mem_rw_buf;
-
static int do_ratp_mem_md(const char *filename,
loff_t start,
loff_t size,
@@ -70,6 +68,7 @@ static int do_ratp_mem_md(const char *filename,
int ret = 0;
int fd;
void *map;
+ char *buf = NULL;
fd = open_and_lseek(filename, O_RWSIZE_1 | O_RDONLY, start);
if (fd < 0)
@@ -81,10 +80,11 @@ static int do_ratp_mem_md(const char *filename,
goto out;
}
+ buf = xmalloc(RW_BUF_SIZE);
t = 0;
do {
now = min(size, (loff_t)RW_BUF_SIZE);
- r = read(fd, mem_rw_buf, now);
+ r = read(fd, buf, now);
if (r < 0) {
ret = -errno;
perror("read");
@@ -93,13 +93,14 @@ static int do_ratp_mem_md(const char *filename,
if (!r)
goto out;
- memcpy(output + t, (uint8_t *)(mem_rw_buf), r);
+ memcpy(output + t, buf, r);
size -= r;
t += r;
} while (size);
out:
+ free(buf);
close(fd);
return ret;