aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdpart.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-04-13 17:29:07 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-04-13 17:29:07 -0400
commitf499cae1e59d75d5eb24c23d47cf8986e6032c6d (patch)
tree1af6235c18391212c40116eb90b01eae8938efee /drivers/mtd/mtdpart.c
parentfc3f55e672e1ed917dd9e215af81939cd3d717da (diff)
parent80a04d3f2f94fb68b5df05e3ac6697130bc3467a (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/mtd/mtdpart.c')
-rw-r--r--drivers/mtd/mtdpart.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 144e6b613a77..29675edb44b4 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -48,8 +48,11 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
48 size_t *retlen, u_char *buf) 48 size_t *retlen, u_char *buf)
49{ 49{
50 struct mtd_part *part = PART(mtd); 50 struct mtd_part *part = PART(mtd);
51 struct mtd_ecc_stats stats;
51 int res; 52 int res;
52 53
54 stats = part->master->ecc_stats;
55
53 if (from >= mtd->size) 56 if (from >= mtd->size)
54 len = 0; 57 len = 0;
55 else if (from + len > mtd->size) 58 else if (from + len > mtd->size)
@@ -58,9 +61,9 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
58 len, retlen, buf); 61 len, retlen, buf);
59 if (unlikely(res)) { 62 if (unlikely(res)) {
60 if (res == -EUCLEAN) 63 if (res == -EUCLEAN)
61 mtd->ecc_stats.corrected++; 64 mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
62 if (res == -EBADMSG) 65 if (res == -EBADMSG)
63 mtd->ecc_stats.failed++; 66 mtd->ecc_stats.failed += part->master->ecc_stats.failed - stats.failed;
64 } 67 }
65 return res; 68 return res;
66} 69}
@@ -84,6 +87,18 @@ static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
84 part->master->unpoint(part->master, from + part->offset, len); 87 part->master->unpoint(part->master, from + part->offset, len);
85} 88}
86 89
90static unsigned long part_get_unmapped_area(struct mtd_info *mtd,
91 unsigned long len,
92 unsigned long offset,
93 unsigned long flags)
94{
95 struct mtd_part *part = PART(mtd);
96
97 offset += part->offset;
98 return part->master->get_unmapped_area(part->master, len, offset,
99 flags);
100}
101
87static int part_read_oob(struct mtd_info *mtd, loff_t from, 102static int part_read_oob(struct mtd_info *mtd, loff_t from,
88 struct mtd_oob_ops *ops) 103 struct mtd_oob_ops *ops)
89{ 104{
@@ -342,6 +357,12 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
342 357
343 slave->mtd.name = part->name; 358 slave->mtd.name = part->name;
344 slave->mtd.owner = master->owner; 359 slave->mtd.owner = master->owner;
360 slave->mtd.backing_dev_info = master->backing_dev_info;
361
362 /* NOTE: we don't arrange MTDs as a tree; it'd be error-prone
363 * to have the same data be in two different partitions.
364 */
365 slave->mtd.dev.parent = master->dev.parent;
345 366
346 slave->mtd.read = part_read; 367 slave->mtd.read = part_read;
347 slave->mtd.write = part_write; 368 slave->mtd.write = part_write;
@@ -354,6 +375,8 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
354 slave->mtd.unpoint = part_unpoint; 375 slave->mtd.unpoint = part_unpoint;
355 } 376 }
356 377
378 if (master->get_unmapped_area)
379 slave->mtd.get_unmapped_area = part_get_unmapped_area;
357 if (master->read_oob) 380 if (master->read_oob)
358 slave->mtd.read_oob = part_read_oob; 381 slave->mtd.read_oob = part_read_oob;
359 if (master->write_oob) 382 if (master->write_oob)
@@ -493,7 +516,9 @@ out_register:
493 * This function, given a master MTD object and a partition table, creates 516 * This function, given a master MTD object and a partition table, creates
494 * and registers slave MTD objects which are bound to the master according to 517 * and registers slave MTD objects which are bound to the master according to
495 * the partition definitions. 518 * the partition definitions.
496 * (Q: should we register the master MTD object as well?) 519 *
520 * We don't register the master, or expect the caller to have done so,
521 * for reasons of data integrity.
497 */ 522 */
498 523
499int add_mtd_partitions(struct mtd_info *master, 524int add_mtd_partitions(struct mtd_info *master,