summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-03-04 09:21:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-04 09:21:37 +0100
commit13408877f4c0d4b2784d3388dd4481369205e46a (patch)
tree81bd24a8bac468785989c5b8b82a489befcddc5a /commands
parent908bc8ce45f428658dab5826eb6fa2e5d9151aa1 (diff)
parent14743045fb31bd1d2d4b7eb2ccd2e956b44b01bd (diff)
downloadbarebox-13408877f4c0d4b2784d3388dd4481369205e46a.tar.gz
barebox-13408877f4c0d4b2784d3388dd4481369205e46a.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'commands')
-rw-r--r--commands/nandtest.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/commands/nandtest.c b/commands/nandtest.c
index f08f8eb886..ba15ecfb33 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -43,41 +43,17 @@ static unsigned int ecc_stats_over;
static unsigned int ecc_failed_cnt;
/*
- * Implementation of pread with lseek and read.
- */
-static ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
-{
- int ret;
-
- /* Seek to offset */
- ret = lseek(fd, offset, SEEK_SET);
- if (ret < 0)
- perror("lseek");
-
- /* Read from flash and put it into buf */
- ret = read(fd, buf, count);
- if (ret < 0)
- perror("read");
-
- return 0;
-}
-
-/*
* Implementation of pwrite with lseek and write.
*/
-static ssize_t pwrite(int fd, const void *buf,
+static ssize_t __pwrite(int fd, const void *buf,
size_t count, loff_t offset, loff_t length)
{
- int ret;
-
- ret = lseek(fd, offset, SEEK_SET);
- if (ret < 0)
- perror("lseek");
+ ssize_t ret;
/* Write buf to flash */
- ret = write(fd, buf, count);
+ ret = pwrite(fd, buf, count, offset);
if (ret < 0) {
- perror("write");
+ perror("pwrite");
if (markbad) {
printf("\nMark block bad at 0x%08llx\n",
offset + memregion.offset);
@@ -88,7 +64,7 @@ static ssize_t pwrite(int fd, const void *buf,
}
flush(fd);
- return 0;
+ return ret;
}
/*
@@ -119,7 +95,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
for (i = 0; i < meminfo.erasesize;
i += meminfo.writesize) {
/* Write data to given offset */
- pwrite(fd, data + i, meminfo.writesize,
+ __pwrite(fd, data + i, meminfo.writesize,
ofs + i, length);
/* Read data from offset */
@@ -136,7 +112,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
newstats.corrected - oldstats.corrected,
ofs + memregion.offset + i);
init_progression_bar(length);
- show_progress(ofs);
+ show_progress(ofs + i);
if ((newstats.corrected-oldstats.corrected) >=
MAX_ECC_BITS) {
/* Increment ECC stats that
@@ -154,7 +130,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
printf("\nECC failed at page 0x%08llx\n",
ofs + memregion.offset + i);
init_progression_bar(length);
- show_progress(ofs);
+ show_progress(ofs + i);
oldstats.failed = newstats.failed;
ecc_failed_cnt++;
}
@@ -316,8 +292,8 @@ static int do_nandtest(int argc, char *argv[])
for (iter = 0; iter < nr_iterations; iter++) {
init_progression_bar(length);
- for (test_ofs = flash_offset;
- test_ofs < flash_offset + length;
+ for (test_ofs = 0;
+ test_ofs < length;
test_ofs += meminfo.erasesize) {
show_progress(test_ofs);
srand(seed);