Commit b706f5fa authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: removal of iovec use in mtd

mtd, jffs and jffs2 switched from iovec to kvec
parent 0fc78de9
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
static int cfi_staa_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); static int cfi_staa_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_staa_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); static int cfi_staa_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
static int cfi_staa_writev(struct mtd_info *mtd, const struct iovec *vecs, static int cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen); unsigned long count, loff_t to, size_t *retlen);
static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *); static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *);
static void cfi_staa_sync (struct mtd_info *); static void cfi_staa_sync (struct mtd_info *);
...@@ -700,7 +700,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to, ...@@ -700,7 +700,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
#define ECCBUF_DIV(x) ((x) & ~(ECCBUF_SIZE - 1)) #define ECCBUF_DIV(x) ((x) & ~(ECCBUF_SIZE - 1))
#define ECCBUF_MOD(x) ((x) & (ECCBUF_SIZE - 1)) #define ECCBUF_MOD(x) ((x) & (ECCBUF_SIZE - 1))
static int static int
cfi_staa_writev(struct mtd_info *mtd, const struct iovec *vecs, cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
unsigned long i; unsigned long i;
......
...@@ -232,7 +232,7 @@ void put_mtd_device(struct mtd_info *mtd) ...@@ -232,7 +232,7 @@ void put_mtd_device(struct mtd_info *mtd)
* dont implement their own * dont implement their own
*/ */
int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs, int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
unsigned long i; unsigned long i;
...@@ -262,7 +262,7 @@ int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs, ...@@ -262,7 +262,7 @@ int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs,
* implement their own * implement their own
*/ */
int default_mtd_readv(struct mtd_info *mtd, struct iovec *vecs, int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
unsigned long count, loff_t from, size_t *retlen) unsigned long count, loff_t from, size_t *retlen)
{ {
unsigned long i; unsigned long i;
......
...@@ -182,7 +182,7 @@ static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t l ...@@ -182,7 +182,7 @@ static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t l
len, retlen, buf); len, retlen, buf);
} }
static int part_writev (struct mtd_info *mtd, const struct iovec *vecs, static int part_writev (struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
struct mtd_part *part = PART(mtd); struct mtd_part *part = PART(mtd);
...@@ -197,7 +197,7 @@ static int part_writev (struct mtd_info *mtd, const struct iovec *vecs, ...@@ -197,7 +197,7 @@ static int part_writev (struct mtd_info *mtd, const struct iovec *vecs,
NULL, &mtd->oobinfo); NULL, &mtd->oobinfo);
} }
static int part_readv (struct mtd_info *mtd, struct iovec *vecs, static int part_readv (struct mtd_info *mtd, struct kvec *vecs,
unsigned long count, loff_t from, size_t *retlen) unsigned long count, loff_t from, size_t *retlen)
{ {
struct mtd_part *part = PART(mtd); struct mtd_part *part = PART(mtd);
...@@ -210,7 +210,7 @@ static int part_readv (struct mtd_info *mtd, struct iovec *vecs, ...@@ -210,7 +210,7 @@ static int part_readv (struct mtd_info *mtd, struct iovec *vecs,
NULL, &mtd->oobinfo); NULL, &mtd->oobinfo);
} }
static int part_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, static int part_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen, unsigned long count, loff_t to, size_t *retlen,
u_char *eccbuf, struct nand_oobinfo *oobsel) u_char *eccbuf, struct nand_oobinfo *oobsel)
{ {
...@@ -224,7 +224,7 @@ static int part_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, ...@@ -224,7 +224,7 @@ static int part_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs,
eccbuf, oobsel); eccbuf, oobsel);
} }
static int part_readv_ecc (struct mtd_info *mtd, struct iovec *vecs, static int part_readv_ecc (struct mtd_info *mtd, struct kvec *vecs,
unsigned long count, loff_t from, size_t *retlen, unsigned long count, loff_t from, size_t *retlen,
u_char *eccbuf, struct nand_oobinfo *oobsel) u_char *eccbuf, struct nand_oobinfo *oobsel)
{ {
......
...@@ -168,9 +168,9 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret ...@@ -168,9 +168,9 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret
static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel); size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf); static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf);
static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs, static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t * retlen); unsigned long count, loff_t to, size_t * retlen);
static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
static int nand_erase (struct mtd_info *mtd, struct erase_info *instr); static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
static void nand_sync (struct mtd_info *mtd); static void nand_sync (struct mtd_info *mtd);
...@@ -961,15 +961,15 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * ...@@ -961,15 +961,15 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
/* /*
* NAND write with iovec * NAND write with kvec
*/ */
static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count,
loff_t to, size_t * retlen) loff_t to, size_t * retlen)
{ {
return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, 0)); return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, 0));
} }
static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count,
loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
{ {
int i, page, len, total_len, ret = 0, written = 0; int i, page, len, total_len, ret = 0, written = 0;
...@@ -1016,7 +1016,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsi ...@@ -1016,7 +1016,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsi
goto out; goto out;
} }
/* Loop until all iovecs' data has been written */ /* Loop until all kvec' data has been written */
len = 0; len = 0;
while (count) { while (count) {
/* /*
...@@ -1025,7 +1025,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsi ...@@ -1025,7 +1025,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsi
* else we have to copy into data_buf. * else we have to copy into data_buf.
*/ */
if ((vecs->iov_len - len) >= mtd->oobblock) { if ((vecs->iov_len - len) >= mtd->oobblock) {
this->data_poi = (u_char *) vecs->iov_base; this->data_poi = vecs->iov_base;
this->data_poi += len; this->data_poi += len;
len += mtd->oobblock; len += mtd->oobblock;
/* Check, if we have to switch to the next tuple */ /* Check, if we have to switch to the next tuple */
......
...@@ -209,7 +209,7 @@ flash_safe_write(struct mtd_info *mtd, loff_t to, ...@@ -209,7 +209,7 @@ flash_safe_write(struct mtd_info *mtd, loff_t to,
static int static int
flash_safe_writev(struct mtd_info *mtd, const struct iovec *vecs, flash_safe_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long iovec_cnt, loff_t to) unsigned long iovec_cnt, loff_t to)
{ {
size_t retlen, retlen_a; size_t retlen, retlen_a;
...@@ -1740,7 +1740,7 @@ jffs_write_node(struct jffs_control *c, struct jffs_node *node, ...@@ -1740,7 +1740,7 @@ jffs_write_node(struct jffs_control *c, struct jffs_node *node,
{ {
struct jffs_fmcontrol *fmc = c->fmc; struct jffs_fmcontrol *fmc = c->fmc;
struct jffs_fm *fm; struct jffs_fm *fm;
struct iovec node_iovec[4]; struct kvec node_iovec[4];
unsigned long iovec_cnt; unsigned long iovec_cnt;
__u32 pos; __u32 pos;
......
...@@ -132,8 +132,9 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) ...@@ -132,8 +132,9 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
#define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) #define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len)
struct kstatfs; struct kstatfs;
struct kvec;
/* wbuf.c */ /* wbuf.c */
int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino); int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino);
int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf); int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf);
int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, u_char *buf); int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, u_char *buf);
int jffs2_check_oob_empty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,int mode); int jffs2_check_oob_empty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,int mode);
...@@ -185,7 +186,7 @@ int jffs2_remount_fs (struct super_block *, int *, char *); ...@@ -185,7 +186,7 @@ int jffs2_remount_fs (struct super_block *, int *, char *);
int jffs2_do_fill_super(struct super_block *sb, void *data, int silent); int jffs2_do_fill_super(struct super_block *sb, void *data, int silent);
/* writev.c */ /* writev.c */
int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs, int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen); unsigned long count, loff_t to, size_t *retlen);
/* super.c */ /* super.c */
......
...@@ -544,9 +544,9 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c) ...@@ -544,9 +544,9 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c)
#define PAGE_DIV(x) ( (x) & (~(c->wbuf_pagesize - 1)) ) #define PAGE_DIV(x) ( (x) & (~(c->wbuf_pagesize - 1)) )
#define PAGE_MOD(x) ( (x) & (c->wbuf_pagesize - 1) ) #define PAGE_MOD(x) ( (x) & (c->wbuf_pagesize - 1) )
int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino) int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino)
{ {
struct iovec outvecs[3]; struct kvec outvecs[3];
uint32_t totlen = 0; uint32_t totlen = 0;
uint32_t split_ofs = 0; uint32_t split_ofs = 0;
uint32_t old_totlen; uint32_t old_totlen;
...@@ -751,11 +751,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsi ...@@ -751,11 +751,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsi
/* /*
* This is the entry for flash write. * This is the entry for flash write.
* Check, if we work on NAND FLASH, if so build an iovec and write it via vritev * Check, if we work on NAND FLASH, if so build an kvec and write it via vritev
*/ */
int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf) int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf)
{ {
struct iovec vecs[1]; struct kvec vecs[1];
if (jffs2_can_mark_obsolete(c)) if (jffs2_can_mark_obsolete(c))
return c->mtd->write(c->mtd, ofs, len, retlen, buf); return c->mtd->write(c->mtd, ofs, len, retlen, buf);
......
...@@ -92,7 +92,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -92,7 +92,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
struct jffs2_raw_node_ref *raw; struct jffs2_raw_node_ref *raw;
struct jffs2_full_dnode *fn; struct jffs2_full_dnode *fn;
size_t retlen; size_t retlen;
struct iovec vecs[2]; struct kvec vecs[2];
int ret; int ret;
int retried = 0; int retried = 0;
unsigned long cnt = 2; unsigned long cnt = 2;
...@@ -233,7 +233,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -233,7 +233,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
struct jffs2_raw_node_ref *raw; struct jffs2_raw_node_ref *raw;
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
size_t retlen; size_t retlen;
struct iovec vecs[2]; struct kvec vecs[2];
int retried = 0; int retried = 0;
int ret; int ret;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* This ought to be in core MTD code. All registered MTD devices /* This ought to be in core MTD code. All registered MTD devices
without writev should have this put in place. Bug the MTD without writev should have this put in place. Bug the MTD
maintainer */ maintainer */
static inline int mtd_fake_writev(struct mtd_info *mtd, const struct iovec *vecs, static inline int mtd_fake_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
unsigned long i; unsigned long i;
...@@ -39,7 +39,7 @@ static inline int mtd_fake_writev(struct mtd_info *mtd, const struct iovec *vecs ...@@ -39,7 +39,7 @@ static inline int mtd_fake_writev(struct mtd_info *mtd, const struct iovec *vecs
return ret; return ret;
} }
int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs, int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen) unsigned long count, loff_t to, size_t *retlen)
{ {
if (c->mtd->writev) if (c->mtd->writev)
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/uio.h> #include <linux/uio.h>
struct kvec {
void *iov_base; /* and that should *never* hold a userland pointer */
size_t iov_len;
};
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
struct erase_info_user { struct erase_info_user {
...@@ -200,16 +205,16 @@ struct mtd_info { ...@@ -200,16 +205,16 @@ struct mtd_info {
/* This function is not yet implemented */ /* This function is not yet implemented */
int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
/* iovec-based read/write methods. We need these especially for NAND flash, /* kvec-based read/write methods. We need these especially for NAND flash,
with its limited number of write cycles per erase. with its limited number of write cycles per erase.
NB: The 'count' parameter is the number of _vectors_, each of NB: The 'count' parameter is the number of _vectors_, each of
which contains an (ofs, len) tuple. which contains an (ofs, len) tuple.
*/ */
int (*readv) (struct mtd_info *mtd, struct iovec *vecs, unsigned long count, loff_t from, size_t *retlen); int (*readv) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from, size_t *retlen);
int (*readv_ecc) (struct mtd_info *mtd, struct iovec *vecs, unsigned long count, loff_t from, int (*readv_ecc) (struct mtd_info *mtd, struct kvec *vecs, unsigned long count, loff_t from,
size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
int (*writev) (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen); int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
int (*writev_ecc) (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, loff_t to, int (*writev_ecc) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to,
size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
/* Sync */ /* Sync */
...@@ -250,10 +255,10 @@ struct mtd_notifier { ...@@ -250,10 +255,10 @@ struct mtd_notifier {
extern void register_mtd_user (struct mtd_notifier *new); extern void register_mtd_user (struct mtd_notifier *new);
extern int unregister_mtd_user (struct mtd_notifier *old); extern int unregister_mtd_user (struct mtd_notifier *old);
int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs, int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen); unsigned long count, loff_t to, size_t *retlen);
int default_mtd_readv(struct mtd_info *mtd, struct iovec *vecs, int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
unsigned long count, loff_t from, size_t *retlen); unsigned long count, loff_t from, size_t *retlen);
#define MTD_ERASE(mtd, args...) (*(mtd->erase))(mtd, args) #define MTD_ERASE(mtd, args...) (*(mtd->erase))(mtd, args)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment