Skip to content

Commit

Permalink
mtd: introduce mtd_point interface
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Artem Bityutskiy authored and David Woodhouse committed Jan 9, 2012
1 parent 7e1f0dc commit d35ea20
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len,
len = 0;
else if (from + len > mtd->size)
len = mtd->size - from;
return part->master->point (part->master, from + part->offset,
len, retlen, virt, phys);
return mtd_point(part->master, from + part->offset, len, retlen,
virt, phys);
}

static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/erase.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
if (c->mtd->point) {
unsigned long *wordebuf;

ret = c->mtd->point(c->mtd, jeb->offset, c->sector_size,
&retlen, &ebuf, NULL);
ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen,
&ebuf, NULL);
if (ret) {
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
goto do_flash_read;
Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/readinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
/* TODO: instead, incapsulate point() stuff to jffs2_flash_read(),
* adding and jffs2_flash_read_end() interface. */
if (c->mtd->point) {
err = c->mtd->point(c->mtd, ofs, len, &retlen,
(void **)&buffer, NULL);
err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer,
NULL);
if (!err && retlen < len) {
JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize);
c->mtd->unpoint(c->mtd, ofs, retlen);
Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
size_t pointlen, try_size;

if (c->mtd->point) {
ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen,
(void **)&flashbuf, NULL);
ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen,
(void **)&flashbuf, NULL);
if (!ret && pointlen < c->mtd->size) {
/* Don't muck about if it won't let us point to the whole flash */
D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen));
Expand Down
14 changes: 10 additions & 4 deletions include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,8 @@ struct mtd_info {
* wrappers instead.
*/
int (*erase) (struct mtd_info *mtd, struct erase_info *instr);

/* This stuff for eXecute-In-Place */
/* phys is optional and may be set to NULL */
int (*point) (struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys);
size_t *retlen, void **virt, resource_size_t *phys);

/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
Expand Down Expand Up @@ -283,6 +280,15 @@ static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
return mtd->erase(mtd, instr);
}

/*
* This stuff for eXecute-In-Place. phys is optional and may be set to NULL.
*/
static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys)
{
return mtd->point(mtd, from, len, retlen, virt, phys);
}

static inline struct mtd_info *dev_to_mtd(struct device *dev)
{
return dev ? dev_get_drvdata(dev) : NULL;
Expand Down

0 comments on commit d35ea20

Please sign in to comment.