9
0
Fork 0

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>
This commit is contained in:
Sascha Hauer 2011-10-14 11:57:55 +02:00
parent 1a5503118a
commit e71c343668
3 changed files with 16 additions and 15 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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) {