Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142319
b: refs/heads/master
c: 6e232cf
h: refs/heads/master
i:
  142317: 045c472
  142315: 6ec693f
  142311: 0ba8eeb
  142303: ee8de63
v: v3
  • Loading branch information
David Howells authored and David Woodhouse committed Mar 24, 2009
1 parent af39fad commit b2e3a83
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 402d326519c1a4859c527702383f4e60f606ef52
refs/heads/master: 6e232cfce35a20a8702d9ac7709d35030c1b3271
47 changes: 47 additions & 0 deletions trunk/drivers/mtd/mtdconcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/backing-dev.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/concat.h>
Expand Down Expand Up @@ -683,6 +684,40 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
return err;
}

/*
* try to support NOMMU mmaps on concatenated devices
* - we don't support subdev spanning as we can't guarantee it'll work
*/
static unsigned long concat_get_unmapped_area(struct mtd_info *mtd,
unsigned long len,
unsigned long offset,
unsigned long flags)
{
struct mtd_concat *concat = CONCAT(mtd);
int i;

for (i = 0; i < concat->num_subdev; i++) {
struct mtd_info *subdev = concat->subdev[i];

if (offset >= subdev->size) {
offset -= subdev->size;
continue;
}

/* we've found the subdev over which the mapping will reside */
if (offset + len > subdev->size)
return (unsigned long) -EINVAL;

if (subdev->get_unmapped_area)
return subdev->get_unmapped_area(subdev, len, offset,
flags);

break;
}

return (unsigned long) -ENOSYS;
}

/*
* This function constructs a virtual MTD device by concatenating
* num_devs MTD devices. A pointer to the new device object is
Expand Down Expand Up @@ -740,6 +775,8 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c

concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;

concat->mtd.backing_dev_info = subdev[0]->backing_dev_info;

concat->subdev[0] = subdev[0];

for (i = 1; i < num_devs; i++) {
Expand All @@ -766,6 +803,15 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.flags |=
subdev[i]->flags & MTD_WRITEABLE;
}

/* only permit direct mapping if the BDIs are all the same
* - copy-mapping is still permitted
*/
if (concat->mtd.backing_dev_info !=
subdev[i]->backing_dev_info)
concat->mtd.backing_dev_info =
&default_backing_dev_info;

concat->mtd.size += subdev[i]->size;
concat->mtd.ecc_stats.badblocks +=
subdev[i]->ecc_stats.badblocks;
Expand Down Expand Up @@ -796,6 +842,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.unlock = concat_unlock;
concat->mtd.suspend = concat_suspend;
concat->mtd.resume = concat_resume;
concat->mtd.get_unmapped_area = concat_get_unmapped_area;

/*
* Combine the erase block size info of the subdevices:
Expand Down

0 comments on commit b2e3a83

Please sign in to comment.