summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-10-14 11:57:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-06-30 16:53:16 +0200
commite71c34366808bbe3ce0b166d8710749513af6d81 (patch)
treef31327dd33e5b8024bac037d50ad82fffb8f61d1
parent1a5503118a95a0080ed93b07a996282cc54ce595 (diff)
downloadbarebox-e71c34366808bbe3ce0b166d8710749513af6d81.tar.gz
barebox-e71c34366808bbe3ce0b166d8710749513af6d81.tar.xz
mtd: fix arguments to bad block ioctls
In the Kernel the mtd ioctls expect a pointer to the offset, whereas barebox interprets the pointer itself as an offset. Since we want to add 64bit support for file sizes a pointer may not be sufficient, so align with the kernel and convert it to a pointer to the offset. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/mtd/core.c5
-rw-r--r--drivers/mtd/nand/nand-bb.c20
-rw-r--r--fs/devfs-core.c6
3 files changed, 16 insertions, 15 deletions
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 87dcba6801..2ce08a6936 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -123,16 +123,17 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
struct mtd_ecc_stats *ecc = buf;
#endif
struct region_info_user *reg = buf;
+ off_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);
+ 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);
+ ret = mtd->block_markbad(mtd, *offset);
break;
#endif
case MEMGETINFO:
diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index bd30438958..0377f1e78d 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;
@@ -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;
@@ -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)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index ff6a97627a..6a56d34f27 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -123,15 +123,15 @@ int cdev_flush(struct cdev *cdev)
static int partition_ioctl(struct cdev *cdev, int request, void *buf)
{
int ret = 0;
- size_t offset;
+ loff_t offset, *_buf = buf;
struct mtd_info_user *user = buf;
switch (request) {
case MEMSETBADBLOCK:
case MEMGETBADBLOCK:
- offset = (off_t)buf;
+ offset = *_buf;
offset += cdev->offset;
- ret = cdev->ops->ioctl(cdev, request, (void *)offset);
+ ret = cdev->ops->ioctl(cdev, request, &offset);
break;
case MEMGETINFO:
if (cdev->mtd) {