summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/core.c20
-rw-r--r--drivers/mtd/mtdoob.c3
-rw-r--r--drivers/mtd/mtdraw.c9
-rw-r--r--drivers/mtd/nand/nand-bb.c30
-rw-r--r--drivers/mtd/ubi/cdev.c8
5 files changed, 39 insertions, 31 deletions
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 87dcba6801..5510439a87 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -31,11 +31,12 @@
static LIST_HEAD(mtd_register_hooks);
static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
- ulong offset, ulong flags)
+ loff_t _offset, ulong flags)
{
struct mtd_info *mtd = cdev->priv;
size_t retlen;
int ret;
+ unsigned long offset = _offset;
debug("mtd_read: 0x%08lx 0x%08x\n", offset, count);
@@ -64,13 +65,14 @@ static int all_ff(const void *buf, int len)
}
static ssize_t mtd_write(struct cdev* cdev, const void *buf, size_t _count,
- ulong offset, ulong flags)
+ loff_t _offset, ulong flags)
{
struct mtd_info *mtd = cdev->priv;
size_t retlen, now;
int ret = 0;
void *wrbuf = NULL;
size_t count = _count;
+ unsigned long offset = _offset;
if (NOTALIGNED(offset)) {
printf("offset 0x%0lx not page aligned\n", offset);
@@ -123,16 +125,17 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
struct mtd_ecc_stats *ecc = buf;
#endif
struct region_info_user *reg = buf;
+ loff_t *offset = buf;
switch (request) {
case MEMGETBADBLOCK:
- dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08lx\n", (off_t)buf);
- ret = mtd->block_isbad(mtd, (off_t)buf);
+ dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08llx\n", *offset);
+ ret = mtd->block_isbad(mtd, *offset);
break;
#ifdef CONFIG_MTD_WRITE
case MEMSETBADBLOCK:
- dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08lx\n", (off_t)buf);
- ret = mtd->block_markbad(mtd, (off_t)buf);
+ dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08llx\n", *offset);
+ ret = mtd->block_markbad(mtd, *offset);
break;
#endif
case MEMGETINFO:
@@ -156,9 +159,10 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
#endif
case MEMGETREGIONINFO:
if (cdev->mtd) {
+ unsigned long size = cdev->size;
reg->offset = cdev->offset;
reg->erasesize = cdev->mtd->erasesize;
- reg->numblocks = cdev->size/reg->erasesize;
+ reg->numblocks = size / reg->erasesize;
reg->regionindex = cdev->mtd->index;
}
break;
@@ -170,7 +174,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
}
#ifdef CONFIG_MTD_WRITE
-static ssize_t mtd_erase(struct cdev *cdev, size_t count, unsigned long offset)
+static ssize_t mtd_erase(struct cdev *cdev, size_t count, loff_t offset)
{
struct mtd_info *mtd = cdev->priv;
struct erase_info erase;
diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c
index be656a4d33..e4dd1a00c8 100644
--- a/drivers/mtd/mtdoob.c
+++ b/drivers/mtd/mtdoob.c
@@ -38,11 +38,12 @@ static struct mtd_info *to_mtd(struct cdev *cdev)
}
static ssize_t mtd_read_oob(struct cdev *cdev, void *buf, size_t count,
- ulong offset, ulong flags)
+ loff_t _offset, ulong flags)
{
struct mtd_info *mtd = to_mtd(cdev);
struct mtd_oob_ops ops;
int ret;
+ unsigned long offset = _offset;
if (count < mtd->oobsize)
return -EINVAL;
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 7abe2351a5..24f7358098 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -116,12 +116,13 @@ err:
}
static ssize_t mtdraw_read(struct cdev *cdev, void *buf, size_t count,
- ulong offset, ulong flags)
+ loff_t _offset, ulong flags)
{
struct mtd_info *mtd = to_mtd(cdev);
ssize_t retlen = 0, ret = 1, toread;
ulong numpage;
int skip;
+ unsigned long offset = _offset;
numpage = offset / (mtd->writesize + mtd->oobsize);
skip = offset % (mtd->writesize + mtd->oobsize);
@@ -167,13 +168,14 @@ static void mtdraw_fillbuf(struct mtdraw *mtdraw, const void *src, int nbbytes)
}
static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
- ulong offset, ulong flags)
+ loff_t _offset, ulong flags)
{
struct mtdraw *mtdraw = to_mtdraw(cdev);
struct mtd_info *mtd = to_mtd(cdev);
int bsz = mtd->writesize + mtd->oobsize;
ulong numpage;
size_t retlen = 0, tofill;
+ unsigned long offset = _offset;
int ret = 0;
if (mtdraw->write_fill &&
@@ -220,10 +222,11 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
}
}
-static ssize_t mtdraw_erase(struct cdev *cdev, size_t count, ulong offset)
+static ssize_t mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
{
struct mtd_info *mtd = to_mtd(cdev);
struct erase_info erase;
+ unsigned long offset = _offset;
int ret;
offset = offset / (mtd->writesize + mtd->oobsize) * mtd->writesize;
diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index bd30438958..d27274924a 100644
--- a/drivers/mtd/nand/nand-bb.c
+++ b/drivers/mtd/nand/nand-bb.c
@@ -42,9 +42,9 @@ struct nand_bb {
struct mtd_info_user info;
- size_t raw_size;
- size_t size;
- off_t offset;
+ loff_t raw_size;
+ loff_t size;
+ loff_t offset;
unsigned long flags;
void *writebuf;
@@ -54,7 +54,7 @@ struct nand_bb {
};
static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
- unsigned long offset, ulong flags)
+ loff_t offset, ulong flags)
{
struct nand_bb *bb = cdev->priv;
struct cdev *parent = bb->cdev_parent;
@@ -63,18 +63,18 @@ static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
debug("%s %d %d\n", __func__, offset, count);
while(count) {
- ret = cdev_ioctl(parent, MEMGETBADBLOCK, (void *)bb->offset);
+ ret = cdev_ioctl(parent, MEMGETBADBLOCK, &bb->offset);
if (ret < 0)
return ret;
if (ret) {
- printf("skipping bad block at 0x%08lx\n", bb->offset);
+ printf("skipping bad block at 0x%08llx\n", bb->offset);
bb->offset += bb->info.erasesize;
continue;
}
now = min(count, (size_t)(bb->info.erasesize -
- (bb->offset % bb->info.erasesize)));
+ ((size_t)bb->offset % bb->info.erasesize)));
ret = cdev_read(parent, buf, now, bb->offset, 0);
if (ret < 0)
return ret;
@@ -96,10 +96,10 @@ static int nand_bb_write_buf(struct nand_bb *bb, size_t count)
int ret, now;
struct cdev *parent = bb->cdev_parent;
void *buf = bb->writebuf;
- int cur_ofs = bb->offset & ~(BB_WRITEBUF_SIZE - 1);
+ off_t cur_ofs = bb->offset & ~(BB_WRITEBUF_SIZE - 1);
while (count) {
- ret = cdev_ioctl(parent, MEMGETBADBLOCK, (void *)cur_ofs);
+ ret = cdev_ioctl(parent, MEMGETBADBLOCK, &cur_ofs);
if (ret < 0)
return ret;
@@ -123,12 +123,12 @@ static int nand_bb_write_buf(struct nand_bb *bb, size_t count)
}
static ssize_t nand_bb_write(struct cdev *cdev, const void *buf, size_t count,
- unsigned long offset, ulong flags)
+ loff_t offset, ulong flags)
{
struct nand_bb *bb = cdev->priv;
int bytes = count, now, wroffs, ret;
- debug("%s offset: 0x%08x count: 0x%08x\n", __func__, offset, count);
+ debug("%s offset: 0x%08llx count: 0x%08x\n", __func__, offset, count);
while (count) {
wroffs = bb->offset % BB_WRITEBUF_SIZE;
@@ -152,7 +152,7 @@ static ssize_t nand_bb_write(struct cdev *cdev, const void *buf, size_t count,
return bytes;
}
-static int nand_bb_erase(struct cdev *cdev, size_t count, unsigned long offset)
+static int nand_bb_erase(struct cdev *cdev, size_t count, loff_t offset)
{
struct nand_bb *bb = cdev->priv;
@@ -197,11 +197,11 @@ static int nand_bb_close(struct cdev *cdev)
static int nand_bb_calc_size(struct nand_bb *bb)
{
- ulong pos = 0;
+ loff_t pos = 0;
int ret;
while (pos < bb->raw_size) {
- ret = cdev_ioctl(bb->cdev_parent, MEMGETBADBLOCK, (void *)pos);
+ ret = cdev_ioctl(bb->cdev_parent, MEMGETBADBLOCK, &pos);
if (ret < 0)
return ret;
if (!ret)
@@ -213,7 +213,7 @@ static int nand_bb_calc_size(struct nand_bb *bb)
return 0;
}
-static off_t nand_bb_lseek(struct cdev *cdev, off_t __offset)
+static loff_t nand_bb_lseek(struct cdev *cdev, loff_t __offset)
{
struct nand_bb *bb = cdev->priv;
unsigned long raw_pos = 0;
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 95bef1f9e0..c99b64db21 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -12,7 +12,7 @@ struct ubi_volume_cdev_priv {
};
static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
- unsigned long offset, unsigned long flags)
+ loff_t offset, unsigned long flags)
{
struct ubi_volume_cdev_priv *priv = cdev->priv;
struct ubi_volume *vol = priv->vol;
@@ -23,7 +23,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
loff_t offp = offset;
int usable_leb_size = vol->usable_leb_size;
- printf("%s: %d @ 0x%08lx\n", __func__, size, offset);
+ printf("%s: %d @ 0x%08llx\n", __func__, size, offset);
len = size > usable_leb_size ? usable_leb_size : size;
@@ -56,7 +56,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
}
static ssize_t ubi_volume_cdev_write(struct cdev* cdev, const void *buf,
- size_t size, unsigned long offset, unsigned long flags)
+ size_t size, loff_t offset, unsigned long flags)
{
struct ubi_volume_cdev_priv *priv = cdev->priv;
struct ubi_volume *vol = priv->vol;
@@ -121,7 +121,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
return 0;
}
-static off_t ubi_volume_cdev_lseek(struct cdev *cdev, off_t ofs)
+static loff_t ubi_volume_cdev_lseek(struct cdev *cdev, loff_t ofs)
{
struct ubi_volume_cdev_priv *priv = cdev->priv;