diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-14 10:31:37 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-14 10:31:39 +0100 |
commit | 7b7cf936cb834a70f3bfea4a2c9395534b4d2e3b (patch) | |
tree | 0e6552d3d83a51d9303666430e1423291f01b982 /drivers | |
parent | b600cb936ee219aa7c2d9c32371a2fd355c009e5 (diff) | |
download | barebox-7b7cf936cb834a70f3bfea4a2c9395534b4d2e3b.tar.gz barebox-7b7cf936cb834a70f3bfea4a2c9395534b4d2e3b.tar.xz |
mtd: Add mtd_* functions
The Kernel has mtd_read, mtd_write, mtd_erase and mtd_block_markbad.
Add these functions to barebox aswell to make future mtd synchronizations
with the kernel easier.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/core.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 40c522f947..47c0226ade 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -30,15 +30,6 @@ static LIST_HEAD(mtd_register_hooks); -int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) -{ - if (!mtd->block_isbad) - return 0; - if (ofs < 0 || ofs > mtd->size) - return -EINVAL; - return mtd->block_isbad(mtd, ofs); -} - static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count, loff_t _offset, ulong flags) { @@ -170,6 +161,46 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf) return ret; } +int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) +{ + if (!mtd->block_isbad) + return 0; + + if (ofs < 0 || ofs > mtd->size) + return -EINVAL; + + return mtd->block_isbad(mtd, ofs); +} + +int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) +{ + int ret; + + if (mtd->block_markbad) + ret = mtd->block_markbad(mtd, ofs); + else + ret = -ENOSYS; + + return ret; +} + +int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, + u_char *buf) +{ + return mtd->read(mtd, from, len, retlen, buf); +} + +int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, + const u_char *buf) +{ + return mtd->write(mtd, to, len, retlen, buf); +} + +int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) +{ + return mtd->erase(mtd, instr); +} + static struct file_operations mtd_ops = { .read = mtd_op_read, #ifdef CONFIG_MTD_WRITE |