]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
mtd: tests: incorporate error message for mtdtest_write()
authorAkinobu Mita <akinobu.mita@gmail.com>
Thu, 15 Aug 2013 13:55:09 +0000 (22:55 +0900)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 30 Aug 2013 20:36:06 +0000 (21:36 +0100)
All callers of mtdtest_write() print the same error message on failure.
This incorporates the error message to mtdtest_write() and removes them
from the callers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/tests/mtd_test.c
drivers/mtd/tests/nandbiterrs.c
drivers/mtd/tests/pagetest.c
drivers/mtd/tests/speedtest.c
drivers/mtd/tests/stresstest.c

index 4c2e3f0bb9531b34087b2027478c18570ce6bf19..c818a63532e774035e7f81d748622c0b21810c2a 100644 (file)
@@ -107,6 +107,8 @@ int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
        err = mtd_write(mtd, addr, size, &written, buf);
        if (!err && written != size)
                err = -EIO;
+       if (err)
+               pr_err("error: write failed at %#llx\n", addr);
 
        return err;
 }
index 5a8c8584112df005cff1d9a393278d6fc322da89..3cd3aabbe1cd8bd3a92a1131e4955c83c41d4431 100644 (file)
@@ -102,16 +102,10 @@ static uint8_t hash(unsigned offset)
 /* Writes wbuffer to page */
 static int write_page(int log)
 {
-       int err;
-
        if (log)
                pr_info("write_page\n");
 
-       err = mtdtest_write(mtd, offset, mtd->writesize, wbuffer);
-       if (err)
-               pr_err("error: write failed at %#llx\n", (long long)offset);
-
-       return err;
+       return mtdtest_write(mtd, offset, mtd->writesize, wbuffer);
 }
 
 /* Re-writes the data area while leaving the OOB alone. */
index 9e8329c5d96d720e3bedfacdba88cc400b2e6ad2..44b96e999ad4694c5ad222c357d98bc22c27c247 100644 (file)
@@ -52,17 +52,11 @@ static struct rnd_state rnd_state;
 
 static int write_eraseblock(int ebnum)
 {
-       int err;
        loff_t addr = ebnum * mtd->erasesize;
 
        prandom_bytes_state(&rnd_state, writebuf, mtd->erasesize);
        cond_resched();
-       err = mtdtest_write(mtd, addr, mtd->erasesize, writebuf);
-       if (err)
-               pr_err("error: write failed at %#llx\n",
-                      (long long)addr);
-
-       return err;
+       return mtdtest_write(mtd, addr, mtd->erasesize, writebuf);
 }
 
 static int verify_eraseblock(int ebnum)
@@ -232,11 +226,8 @@ static int erasecrosstest(void)
        prandom_bytes_state(&rnd_state, writebuf, pgsize);
        strcpy(writebuf, "There is no data like this!");
        err = mtdtest_write(mtd, addr0, pgsize, writebuf);
-       if (err) {
-               pr_info("error: write failed at %#llx\n",
-                      (long long)addr0);
+       if (err)
                return err;
-       }
 
        pr_info("reading 1st page of block %d\n", ebnum);
        memset(readbuf, 0, pgsize);
@@ -260,11 +251,8 @@ static int erasecrosstest(void)
        prandom_bytes_state(&rnd_state, writebuf, pgsize);
        strcpy(writebuf, "There is no data like this!");
        err = mtdtest_write(mtd, addr0, pgsize, writebuf);
-       if (err) {
-               pr_err("error: write failed at %#llx\n",
-                      (long long)addr0);
+       if (err)
                return err;
-       }
 
        pr_info("erasing block %d\n", ebnum2);
        err = mtdtest_erase_eraseblock(mtd, ebnum2);
@@ -311,11 +299,8 @@ static int erasetest(void)
        pr_info("writing 1st page of block %d\n", ebnum);
        prandom_bytes_state(&rnd_state, writebuf, pgsize);
        err = mtdtest_write(mtd, addr0, pgsize, writebuf);
-       if (err) {
-               pr_err("error: write failed at %#llx\n",
-                      (long long)addr0);
+       if (err)
                return err;
-       }
 
        pr_info("erasing block %d\n", ebnum);
        err = mtdtest_erase_eraseblock(mtd, ebnum);
index d1a38530612e2d2470c6ac2760c259092bcad444..87ff6a29f84ee94bacc657aaf6f52700aa45074d 100644 (file)
@@ -80,14 +80,9 @@ static int multiblock_erase(int ebnum, int blocks)
 
 static int write_eraseblock(int ebnum)
 {
-       int err;
        loff_t addr = ebnum * mtd->erasesize;
 
-       err = mtdtest_write(mtd, addr, mtd->erasesize, iobuf);
-       if (err)
-               pr_err("error: write failed at %#llx\n", addr);
-
-       return err;
+       return mtdtest_write(mtd, addr, mtd->erasesize, iobuf);
 }
 
 static int write_eraseblock_by_page(int ebnum)
@@ -98,11 +93,8 @@ static int write_eraseblock_by_page(int ebnum)
 
        for (i = 0; i < pgcnt; i++) {
                err = mtdtest_write(mtd, addr, pgsize, buf);
-               if (err) {
-                       pr_err("error: write failed at %#llx\n",
-                              addr);
+               if (err)
                        break;
-               }
                addr += pgsize;
                buf += pgsize;
        }
@@ -119,21 +111,13 @@ static int write_eraseblock_by_2pages(int ebnum)
 
        for (i = 0; i < n; i++) {
                err = mtdtest_write(mtd, addr, sz, buf);
-               if (err) {
-                       pr_err("error: write failed at %#llx\n",
-                              addr);
+               if (err)
                        return err;
-               }
                addr += sz;
                buf += sz;
        }
-       if (pgcnt % 2) {
+       if (pgcnt % 2)
                err = mtdtest_write(mtd, addr, pgsize, buf);
-               if (err) {
-                       pr_err("error: write failed at %#llx\n",
-                              addr);
-               }
-       }
 
        return err;
 }
index 6c9e23f40cbc7cbc1bc777eec7404a7198beaaae..c9d42cc2df1b5303804217f7621af9539cffc28f 100644 (file)
@@ -126,11 +126,8 @@ static int do_write(void)
        }
        addr = eb * mtd->erasesize + offs;
        err = mtdtest_write(mtd, addr, len, writebuf);
-       if (unlikely(err)) {
-               pr_err("error: write failed at 0x%llx\n",
-                      (long long)addr);
+       if (unlikely(err))
                return err;
-       }
        offs += len;
        while (offs > mtd->erasesize) {
                offsets[eb++] = mtd->erasesize;