From be573120fe20e2735e8ec8db26c2f3feeec11bf4 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 19 Oct 2011 09:27:47 +0200 Subject: make cdev 64bit capable Next step to 64bit support: Make cdev size a 64bit type. Signed-off-by: Sascha Hauer --- common/block.c | 2 +- drivers/base/driver.c | 2 +- fs/devfs-core.c | 9 +++++---- fs/devfs.c | 4 ++-- fs/fs.c | 2 +- include/driver.h | 10 +++++----- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/common/block.c b/common/block.c index 1db06cc98d..e40374f79f 100644 --- a/common/block.c +++ b/common/block.c @@ -338,7 +338,7 @@ static struct file_operations block_ops = { int blockdevice_register(struct block_device *blk) { - size_t size = blk->num_blocks * BLOCKSIZE(blk); + loff_t size = (loff_t)blk->num_blocks * BLOCKSIZE(blk); int ret; int i; diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 81cedca1db..a5c6fb9293 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -339,7 +339,7 @@ static int do_devinfo_subtree(struct device_d *dev, int depth) list_for_each_entry(cdev, &dev->cdevs, devices_list) { for (i = 0; i < depth + 1; i++) printf(" "); - printf("`---- 0x%08lx-0x%08lx: /dev/%s\n", + printf("`---- 0x%08llx-0x%08llx: /dev/%s\n", cdev->offset, cdev->offset + cdev->size - 1, cdev->name); diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 6a56d34f27..b66965e390 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -96,7 +96,7 @@ void cdev_close(struct cdev *cdev) cdev->ops->close(cdev); } -ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags) +ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) { if (!cdev->ops->read) return -ENOSYS; @@ -104,7 +104,7 @@ ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulon return cdev->ops->read(cdev, buf, count, cdev->offset +offset, flags); } -ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags) +ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) { if (!cdev->ops->write) return -ENOSYS; @@ -165,10 +165,11 @@ static int partition_ioctl(struct cdev *cdev, int request, void *buf) case MEMGETREGIONINFO: if (cdev->mtd) { struct region_info_user *reg = buf; + int erasesize_shift = ffs(cdev->mtd->erasesize) - 1; reg->offset = cdev->offset; reg->erasesize = cdev->mtd->erasesize; - reg->numblocks = cdev->size/reg->erasesize; + reg->numblocks = cdev->size >> erasesize_shift; reg->regionindex = cdev->mtd->index; } break; @@ -191,7 +192,7 @@ int cdev_ioctl(struct cdev *cdev, int request, void *buf) return cdev->ops->ioctl(cdev, request, buf); } -int cdev_erase(struct cdev *cdev, size_t count, unsigned long offset) +int cdev_erase(struct cdev *cdev, size_t count, loff_t offset) { if (!cdev->ops->erase) return -ENOSYS; diff --git a/fs/devfs.c b/fs/devfs.c index 863f4ec33e..5aace362e2 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -55,7 +55,7 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s static loff_t devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos) { struct cdev *cdev = f->inode; - off_t ret = -1; + loff_t ret = -1; if (cdev->ops->lseek) ret = cdev->ops->lseek(cdev, pos + cdev->offset); @@ -100,7 +100,7 @@ static int devfs_memmap(struct device_d *_dev, FILE *f, void **map, int flags) ret = cdev->ops->memmap(cdev, map, flags); if (!ret) - *map = (void *)((unsigned long)*map + cdev->offset); + *map = (void *)((unsigned long)*map + (unsigned long)cdev->offset); return ret; } diff --git a/fs/fs.c b/fs/fs.c index 6d1d703909..7dd6c03816 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -697,7 +697,7 @@ loff_t lseek(int fildes, loff_t offset, int whence) struct device_d *dev; struct fs_driver_d *fsdrv; FILE *f = &files[fildes]; - off_t pos; + loff_t pos; int ret; if (check_fd(fildes)) diff --git a/include/driver.h b/include/driver.h index 4a8d48a873..0b6d1b30c5 100644 --- a/include/driver.h +++ b/include/driver.h @@ -395,8 +395,8 @@ struct cdev { struct list_head list; struct list_head devices_list; char *name; - unsigned long offset; - size_t size; + loff_t offset; + loff_t size; unsigned int flags; int open; struct mtd_info *mtd; @@ -409,10 +409,10 @@ struct cdev *cdev_by_name(const char *filename); struct cdev *cdev_open(const char *name, unsigned long flags); void cdev_close(struct cdev *cdev); int cdev_flush(struct cdev *cdev); -ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags); -ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags); +ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags); +ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags); int cdev_ioctl(struct cdev *cdev, int cmd, void *buf); -int cdev_erase(struct cdev *cdev, size_t count, unsigned long offset); +int cdev_erase(struct cdev *cdev, size_t count, loff_t offset); #define DEVFS_PARTITION_FIXED (1 << 0) #define DEVFS_PARTITION_READONLY (1 << 1) -- cgit v1.2.3