summaryrefslogtreecommitdiffstats
path: root/commands/nand.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-06-04 09:40:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2008-06-06 09:30:39 +0200
commit3d45abb7c4be454b6f2a7ede06fe961a04131083 (patch)
treef2e4581d485f0a6f285f3c6f62dd973330743e20 /commands/nand.c
parentf3351ebd7864b83b1f5f3cdc7c8a9f9110cb562f (diff)
downloadbarebox-3d45abb7c4be454b6f2a7ede06fe961a04131083.tar.gz
barebox-3d45abb7c4be454b6f2a7ede06fe961a04131083.tar.xz
[NAND] continue to make it work. Now works partly on at91sam9260
Diffstat (limited to 'commands/nand.c')
-rw-r--r--commands/nand.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/commands/nand.c b/commands/nand.c
index 483441a146..4c6b717809 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -51,14 +51,16 @@ static ssize_t nand_bb_read(struct device_d *dev, void *buf, size_t count,
printf("%s %d %d\n", __func__, offset, count);
- ret = dev_ioctl(bb->physdev, MEMGETBADBLOCK, (void *)bb->offset);
- if (ret < 0)
- return ret;
-
- if (ret) {
- printf("block is bad\n");
- bb->offset += bb->info.erasesize;
- }
+ do {
+ ret = dev_ioctl(bb->physdev, MEMGETBADBLOCK, (void *)bb->offset);
+ if (ret < 0)
+ return ret;
+
+ if (ret) {
+ printf("block is bad\n");
+ bb->offset += bb->info.erasesize;
+ }
+ } while (ret);
ret = dev_read(bb->physdev, buf, count, bb->offset, flags);
if (ret > 0)
@@ -75,14 +77,16 @@ static ssize_t nand_bb_write(struct device_d *dev, const void *buf, size_t count
printf("%s %d %d\n", __func__, offset, count);
- ret = dev_ioctl(bb->physdev, MEMGETBADBLOCK, (void *)bb->offset);
- if (ret < 0)
- return ret;
+ do {
+ ret = dev_ioctl(bb->physdev, MEMGETBADBLOCK, (void *)bb->offset);
+ if (ret < 0)
+ return ret;
- if (ret) {
- printf("block is bad\n");
- bb->offset += bb->info.erasesize;
- }
+ if (ret) {
+ printf("block is bad\n");
+ bb->offset += bb->info.erasesize;
+ }
+ } while (ret);
ret = dev_write(bb->physdev, buf, count, bb->offset, flags);
if (ret > 0)