use loff_t for file offsets
This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
e71c343668
commit
3e503822c7
|
@ -84,7 +84,7 @@ static int do_fuse_sense(void __iomem *reg_base, unsigned int bank,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
|
static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
ulong size, i;
|
ulong size, i;
|
||||||
struct iim_priv *priv = cdev->priv;
|
struct iim_priv *priv = cdev->priv;
|
||||||
|
@ -94,7 +94,7 @@ static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
|
||||||
if ((sense_param = dev_get_param(cdev->dev, "explicit_sense_enable")))
|
if ((sense_param = dev_get_param(cdev->dev, "explicit_sense_enable")))
|
||||||
explicit_sense = simple_strtoul(sense_param, NULL, 0);
|
explicit_sense = simple_strtoul(sense_param, NULL, 0);
|
||||||
|
|
||||||
size = min((ulong)count, priv->banksize - offset);
|
size = min((loff_t)count, priv->banksize - offset);
|
||||||
if (explicit_sense) {
|
if (explicit_sense) {
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
int row_val;
|
int row_val;
|
||||||
|
@ -176,7 +176,7 @@ out:
|
||||||
#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
|
#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
|
||||||
|
|
||||||
static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t count,
|
static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
ulong size, i;
|
ulong size, i;
|
||||||
struct iim_priv *priv = cdev->priv;
|
struct iim_priv *priv = cdev->priv;
|
||||||
|
@ -186,7 +186,7 @@ static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t cou
|
||||||
if ((write_param = dev_get_param(cdev->dev, "permanent_write_enable")))
|
if ((write_param = dev_get_param(cdev->dev, "permanent_write_enable")))
|
||||||
blow_enable = simple_strtoul(write_param, NULL, 0);
|
blow_enable = simple_strtoul(write_param, NULL, 0);
|
||||||
|
|
||||||
size = min((ulong)count, priv->banksize - offset);
|
size = min((loff_t)count, priv->banksize - offset);
|
||||||
#ifdef CONFIG_IMX_IIM_FUSE_BLOW
|
#ifdef CONFIG_IMX_IIM_FUSE_BLOW
|
||||||
if (blow_enable) {
|
if (blow_enable) {
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
|
|
|
@ -40,11 +40,11 @@ struct ocotp_priv {
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t mxs_ocotp_cdev_read(struct cdev *cdev, void *buf, size_t count,
|
static ssize_t mxs_ocotp_cdev_read(struct cdev *cdev, void *buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct ocotp_priv *priv = cdev->priv;
|
struct ocotp_priv *priv = cdev->priv;
|
||||||
void __iomem *base = priv->base;
|
void __iomem *base = priv->base;
|
||||||
size_t size = min((ulong)count, cdev->size - offset);
|
size_t size = min((loff_t)count, cdev->size - offset);
|
||||||
uint64_t start;
|
uint64_t start;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct hf_priv {
|
||||||
struct hf_platform_data *pdata;
|
struct hf_platform_data *pdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
|
static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct hf_platform_data *hf = cdev->priv;
|
struct hf_platform_data *hf = cdev->priv;
|
||||||
int fd = hf->fd;
|
int fd = hf->fd;
|
||||||
|
@ -45,7 +45,7 @@ static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, ulong offset,
|
||||||
return linux_read(fd, buf, count);
|
return linux_read(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
|
static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct hf_platform_data *hf = cdev->priv;
|
struct hf_platform_data *hf = cdev->priv;
|
||||||
int fd = hf->fd;
|
int fd = hf->fd;
|
||||||
|
|
|
@ -624,7 +624,7 @@ static int mem_init(void)
|
||||||
|
|
||||||
device_initcall(mem_init);
|
device_initcall(mem_init);
|
||||||
|
|
||||||
static ssize_t zero_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
|
static ssize_t zero_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
memset(buf, 0, count);
|
memset(buf, 0, count);
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -179,7 +179,7 @@ static void *block_get(struct block_device *blk, int block)
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,
|
static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,
|
||||||
unsigned long offset, unsigned long flags)
|
loff_t offset, unsigned long flags)
|
||||||
{
|
{
|
||||||
struct block_device *blk = cdev->priv;
|
struct block_device *blk = cdev->priv;
|
||||||
unsigned long mask = BLOCKSIZE(blk) - 1;
|
unsigned long mask = BLOCKSIZE(blk) - 1;
|
||||||
|
@ -256,7 +256,7 @@ static int block_put(struct block_device *blk, const void *buf, int block)
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,
|
static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,
|
||||||
unsigned long offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct block_device *blk = cdev->priv;
|
struct block_device *blk = cdev->priv;
|
||||||
unsigned long mask = BLOCKSIZE(blk) - 1;
|
unsigned long mask = BLOCKSIZE(blk) - 1;
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct at25_data {
|
||||||
static ssize_t at25_ee_read(struct cdev *cdev,
|
static ssize_t at25_ee_read(struct cdev *cdev,
|
||||||
void *buf,
|
void *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
ulong offset,
|
loff_t offset,
|
||||||
ulong flags)
|
ulong flags)
|
||||||
{
|
{
|
||||||
u8 command[EE_MAXADDRLEN + 1];
|
u8 command[EE_MAXADDRLEN + 1];
|
||||||
|
@ -117,7 +117,7 @@ static ssize_t at25_ee_read(struct cdev *cdev,
|
||||||
*/
|
*/
|
||||||
status = spi_sync(at25->spi, &m);
|
status = spi_sync(at25->spi, &m);
|
||||||
dev_dbg(at25->cdev.dev,
|
dev_dbg(at25->cdev.dev,
|
||||||
"read %d bytes at %lu --> %d\n",
|
"read %d bytes at %llu --> %d\n",
|
||||||
count, offset, (int) status);
|
count, offset, (int) status);
|
||||||
|
|
||||||
return status ? status : count;
|
return status ? status : count;
|
||||||
|
@ -126,7 +126,7 @@ static ssize_t at25_ee_read(struct cdev *cdev,
|
||||||
static ssize_t at25_ee_write(struct cdev *cdev,
|
static ssize_t at25_ee_write(struct cdev *cdev,
|
||||||
const void *buf,
|
const void *buf,
|
||||||
size_t count,
|
size_t count,
|
||||||
ulong off,
|
loff_t off,
|
||||||
ulong flags)
|
ulong flags)
|
||||||
{
|
{
|
||||||
ssize_t status = 0;
|
ssize_t status = 0;
|
||||||
|
@ -232,7 +232,7 @@ static ssize_t at25_ee_write(struct cdev *cdev,
|
||||||
return written ? written : status;
|
return written ? written : status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t at25_ee_lseek(struct cdev *cdev, off_t off)
|
static loff_t at25_ee_lseek(struct cdev *cdev, loff_t off)
|
||||||
{
|
{
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ static u32 lp_read_reg(struct lp_priv *lp, int reg)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct lp_priv *priv = to_lp_priv(cdev);
|
struct lp_priv *priv = to_lp_priv(cdev);
|
||||||
int i = count;
|
int i = count;
|
||||||
|
|
|
@ -160,7 +160,7 @@ int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u32 val)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mc13xxx_set_bits);
|
EXPORT_SYMBOL(mc13xxx_set_bits);
|
||||||
|
|
||||||
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc13xxx *priv = to_mc13xxx(cdev);
|
struct mc13xxx *priv = to_mc13xxx(cdev);
|
||||||
u32 *buf = _buf;
|
u32 *buf = _buf;
|
||||||
|
@ -181,7 +181,7 @@ static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc13xxx *mc13xxx = to_mc13xxx(cdev);
|
struct mc13xxx *mc13xxx = to_mc13xxx(cdev);
|
||||||
const u32 *buf = _buf;
|
const u32 *buf = _buf;
|
||||||
|
|
|
@ -65,7 +65,7 @@ int mc34704_reg_write(struct mc34704 *mc34704, u8 reg, u8 val)
|
||||||
EXPORT_SYMBOL(mc34704_reg_write)
|
EXPORT_SYMBOL(mc34704_reg_write)
|
||||||
|
|
||||||
static ssize_t mc34704_read(struct cdev *cdev, void *_buf, size_t count,
|
static ssize_t mc34704_read(struct cdev *cdev, void *_buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc34704 *priv = to_mc34704(cdev);
|
struct mc34704 *priv = to_mc34704(cdev);
|
||||||
u8 *buf = _buf;
|
u8 *buf = _buf;
|
||||||
|
@ -85,7 +85,7 @@ static ssize_t mc34704_read(struct cdev *cdev, void *_buf, size_t count,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mc34704_write(struct cdev *cdev, const void *_buf, size_t count,
|
static ssize_t mc34704_write(struct cdev *cdev, const void *_buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc34704 *mc34704 = to_mc34704(cdev);
|
struct mc34704 *mc34704 = to_mc34704(cdev);
|
||||||
const u8 *buf = _buf;
|
const u8 *buf = _buf;
|
||||||
|
|
|
@ -163,7 +163,8 @@ int mc34708_set_bits(struct mc34708 *mc34708, enum mc34708_reg reg, u32 mask, u3
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mc34708_set_bits);
|
EXPORT_SYMBOL(mc34708_set_bits);
|
||||||
|
|
||||||
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count,
|
||||||
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc34708 *priv = to_mc34708(cdev);
|
struct mc34708 *priv = to_mc34708(cdev);
|
||||||
u32 *buf = _buf;
|
u32 *buf = _buf;
|
||||||
|
@ -184,7 +185,8 @@ static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count,
|
||||||
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc34708 *mc34708 = to_mc34708(cdev);
|
struct mc34708 *mc34708 = to_mc34708(cdev);
|
||||||
const u32 *buf = _buf;
|
const u32 *buf = _buf;
|
||||||
|
|
|
@ -78,7 +78,7 @@ int mc9sdz60_set_bits(struct mc9sdz60 *mc9sdz60, enum mc9sdz60_reg reg, u8 mask,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mc9sdz60_set_bits);
|
EXPORT_SYMBOL(mc9sdz60_set_bits);
|
||||||
|
|
||||||
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
|
struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
|
||||||
u8 *buf = _buf;
|
u8 *buf = _buf;
|
||||||
|
@ -97,7 +97,7 @@ static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
|
struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
|
||||||
const u8 *buf = _buf;
|
const u8 *buf = _buf;
|
||||||
|
|
|
@ -112,7 +112,7 @@ int twlcore_set_bits(struct twlcore *twlcore, u16 reg, u8 mask, u8 val)
|
||||||
EXPORT_SYMBOL(twlcore_set_bits);
|
EXPORT_SYMBOL(twlcore_set_bits);
|
||||||
|
|
||||||
static ssize_t twl_read(struct cdev *cdev, void *_buf, size_t count,
|
static ssize_t twl_read(struct cdev *cdev, void *_buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct twlcore *priv = to_twlcore(cdev);
|
struct twlcore *priv = to_twlcore(cdev);
|
||||||
u8 *buf = _buf;
|
u8 *buf = _buf;
|
||||||
|
@ -131,7 +131,7 @@ static ssize_t twl_read(struct cdev *cdev, void *_buf, size_t count,
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t twl_write(struct cdev *cdev, const void *_buf, size_t count,
|
static ssize_t twl_write(struct cdev *cdev, const void *_buf, size_t count,
|
||||||
ulong offset, ulong flags)
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct twlcore *twlcore = to_twlcore(cdev);
|
struct twlcore *twlcore = to_twlcore(cdev);
|
||||||
const u8 *buf = _buf;
|
const u8 *buf = _buf;
|
||||||
|
|
|
@ -31,11 +31,12 @@
|
||||||
static LIST_HEAD(mtd_register_hooks);
|
static LIST_HEAD(mtd_register_hooks);
|
||||||
|
|
||||||
static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
|
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;
|
struct mtd_info *mtd = cdev->priv;
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned long offset = _offset;
|
||||||
|
|
||||||
debug("mtd_read: 0x%08lx 0x%08x\n", offset, count);
|
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,
|
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;
|
struct mtd_info *mtd = cdev->priv;
|
||||||
size_t retlen, now;
|
size_t retlen, now;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
void *wrbuf = NULL;
|
void *wrbuf = NULL;
|
||||||
size_t count = _count;
|
size_t count = _count;
|
||||||
|
unsigned long offset = _offset;
|
||||||
|
|
||||||
if (NOTALIGNED(offset)) {
|
if (NOTALIGNED(offset)) {
|
||||||
printf("offset 0x%0lx not page aligned\n", offset);
|
printf("offset 0x%0lx not page aligned\n", offset);
|
||||||
|
@ -123,16 +125,16 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
|
||||||
struct mtd_ecc_stats *ecc = buf;
|
struct mtd_ecc_stats *ecc = buf;
|
||||||
#endif
|
#endif
|
||||||
struct region_info_user *reg = buf;
|
struct region_info_user *reg = buf;
|
||||||
off_t *offset = buf;
|
loff_t *offset = buf;
|
||||||
|
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case MEMGETBADBLOCK:
|
case MEMGETBADBLOCK:
|
||||||
dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08lx\n", (off_t)buf);
|
dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08llx\n", *offset);
|
||||||
ret = mtd->block_isbad(mtd, *offset);
|
ret = mtd->block_isbad(mtd, *offset);
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_MTD_WRITE
|
#ifdef CONFIG_MTD_WRITE
|
||||||
case MEMSETBADBLOCK:
|
case MEMSETBADBLOCK:
|
||||||
dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08lx\n", (off_t)buf);
|
dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08llx\n", *offset);
|
||||||
ret = mtd->block_markbad(mtd, *offset);
|
ret = mtd->block_markbad(mtd, *offset);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -157,9 +159,10 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
|
||||||
#endif
|
#endif
|
||||||
case MEMGETREGIONINFO:
|
case MEMGETREGIONINFO:
|
||||||
if (cdev->mtd) {
|
if (cdev->mtd) {
|
||||||
|
unsigned long size = cdev->size;
|
||||||
reg->offset = cdev->offset;
|
reg->offset = cdev->offset;
|
||||||
reg->erasesize = cdev->mtd->erasesize;
|
reg->erasesize = cdev->mtd->erasesize;
|
||||||
reg->numblocks = cdev->size/reg->erasesize;
|
reg->numblocks = size / reg->erasesize;
|
||||||
reg->regionindex = cdev->mtd->index;
|
reg->regionindex = cdev->mtd->index;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -171,7 +174,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_WRITE
|
#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 mtd_info *mtd = cdev->priv;
|
||||||
struct erase_info erase;
|
struct erase_info erase;
|
||||||
|
|
|
@ -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,
|
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_info *mtd = to_mtd(cdev);
|
||||||
struct mtd_oob_ops ops;
|
struct mtd_oob_ops ops;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned long offset = _offset;
|
||||||
|
|
||||||
if (count < mtd->oobsize)
|
if (count < mtd->oobsize)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -116,12 +116,13 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mtdraw_read(struct cdev *cdev, void *buf, size_t count,
|
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);
|
struct mtd_info *mtd = to_mtd(cdev);
|
||||||
ssize_t retlen = 0, ret = 1, toread;
|
ssize_t retlen = 0, ret = 1, toread;
|
||||||
ulong numpage;
|
ulong numpage;
|
||||||
int skip;
|
int skip;
|
||||||
|
unsigned long offset = _offset;
|
||||||
|
|
||||||
numpage = offset / (mtd->writesize + mtd->oobsize);
|
numpage = offset / (mtd->writesize + mtd->oobsize);
|
||||||
skip = 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,
|
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 mtdraw *mtdraw = to_mtdraw(cdev);
|
||||||
struct mtd_info *mtd = to_mtd(cdev);
|
struct mtd_info *mtd = to_mtd(cdev);
|
||||||
int bsz = mtd->writesize + mtd->oobsize;
|
int bsz = mtd->writesize + mtd->oobsize;
|
||||||
ulong numpage;
|
ulong numpage;
|
||||||
size_t retlen = 0, tofill;
|
size_t retlen = 0, tofill;
|
||||||
|
unsigned long offset = _offset;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (mtdraw->write_fill &&
|
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 mtd_info *mtd = to_mtd(cdev);
|
||||||
struct erase_info erase;
|
struct erase_info erase;
|
||||||
|
unsigned long offset = _offset;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
offset = offset / (mtd->writesize + mtd->oobsize) * mtd->writesize;
|
offset = offset / (mtd->writesize + mtd->oobsize) * mtd->writesize;
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct nand_bb {
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
|
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 nand_bb *bb = cdev->priv;
|
||||||
struct cdev *parent = bb->cdev_parent;
|
struct cdev *parent = bb->cdev_parent;
|
||||||
|
@ -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,
|
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;
|
struct nand_bb *bb = cdev->priv;
|
||||||
int bytes = count, now, wroffs, ret;
|
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) {
|
while (count) {
|
||||||
wroffs = bb->offset % BB_WRITEBUF_SIZE;
|
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;
|
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;
|
struct nand_bb *bb = cdev->priv;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ static int nand_bb_calc_size(struct nand_bb *bb)
|
||||||
return 0;
|
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;
|
struct nand_bb *bb = cdev->priv;
|
||||||
unsigned long raw_pos = 0;
|
unsigned long raw_pos = 0;
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct ubi_volume_cdev_priv {
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
|
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_cdev_priv *priv = cdev->priv;
|
||||||
struct ubi_volume *vol = priv->vol;
|
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;
|
loff_t offp = offset;
|
||||||
int usable_leb_size = vol->usable_leb_size;
|
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;
|
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,
|
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_cdev_priv *priv = cdev->priv;
|
||||||
struct ubi_volume *vol = priv->vol;
|
struct ubi_volume *vol = priv->vol;
|
||||||
|
@ -121,7 +121,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
|
||||||
return 0;
|
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;
|
struct ubi_volume_cdev_priv *priv = cdev->priv;
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ int miidev_print_status(struct mii_device *mdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t miidev_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t miidev_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
int i = count;
|
int i = count;
|
||||||
uint16_t *buf = _buf;
|
uint16_t *buf = _buf;
|
||||||
|
@ -196,7 +196,7 @@ static ssize_t miidev_read(struct cdev *cdev, void *_buf, size_t count, ulong of
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t miidev_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
|
static ssize_t miidev_write(struct cdev *cdev, const void *_buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
int i = count;
|
int i = count;
|
||||||
const uint16_t *buf = _buf;
|
const uint16_t *buf = _buf;
|
||||||
|
|
|
@ -458,7 +458,7 @@ flash_sect_t find_sector (struct flash_info *info, ulong addr)
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __cfi_erase(struct cdev *cdev, size_t count, unsigned long offset,
|
static int __cfi_erase(struct cdev *cdev, size_t count, loff_t offset,
|
||||||
int verbose)
|
int verbose)
|
||||||
{
|
{
|
||||||
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
||||||
|
@ -493,7 +493,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cfi_erase(struct cdev *cdev, size_t count, unsigned long offset)
|
static int cfi_erase(struct cdev *cdev, size_t count, loff_t offset)
|
||||||
{
|
{
|
||||||
return __cfi_erase(cdev, count, offset, 1);
|
return __cfi_erase(cdev, count, offset, 1);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ static int flash_real_protect (struct flash_info *info, long sector, int prot)
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cfi_protect(struct cdev *cdev, size_t count, unsigned long offset, int prot)
|
static int cfi_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
|
||||||
{
|
{
|
||||||
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
||||||
unsigned long start, end;
|
unsigned long start, end;
|
||||||
|
@ -653,7 +653,7 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t cfi_write(struct cdev *cdev, const void *buf, size_t count, unsigned long offset, ulong flags)
|
static ssize_t cfi_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
struct flash_info *finfo = (struct flash_info *)cdev->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -194,13 +194,14 @@ static int erase_sector(struct m25p *flash, u32 offset)
|
||||||
* Erase an address range on the flash chip. The address range may extend
|
* Erase an address range on the flash chip. The address range may extend
|
||||||
* one or more erase sectors. Return an error is there is a problem erasing.
|
* one or more erase sectors. Return an error is there is a problem erasing.
|
||||||
*/
|
*/
|
||||||
static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offset)
|
static ssize_t m25p80_erase(struct cdev *cdev, size_t count, loff_t offset)
|
||||||
{
|
{
|
||||||
struct m25p *flash = cdev->priv;
|
struct m25p *flash = cdev->priv;
|
||||||
u32 addr, len;
|
u32 addr, len;
|
||||||
u32 start_sector;
|
u32 start_sector;
|
||||||
u32 end_sector;
|
u32 end_sector;
|
||||||
u32 progress = 0;
|
u32 progress = 0;
|
||||||
|
int eraseshift = ffs(flash->erasesize) - 1;
|
||||||
|
|
||||||
dev_dbg(&flash->spi->dev, "%s %s 0x%llx, len %lld\n",
|
dev_dbg(&flash->spi->dev, "%s %s 0x%llx, len %lld\n",
|
||||||
__func__, "at", (long long)offset, (long long)count);
|
__func__, "at", (long long)offset, (long long)count);
|
||||||
|
@ -212,8 +213,8 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offse
|
||||||
addr = offset;
|
addr = offset;
|
||||||
len = count;
|
len = count;
|
||||||
|
|
||||||
start_sector = offset / flash->erasesize;
|
start_sector = offset >> eraseshift;
|
||||||
end_sector = (offset + count - 1) / flash->erasesize;
|
end_sector = (offset + count - 1) >> eraseshift;
|
||||||
init_progression_bar(end_sector - start_sector + 1);
|
init_progression_bar(end_sector - start_sector + 1);
|
||||||
|
|
||||||
/* whole-chip erase? */
|
/* whole-chip erase? */
|
||||||
|
@ -250,7 +251,8 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offse
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
|
ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
|
||||||
|
ulong flags)
|
||||||
{
|
{
|
||||||
struct m25p *flash = cdev->priv;
|
struct m25p *flash = cdev->priv;
|
||||||
struct spi_transfer t[2];
|
struct spi_transfer t[2];
|
||||||
|
@ -302,7 +304,8 @@ ssize_t m25p80_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ul
|
||||||
return retlen;
|
return retlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t m25p80_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
|
ssize_t m25p80_write(struct cdev *cdev, const void *buf, size_t count,
|
||||||
|
loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
struct m25p *flash = cdev->priv;
|
struct m25p *flash = cdev->priv;
|
||||||
struct spi_transfer t[2];
|
struct spi_transfer t[2];
|
||||||
|
@ -381,7 +384,8 @@ ssize_t m25p80_write(struct cdev *cdev, const void *buf, size_t count, ulong off
|
||||||
return retlen;
|
return retlen;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_MTD_SST25L
|
#ifdef CONFIG_MTD_SST25L
|
||||||
ssize_t sst_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
|
ssize_t sst_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset,
|
||||||
|
ulong flags)
|
||||||
{
|
{
|
||||||
struct m25p *flash = cdev->priv;
|
struct m25p *flash = cdev->priv;
|
||||||
struct spi_transfer t[2];
|
struct spi_transfer t[2];
|
||||||
|
|
|
@ -358,7 +358,7 @@ static int cramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size)
|
||||||
return outsize;
|
return outsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t cramfs_lseek(struct device_d *dev, FILE *f, off_t pos)
|
static loff_t cramfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
|
||||||
{
|
{
|
||||||
f->pos = pos;
|
f->pos = pos;
|
||||||
return f->pos;
|
return f->pos;
|
||||||
|
|
|
@ -52,7 +52,7 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s
|
||||||
return cdev_write(cdev, buf, size, f->pos, f->flags);
|
return cdev_write(cdev, buf, size, f->pos, f->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t devfs_lseek(struct device_d *_dev, FILE *f, off_t pos)
|
static loff_t devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos)
|
||||||
{
|
{
|
||||||
struct cdev *cdev = f->inode;
|
struct cdev *cdev = f->inode;
|
||||||
off_t ret = -1;
|
off_t ret = -1;
|
||||||
|
@ -66,7 +66,7 @@ static off_t devfs_lseek(struct device_d *_dev, FILE *f, off_t pos)
|
||||||
return ret - cdev->offset;
|
return ret - cdev->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned long offset)
|
static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, loff_t offset)
|
||||||
{
|
{
|
||||||
struct cdev *cdev = f->inode;
|
struct cdev *cdev = f->inode;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned lo
|
||||||
return cdev->ops->erase(cdev, count, offset + cdev->offset);
|
return cdev->ops->erase(cdev, count, offset + cdev->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int devfs_protect(struct device_d *_dev, FILE *f, size_t count, unsigned long offset, int prot)
|
static int devfs_protect(struct device_d *_dev, FILE *f, size_t count, loff_t offset, int prot)
|
||||||
{
|
{
|
||||||
struct cdev *cdev = f->inode;
|
struct cdev *cdev = f->inode;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ DRESULT disk_read(FATFS *fat, BYTE *buf, DWORD sector, BYTE count)
|
||||||
|
|
||||||
debug("%s: sector: %ld count: %d\n", __func__, sector, count);
|
debug("%s: sector: %ld count: %d\n", __func__, sector, count);
|
||||||
|
|
||||||
ret = cdev_read(priv->cdev, buf, count << 9, sector * 512, 0);
|
ret = cdev_read(priv->cdev, buf, count << 9, (loff_t)sector * 512, 0);
|
||||||
if (ret != count << 9)
|
if (ret != count << 9)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ DRESULT disk_write(FATFS *fat, const BYTE *buf, DWORD sector, BYTE count)
|
||||||
debug("%s: buf: %p sector: %ld count: %d\n",
|
debug("%s: buf: %p sector: %ld count: %d\n",
|
||||||
__func__, buf, sector, count);
|
__func__, buf, sector, count);
|
||||||
|
|
||||||
ret = cdev_write(priv->cdev, buf, count << 9, sector * 512, 0);
|
ret = cdev_write(priv->cdev, buf, count << 9, (loff_t)sector * 512, 0);
|
||||||
if (ret != count << 9)
|
if (ret != count << 9)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ static int fat_read(struct device_d *_dev, FILE *f, void *buf, size_t insize)
|
||||||
return outsize;
|
return outsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t fat_lseek(struct device_d *dev, FILE *f, off_t pos)
|
static loff_t fat_lseek(struct device_d *dev, FILE *f, loff_t pos)
|
||||||
{
|
{
|
||||||
FIL *f_file = f->inode;
|
FIL *f_file = f->inode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
10
fs/fs.c
10
fs/fs.c
|
@ -692,7 +692,7 @@ int flush(int fd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t lseek(int fildes, off_t offset, int whence)
|
loff_t lseek(int fildes, loff_t offset, int whence)
|
||||||
{
|
{
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
struct fs_driver_d *fsdrv;
|
struct fs_driver_d *fsdrv;
|
||||||
|
@ -1243,7 +1243,7 @@ static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
|
ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
ulong size;
|
ulong size;
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
|
@ -1252,13 +1252,13 @@ ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong
|
||||||
return -1;
|
return -1;
|
||||||
dev = cdev->dev;
|
dev = cdev->dev;
|
||||||
|
|
||||||
size = min((ulong)count, dev->resource[0].size - offset);
|
size = min((loff_t)count, dev->resource[0].size - offset);
|
||||||
memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
|
memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mem_read);
|
EXPORT_SYMBOL(mem_read);
|
||||||
|
|
||||||
ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
|
ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
|
||||||
{
|
{
|
||||||
ulong size;
|
ulong size;
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
|
@ -1267,7 +1267,7 @@ ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset
|
||||||
return -1;
|
return -1;
|
||||||
dev = cdev->dev;
|
dev = cdev->dev;
|
||||||
|
|
||||||
size = min((ulong)count, dev->resource[0].size - offset);
|
size = min((loff_t)count, dev->resource[0].size - offset);
|
||||||
memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
|
memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
2
fs/nfs.c
2
fs/nfs.c
|
@ -805,7 +805,7 @@ static int nfs_read(struct device_d *dev, FILE *file, void *buf, size_t insize)
|
||||||
return outsize;
|
return outsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t nfs_lseek(struct device_d *dev, FILE *file, off_t pos)
|
static loff_t nfs_lseek(struct device_d *dev, FILE *file, loff_t pos)
|
||||||
{
|
{
|
||||||
struct file_priv *priv = file->inode;
|
struct file_priv *priv = file->inode;
|
||||||
|
|
||||||
|
|
|
@ -428,7 +428,7 @@ static int ramfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t i
|
||||||
return insize;
|
return insize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t ramfs_lseek(struct device_d *dev, FILE *f, off_t pos)
|
static loff_t ramfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
|
||||||
{
|
{
|
||||||
f->pos = pos;
|
f->pos = pos;
|
||||||
return f->pos;
|
return f->pos;
|
||||||
|
|
|
@ -569,7 +569,7 @@ static int tftp_read(struct device_d *dev, FILE *f, void *buf, size_t insize)
|
||||||
return outsize;
|
return outsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t tftp_lseek(struct device_d *dev, FILE *f, off_t pos)
|
static loff_t tftp_lseek(struct device_d *dev, FILE *f, loff_t pos)
|
||||||
{
|
{
|
||||||
/* not implemented in tftp protocol */
|
/* not implemented in tftp protocol */
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
|
@ -301,8 +301,8 @@ struct cdev;
|
||||||
int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot);
|
int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot);
|
||||||
|
|
||||||
/* These are used by drivers which work with direct memory accesses */
|
/* These are used by drivers which work with direct memory accesses */
|
||||||
ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags);
|
ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
|
||||||
ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags);
|
ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
|
||||||
int mem_memmap(struct cdev *cdev, void **map, int flags);
|
int mem_memmap(struct cdev *cdev, void **map, int flags);
|
||||||
|
|
||||||
/* Use this if you have nothing to do in your drivers probe function */
|
/* Use this if you have nothing to do in your drivers probe function */
|
||||||
|
@ -316,7 +316,7 @@ void devices_shutdown(void);
|
||||||
int generic_memmap_ro(struct cdev *dev, void **map, int flags);
|
int generic_memmap_ro(struct cdev *dev, void **map, int flags);
|
||||||
int generic_memmap_rw(struct cdev *dev, void **map, int flags);
|
int generic_memmap_rw(struct cdev *dev, void **map, int flags);
|
||||||
|
|
||||||
static inline off_t dev_lseek_default(struct cdev *cdev, off_t ofs)
|
static inline loff_t dev_lseek_default(struct cdev *cdev, loff_t ofs)
|
||||||
{
|
{
|
||||||
return ofs;
|
return ofs;
|
||||||
}
|
}
|
||||||
|
@ -373,18 +373,18 @@ extern struct bus_type platform_bus;
|
||||||
|
|
||||||
struct file_operations {
|
struct file_operations {
|
||||||
/*! Called in response of reading from this device. Required */
|
/*! Called in response of reading from this device. Required */
|
||||||
ssize_t (*read)(struct cdev*, void* buf, size_t count, ulong offset, ulong flags);
|
ssize_t (*read)(struct cdev*, void* buf, size_t count, loff_t offset, ulong flags);
|
||||||
|
|
||||||
/*! Called in response of write to this device. Required */
|
/*! Called in response of write to this device. Required */
|
||||||
ssize_t (*write)(struct cdev*, const void* buf, size_t count, ulong offset, ulong flags);
|
ssize_t (*write)(struct cdev*, const void* buf, size_t count, loff_t offset, ulong flags);
|
||||||
|
|
||||||
int (*ioctl)(struct cdev*, int, void *);
|
int (*ioctl)(struct cdev*, int, void *);
|
||||||
off_t (*lseek)(struct cdev*, off_t);
|
loff_t (*lseek)(struct cdev*, loff_t);
|
||||||
int (*open)(struct cdev*, unsigned long flags);
|
int (*open)(struct cdev*, unsigned long flags);
|
||||||
int (*close)(struct cdev*);
|
int (*close)(struct cdev*);
|
||||||
int (*flush)(struct cdev*);
|
int (*flush)(struct cdev*);
|
||||||
int (*erase)(struct cdev*, size_t count, unsigned long offset);
|
int (*erase)(struct cdev*, size_t count, loff_t offset);
|
||||||
int (*protect)(struct cdev*, size_t count, unsigned long offset, int prot);
|
int (*protect)(struct cdev*, size_t count, loff_t offset, int prot);
|
||||||
int (*memmap)(struct cdev*, void **map, int flags);
|
int (*memmap)(struct cdev*, void **map, int flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
12
include/fs.h
12
include/fs.h
|
@ -23,8 +23,8 @@ typedef struct dir {
|
||||||
|
|
||||||
typedef struct filep {
|
typedef struct filep {
|
||||||
struct device_d *dev; /* The device this FILE belongs to */
|
struct device_d *dev; /* The device this FILE belongs to */
|
||||||
ulong pos; /* current position in stream */
|
loff_t pos; /* current position in stream */
|
||||||
ulong size; /* The size of this inode */
|
loff_t size; /* The size of this inode */
|
||||||
ulong flags; /* the O_* flags from open */
|
ulong flags; /* the O_* flags from open */
|
||||||
|
|
||||||
void *inode; /* private to the filesystem driver */
|
void *inode; /* private to the filesystem driver */
|
||||||
|
@ -54,7 +54,7 @@ struct fs_driver_d {
|
||||||
int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size);
|
int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size);
|
||||||
int (*write)(struct device_d *dev, FILE *f, const void *buf, size_t size);
|
int (*write)(struct device_d *dev, FILE *f, const void *buf, size_t size);
|
||||||
int (*flush)(struct device_d *dev, FILE *f);
|
int (*flush)(struct device_d *dev, FILE *f);
|
||||||
off_t (*lseek)(struct device_d *dev, FILE *f, off_t pos);
|
loff_t (*lseek)(struct device_d *dev, FILE *f, loff_t pos);
|
||||||
|
|
||||||
struct dir* (*opendir)(struct device_d *dev, const char *pathname);
|
struct dir* (*opendir)(struct device_d *dev, const char *pathname);
|
||||||
struct dirent* (*readdir)(struct device_d *dev, struct dir *dir);
|
struct dirent* (*readdir)(struct device_d *dev, struct dir *dir);
|
||||||
|
@ -63,9 +63,9 @@ struct fs_driver_d {
|
||||||
|
|
||||||
int (*ioctl)(struct device_d *dev, FILE *f, int request, void *buf);
|
int (*ioctl)(struct device_d *dev, FILE *f, int request, void *buf);
|
||||||
int (*erase)(struct device_d *dev, FILE *f, size_t count,
|
int (*erase)(struct device_d *dev, FILE *f, size_t count,
|
||||||
unsigned long offset);
|
loff_t offset);
|
||||||
int (*protect)(struct device_d *dev, FILE *f, size_t count,
|
int (*protect)(struct device_d *dev, FILE *f, size_t count,
|
||||||
unsigned long offset, int prot);
|
loff_t offset, int prot);
|
||||||
|
|
||||||
int (*memmap)(struct device_d *dev, FILE *f, void **map, int flags);
|
int (*memmap)(struct device_d *dev, FILE *f, void **map, int flags);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ ssize_t write(int fd, const void *buf, size_t count);
|
||||||
#define SEEK_CUR 2
|
#define SEEK_CUR 2
|
||||||
#define SEEK_END 3
|
#define SEEK_END 3
|
||||||
|
|
||||||
off_t lseek(int fildes, off_t offset, int whence);
|
loff_t lseek(int fildes, loff_t offset, int whence);
|
||||||
int mkdir (const char *pathname, mode_t mode);
|
int mkdir (const char *pathname, mode_t mode);
|
||||||
|
|
||||||
/* Create a directory and its parents */
|
/* Create a directory and its parents */
|
||||||
|
|
Loading…
Reference in New Issue