[PATCH 5/5] Use size_t for memory offsets
Sascha Hauer
s.hauer at pengutronix.de
Fri Oct 14 08:11:58 EDT 2011
On Fri, Oct 14, 2011 at 10:59:03AM +0200, Loïc Minier wrote:
> On Fri, Oct 14, 2011, Sascha Hauer wrote:
> > You should change the prototypes in include/driver.h aswell.
>
> Ah thanks, now it strikes me that the very same constructs are present
> in many file_operations implementations; e.g. imx_iim_cdev_read and
> imx_iim_cdev_write also use an ulong offset, as well as
> ubi_volume_cdev_read/ubi_volume_cdev_write (unsigned long), lp_read,
> miidev_read/_write etc.
>
> I had a look at file_operations in linux now, and it uses
> size_t/ssize_t and a loff_t type for regular read/write:
> struct file_operations {
> loff_t (*llseek) (struct file *, loff_t, int);
> ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
> ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
>
> however for aio:
> ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
> ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
>
> loff_t is defined as long long on 32-bits and 64-bits arches, which I
> believe are both 8 bytes.
>
> So perhaps it's better to switch from ulong to unsigned long long for
> offsets? This isn't important for mem_read/mem_write, but it would be
> for e.g. MMC accesses as it's of course valid to seek after the first
> 4 G of a MMC on a 32-bits system.
Yes, an 8 byte type would be definitely better for file offsets. It
would be a first step to support SD cards > 4G. I have looked into
this several times before and ended up with huge patches everytime
I tried.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list