mtd: introduce mtd_unpoint interface

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
Artem Bityutskiy 2011-12-23 17:05:52 +02:00 committed by David Woodhouse
parent d35ea200c0
commit 7219778ad9
5 changed files with 14 additions and 10 deletions

View File

@ -97,7 +97,7 @@ static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{ {
struct mtd_part *part = PART(mtd); struct mtd_part *part = PART(mtd);
part->master->unpoint(part->master, from + part->offset, len); mtd_unpoint(part->master, from + part->offset, len);
} }
static unsigned long part_get_unmapped_area(struct mtd_info *mtd, static unsigned long part_get_unmapped_area(struct mtd_info *mtd,

View File

@ -349,7 +349,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
if (retlen < c->sector_size) { if (retlen < c->sector_size) {
/* Don't muck about if it won't let us point to the whole erase sector */ /* Don't muck about if it won't let us point to the whole erase sector */
D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen));
c->mtd->unpoint(c->mtd, jeb->offset, retlen); mtd_unpoint(c->mtd, jeb->offset, retlen);
goto do_flash_read; goto do_flash_read;
} }
wordebuf = ebuf-sizeof(*wordebuf); wordebuf = ebuf-sizeof(*wordebuf);
@ -358,7 +358,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
if (*++wordebuf != ~0) if (*++wordebuf != ~0)
break; break;
} while(--retlen); } while(--retlen);
c->mtd->unpoint(c->mtd, jeb->offset, c->sector_size); mtd_unpoint(c->mtd, jeb->offset, c->sector_size);
if (retlen) { if (retlen) {
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n", printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
*wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf)); *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));

View File

@ -67,7 +67,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
NULL); NULL);
if (!err && retlen < len) { if (!err && retlen < len) {
JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize);
c->mtd->unpoint(c->mtd, ofs, retlen); mtd_unpoint(c->mtd, ofs, retlen);
} else if (err) } else if (err)
JFFS2_WARNING("MTD point failed: error code %d.\n", err); JFFS2_WARNING("MTD point failed: error code %d.\n", err);
else else
@ -101,7 +101,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
kfree(buffer); kfree(buffer);
#ifndef __ECOS #ifndef __ECOS
else else
c->mtd->unpoint(c->mtd, ofs, len); mtd_unpoint(c->mtd, ofs, len);
#endif #endif
if (crc != tn->data_crc) { if (crc != tn->data_crc) {
@ -137,7 +137,7 @@ free_out:
kfree(buffer); kfree(buffer);
#ifndef __ECOS #ifndef __ECOS
else else
c->mtd->unpoint(c->mtd, ofs, len); mtd_unpoint(c->mtd, ofs, len);
#endif #endif
return err; return err;
} }

View File

@ -102,7 +102,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
if (!ret && pointlen < c->mtd->size) { if (!ret && pointlen < c->mtd->size) {
/* Don't muck about if it won't let us point to the whole flash */ /* 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)); D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen));
c->mtd->unpoint(c->mtd, 0, pointlen); mtd_unpoint(c->mtd, 0, pointlen);
flashbuf = NULL; flashbuf = NULL;
} }
if (ret) if (ret)
@ -273,7 +273,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
kfree(flashbuf); kfree(flashbuf);
#ifndef __ECOS #ifndef __ECOS
else else
c->mtd->unpoint(c->mtd, 0, c->mtd->size); mtd_unpoint(c->mtd, 0, c->mtd->size);
#endif #endif
kfree(s); kfree(s);
return ret; return ret;

View File

@ -177,8 +177,6 @@ struct mtd_info {
int (*erase) (struct mtd_info *mtd, struct erase_info *instr); int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
int (*point) (struct mtd_info *mtd, loff_t from, size_t len, 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); void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
/* Allow NOMMU mmap() to directly map the device (if not NULL) /* Allow NOMMU mmap() to directly map the device (if not NULL)
@ -289,6 +287,12 @@ static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
return mtd->point(mtd, from, len, retlen, virt, phys); return mtd->point(mtd, from, len, retlen, virt, phys);
} }
/* We probably shouldn't allow XIP if the unpoint isn't a NULL */
static inline void mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{
return mtd->unpoint(mtd, from, len);
}
static inline struct mtd_info *dev_to_mtd(struct device *dev) static inline struct mtd_info *dev_to_mtd(struct device *dev)
{ {
return dev ? dev_get_drvdata(dev) : NULL; return dev ? dev_get_drvdata(dev) : NULL;