diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-23 11:27:05 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:25:23 -0500 |
commit | fd2819bbc92fc98bed5d612e4acbe16b6326f6bf (patch) | |
tree | 114f2a130cb854c74707eb805854fe048f65ac14 /drivers | |
parent | 7ae79d7ff1769a3e9c47076b46e4eaa11204a2ee (diff) |
mtd: introduce mtd_read_oob interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/inftlcore.c | 2 | ||||
-rw-r--r-- | drivers/mtd/mtdchar.c | 4 | ||||
-rw-r--r-- | drivers/mtd/mtdconcat.c | 2 | ||||
-rw-r--r-- | drivers/mtd/mtdpart.c | 2 | ||||
-rw-r--r-- | drivers/mtd/mtdswap.c | 4 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 6 | ||||
-rw-r--r-- | drivers/mtd/nftlcore.c | 2 | ||||
-rw-r--r-- | drivers/mtd/sm_ftl.c | 2 | ||||
-rw-r--r-- | drivers/mtd/ssfdc.c | 2 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_oobtest.c | 14 | ||||
-rw-r--r-- | drivers/mtd/tests/mtd_readtest.c | 2 | ||||
-rw-r--r-- | drivers/staging/spectra/lld_mtd.c | 12 |
12 files changed, 27 insertions, 27 deletions
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 0b038bed7b9c..07646e1273e2 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -158,7 +158,7 @@ int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
158 | ops.oobbuf = buf; | 158 | ops.oobbuf = buf; |
159 | ops.datbuf = NULL; | 159 | ops.datbuf = NULL; |
160 | 160 | ||
161 | res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); | 161 | res = mtd_read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); |
162 | *retlen = ops.oobretlen; | 162 | *retlen = ops.oobretlen; |
163 | return res; | 163 | return res; |
164 | } | 164 | } |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 922da31d2c6b..e74f570a7b93 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -227,7 +227,7 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count, | |||
227 | ops.oobbuf = NULL; | 227 | ops.oobbuf = NULL; |
228 | ops.len = len; | 228 | ops.len = len; |
229 | 229 | ||
230 | ret = mtd->read_oob(mtd, *ppos, &ops); | 230 | ret = mtd_read_oob(mtd, *ppos, &ops); |
231 | retlen = ops.retlen; | 231 | retlen = ops.retlen; |
232 | break; | 232 | break; |
233 | } | 233 | } |
@@ -471,7 +471,7 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, | |||
471 | return -ENOMEM; | 471 | return -ENOMEM; |
472 | 472 | ||
473 | start &= ~((uint64_t)mtd->writesize - 1); | 473 | start &= ~((uint64_t)mtd->writesize - 1); |
474 | ret = mtd->read_oob(mtd, start, &ops); | 474 | ret = mtd_read_oob(mtd, start, &ops); |
475 | 475 | ||
476 | if (put_user(ops.oobretlen, retp)) | 476 | if (put_user(ops.oobretlen, retp)) |
477 | ret = -EFAULT; | 477 | ret = -EFAULT; |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 45215501c4c7..cf35642e5f49 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -273,7 +273,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
273 | if (from + devops.len > subdev->size) | 273 | if (from + devops.len > subdev->size) |
274 | devops.len = subdev->size - from; | 274 | devops.len = subdev->size - from; |
275 | 275 | ||
276 | err = subdev->read_oob(subdev, from, &devops); | 276 | err = mtd_read_oob(subdev, from, &devops); |
277 | ops->retlen += devops.retlen; | 277 | ops->retlen += devops.retlen; |
278 | ops->oobretlen += devops.oobretlen; | 278 | ops->oobretlen += devops.oobretlen; |
279 | 279 | ||
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 9ed58f7d7466..6fdc74ef19c1 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -138,7 +138,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, | |||
138 | return -EINVAL; | 138 | return -EINVAL; |
139 | } | 139 | } |
140 | 140 | ||
141 | res = part->master->read_oob(part->master, from + part->offset, ops); | 141 | res = mtd_read_oob(part->master, from + part->offset, ops); |
142 | if (unlikely(res)) { | 142 | if (unlikely(res)) { |
143 | if (mtd_is_bitflip(res)) | 143 | if (mtd_is_bitflip(res)) |
144 | mtd->ecc_stats.corrected++; | 144 | mtd->ecc_stats.corrected++; |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 6ff823e29c0c..0f0ab18d4405 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
@@ -312,7 +312,7 @@ static int mtdswap_handle_write_error(struct mtdswap_dev *d, struct swap_eb *eb) | |||
312 | static int mtdswap_read_oob(struct mtdswap_dev *d, loff_t from, | 312 | static int mtdswap_read_oob(struct mtdswap_dev *d, loff_t from, |
313 | struct mtd_oob_ops *ops) | 313 | struct mtd_oob_ops *ops) |
314 | { | 314 | { |
315 | int ret = d->mtd->read_oob(d->mtd, from, ops); | 315 | int ret = mtd_read_oob(d->mtd, from, ops); |
316 | 316 | ||
317 | if (mtd_is_bitflip(ret)) | 317 | if (mtd_is_bitflip(ret)) |
318 | return ret; | 318 | return ret; |
@@ -955,7 +955,7 @@ static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d, | |||
955 | 955 | ||
956 | pos = base; | 956 | pos = base; |
957 | for (i = 0; i < mtd_pages; i++) { | 957 | for (i = 0; i < mtd_pages; i++) { |
958 | ret = mtd->read_oob(mtd, pos, &ops); | 958 | ret = mtd_read_oob(mtd, pos, &ops); |
959 | if (ret) | 959 | if (ret) |
960 | goto error; | 960 | goto error; |
961 | 961 | ||
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 1bcd6bc6798c..fcab50e80b90 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -317,7 +317,7 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs, | |||
317 | ops.len = min(len, (size_t)mtd->writesize); | 317 | ops.len = min(len, (size_t)mtd->writesize); |
318 | ops.oobbuf = buf + ops.len; | 318 | ops.oobbuf = buf + ops.len; |
319 | 319 | ||
320 | res = mtd->read_oob(mtd, offs, &ops); | 320 | res = mtd_read_oob(mtd, offs, &ops); |
321 | 321 | ||
322 | if (res) | 322 | if (res) |
323 | return res; | 323 | return res; |
@@ -434,7 +434,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, | |||
434 | * Read the full oob until read_oob is fixed to handle single | 434 | * Read the full oob until read_oob is fixed to handle single |
435 | * byte reads for 16 bit buswidth. | 435 | * byte reads for 16 bit buswidth. |
436 | */ | 436 | */ |
437 | ret = mtd->read_oob(mtd, offs, &ops); | 437 | ret = mtd_read_oob(mtd, offs, &ops); |
438 | /* Ignore ECC errors when checking for BBM */ | 438 | /* Ignore ECC errors when checking for BBM */ |
439 | if (ret && !mtd_is_bitflip_or_eccerr(ret)) | 439 | if (ret && !mtd_is_bitflip_or_eccerr(ret)) |
440 | return ret; | 440 | return ret; |
@@ -769,7 +769,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
769 | /* Read oob data */ | 769 | /* Read oob data */ |
770 | ops.ooblen = (len >> this->page_shift) * mtd->oobsize; | 770 | ops.ooblen = (len >> this->page_shift) * mtd->oobsize; |
771 | ops.oobbuf = &buf[len]; | 771 | ops.oobbuf = &buf[len]; |
772 | res = mtd->read_oob(mtd, to + mtd->writesize, &ops); | 772 | res = mtd_read_oob(mtd, to + mtd->writesize, &ops); |
773 | if (res < 0 || ops.oobretlen != ops.ooblen) | 773 | if (res < 0 || ops.oobretlen != ops.ooblen) |
774 | goto outerr; | 774 | goto outerr; |
775 | 775 | ||
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index 1a9d9c1d3a74..7497f5efc26b 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -153,7 +153,7 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
153 | ops.oobbuf = buf; | 153 | ops.oobbuf = buf; |
154 | ops.datbuf = NULL; | 154 | ops.datbuf = NULL; |
155 | 155 | ||
156 | res = mtd->read_oob(mtd, offs & ~mask, &ops); | 156 | res = mtd_read_oob(mtd, offs & ~mask, &ops); |
157 | *retlen = ops.oobretlen; | 157 | *retlen = ops.oobretlen; |
158 | return res; | 158 | return res; |
159 | } | 159 | } |
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index 2f1acb1ab5e8..748aa4416691 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c | |||
@@ -278,7 +278,7 @@ again: | |||
278 | 278 | ||
279 | /* Unfortunately, oob read will _always_ succeed, | 279 | /* Unfortunately, oob read will _always_ succeed, |
280 | despite card removal..... */ | 280 | despite card removal..... */ |
281 | ret = mtd->read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); | 281 | ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); |
282 | 282 | ||
283 | /* Test for unknown errors */ | 283 | /* Test for unknown errors */ |
284 | if (ret != 0 && !mtd_is_bitflip_or_eccerr(ret)) { | 284 | if (ret != 0 && !mtd_is_bitflip_or_eccerr(ret)) { |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 293e22a5710f..0e6881338357 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -175,7 +175,7 @@ static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf) | |||
175 | ops.oobbuf = buf; | 175 | ops.oobbuf = buf; |
176 | ops.datbuf = NULL; | 176 | ops.datbuf = NULL; |
177 | 177 | ||
178 | ret = mtd->read_oob(mtd, offs, &ops); | 178 | ret = mtd_read_oob(mtd, offs, &ops); |
179 | if (ret < 0 || ops.oobretlen != OOB_SIZE) | 179 | if (ret < 0 || ops.oobretlen != OOB_SIZE) |
180 | return -1; | 180 | return -1; |
181 | 181 | ||
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c index 7d52854c16dd..962d27a64e64 100644 --- a/drivers/mtd/tests/mtd_oobtest.c +++ b/drivers/mtd/tests/mtd_oobtest.c | |||
@@ -192,7 +192,7 @@ static int verify_eraseblock(int ebnum) | |||
192 | ops.ooboffs = use_offset; | 192 | ops.ooboffs = use_offset; |
193 | ops.datbuf = NULL; | 193 | ops.datbuf = NULL; |
194 | ops.oobbuf = readbuf; | 194 | ops.oobbuf = readbuf; |
195 | err = mtd->read_oob(mtd, addr, &ops); | 195 | err = mtd_read_oob(mtd, addr, &ops); |
196 | if (err || ops.oobretlen != use_len) { | 196 | if (err || ops.oobretlen != use_len) { |
197 | printk(PRINT_PREF "error: readoob failed at %#llx\n", | 197 | printk(PRINT_PREF "error: readoob failed at %#llx\n", |
198 | (long long)addr); | 198 | (long long)addr); |
@@ -219,7 +219,7 @@ static int verify_eraseblock(int ebnum) | |||
219 | ops.ooboffs = 0; | 219 | ops.ooboffs = 0; |
220 | ops.datbuf = NULL; | 220 | ops.datbuf = NULL; |
221 | ops.oobbuf = readbuf; | 221 | ops.oobbuf = readbuf; |
222 | err = mtd->read_oob(mtd, addr, &ops); | 222 | err = mtd_read_oob(mtd, addr, &ops); |
223 | if (err || ops.oobretlen != mtd->ecclayout->oobavail) { | 223 | if (err || ops.oobretlen != mtd->ecclayout->oobavail) { |
224 | printk(PRINT_PREF "error: readoob failed at " | 224 | printk(PRINT_PREF "error: readoob failed at " |
225 | "%#llx\n", (long long)addr); | 225 | "%#llx\n", (long long)addr); |
@@ -284,7 +284,7 @@ static int verify_eraseblock_in_one_go(int ebnum) | |||
284 | ops.ooboffs = 0; | 284 | ops.ooboffs = 0; |
285 | ops.datbuf = NULL; | 285 | ops.datbuf = NULL; |
286 | ops.oobbuf = readbuf; | 286 | ops.oobbuf = readbuf; |
287 | err = mtd->read_oob(mtd, addr, &ops); | 287 | err = mtd_read_oob(mtd, addr, &ops); |
288 | if (err || ops.oobretlen != len) { | 288 | if (err || ops.oobretlen != len) { |
289 | printk(PRINT_PREF "error: readoob failed at %#llx\n", | 289 | printk(PRINT_PREF "error: readoob failed at %#llx\n", |
290 | (long long)addr); | 290 | (long long)addr); |
@@ -544,7 +544,7 @@ static int __init mtd_oobtest_init(void) | |||
544 | ops.oobbuf = readbuf; | 544 | ops.oobbuf = readbuf; |
545 | printk(PRINT_PREF "attempting to start read past end of OOB\n"); | 545 | printk(PRINT_PREF "attempting to start read past end of OOB\n"); |
546 | printk(PRINT_PREF "an error is expected...\n"); | 546 | printk(PRINT_PREF "an error is expected...\n"); |
547 | err = mtd->read_oob(mtd, addr0, &ops); | 547 | err = mtd_read_oob(mtd, addr0, &ops); |
548 | if (err) { | 548 | if (err) { |
549 | printk(PRINT_PREF "error occurred as expected\n"); | 549 | printk(PRINT_PREF "error occurred as expected\n"); |
550 | err = 0; | 550 | err = 0; |
@@ -588,7 +588,7 @@ static int __init mtd_oobtest_init(void) | |||
588 | ops.oobbuf = readbuf; | 588 | ops.oobbuf = readbuf; |
589 | printk(PRINT_PREF "attempting to read past end of device\n"); | 589 | printk(PRINT_PREF "attempting to read past end of device\n"); |
590 | printk(PRINT_PREF "an error is expected...\n"); | 590 | printk(PRINT_PREF "an error is expected...\n"); |
591 | err = mtd->read_oob(mtd, mtd->size - mtd->writesize, &ops); | 591 | err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); |
592 | if (err) { | 592 | if (err) { |
593 | printk(PRINT_PREF "error occurred as expected\n"); | 593 | printk(PRINT_PREF "error occurred as expected\n"); |
594 | err = 0; | 594 | err = 0; |
@@ -632,7 +632,7 @@ static int __init mtd_oobtest_init(void) | |||
632 | ops.oobbuf = readbuf; | 632 | ops.oobbuf = readbuf; |
633 | printk(PRINT_PREF "attempting to read past end of device\n"); | 633 | printk(PRINT_PREF "attempting to read past end of device\n"); |
634 | printk(PRINT_PREF "an error is expected...\n"); | 634 | printk(PRINT_PREF "an error is expected...\n"); |
635 | err = mtd->read_oob(mtd, mtd->size - mtd->writesize, &ops); | 635 | err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); |
636 | if (err) { | 636 | if (err) { |
637 | printk(PRINT_PREF "error occurred as expected\n"); | 637 | printk(PRINT_PREF "error occurred as expected\n"); |
638 | err = 0; | 638 | err = 0; |
@@ -698,7 +698,7 @@ static int __init mtd_oobtest_init(void) | |||
698 | ops.ooboffs = 0; | 698 | ops.ooboffs = 0; |
699 | ops.datbuf = NULL; | 699 | ops.datbuf = NULL; |
700 | ops.oobbuf = readbuf; | 700 | ops.oobbuf = readbuf; |
701 | err = mtd->read_oob(mtd, addr, &ops); | 701 | err = mtd_read_oob(mtd, addr, &ops); |
702 | if (err) | 702 | if (err) |
703 | goto out; | 703 | goto out; |
704 | if (memcmp(readbuf, writebuf, mtd->ecclayout->oobavail * 2)) { | 704 | if (memcmp(readbuf, writebuf, mtd->ecclayout->oobavail * 2)) { |
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c index 0c58d2976c76..5eaeada84284 100644 --- a/drivers/mtd/tests/mtd_readtest.c +++ b/drivers/mtd/tests/mtd_readtest.c | |||
@@ -74,7 +74,7 @@ static int read_eraseblock_by_page(int ebnum) | |||
74 | ops.ooboffs = 0; | 74 | ops.ooboffs = 0; |
75 | ops.datbuf = NULL; | 75 | ops.datbuf = NULL; |
76 | ops.oobbuf = oobbuf; | 76 | ops.oobbuf = oobbuf; |
77 | ret = mtd->read_oob(mtd, addr, &ops); | 77 | ret = mtd_read_oob(mtd, addr, &ops); |
78 | if ((ret && !mtd_is_bitflip(ret)) || | 78 | if ((ret && !mtd_is_bitflip(ret)) || |
79 | ops.oobretlen != mtd->oobsize) { | 79 | ops.oobretlen != mtd->oobsize) { |
80 | printk(PRINT_PREF "error: read oob failed at " | 80 | printk(PRINT_PREF "error: read oob failed at " |
diff --git a/drivers/staging/spectra/lld_mtd.c b/drivers/staging/spectra/lld_mtd.c index 2eb032131960..ed8e5f067087 100644 --- a/drivers/staging/spectra/lld_mtd.c +++ b/drivers/staging/spectra/lld_mtd.c | |||
@@ -351,9 +351,9 @@ u16 mtd_Read_Page_Main_Spare(u8 *read_data, u32 Block, | |||
351 | ops.ooblen = BTSIG_BYTES; | 351 | ops.ooblen = BTSIG_BYTES; |
352 | ops.ooboffs = 0; | 352 | ops.ooboffs = 0; |
353 | 353 | ||
354 | ret = spectra_mtd->read_oob(spectra_mtd, | 354 | ret = mtd_read_oob(spectra_mtd, |
355 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), | 355 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), |
356 | &ops); | 356 | &ops); |
357 | if (ret) { | 357 | if (ret) { |
358 | printk(KERN_ERR "%s failed %d\n", __func__, ret); | 358 | printk(KERN_ERR "%s failed %d\n", __func__, ret); |
359 | return FAIL; | 359 | return FAIL; |
@@ -484,9 +484,9 @@ u16 mtd_Read_Page_Spare(u8 *read_data, u32 Block, | |||
484 | ops.ooblen = BTSIG_BYTES; | 484 | ops.ooblen = BTSIG_BYTES; |
485 | ops.ooboffs = 0; | 485 | ops.ooboffs = 0; |
486 | 486 | ||
487 | ret = spectra_mtd->read_oob(spectra_mtd, | 487 | ret = mtd_read_oob(spectra_mtd, |
488 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), | 488 | (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), |
489 | &ops); | 489 | &ops); |
490 | if (ret) { | 490 | if (ret) { |
491 | printk(KERN_ERR "%s failed %d\n", __func__, ret); | 491 | printk(KERN_ERR "%s failed %d\n", __func__, ret); |
492 | return FAIL; | 492 | return FAIL; |