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 @@
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_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);
static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_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,
#define ECCBUF_DIV(x) ((x) & ~(ECCBUF_SIZE - 1))
#define ECCBUF_MOD(x) ((x) & (ECCBUF_SIZE - 1))
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 i;
......
......@@ -232,7 +232,7 @@ void put_mtd_device(struct mtd_info *mtd)
* 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 i;
......@@ -262,7 +262,7 @@ int default_mtd_writev(struct mtd_info *mtd, const struct iovec *vecs,
* 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 i;
......
......@@ -182,7 +182,7 @@ static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t l
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)
{
struct mtd_part *part = PART(mtd);
......@@ -197,7 +197,7 @@ static int part_writev (struct mtd_info *mtd, const struct iovec *vecs,
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)
{
struct mtd_part *part = PART(mtd);
......@@ -210,7 +210,7 @@ static int part_readv (struct mtd_info *mtd, struct iovec *vecs,
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,
u_char *eccbuf, struct nand_oobinfo *oobsel)
{
......@@ -224,7 +224,7 @@ static int part_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs,
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,
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
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);
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);
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);
static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
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 *
/*
* 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)
{
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)
{
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
goto out;
}
/* Loop until all iovecs' data has been written */
/* Loop until all kvec' data has been written */
len = 0;
while (count) {
/*
......@@ -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.
*/
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;
len += mtd->oobblock;
/* Check, if we have to switch to the next tuple */
......
......@@ -209,7 +209,7 @@ flash_safe_write(struct mtd_info *mtd, loff_t to,
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)
{
size_t retlen, retlen_a;
......@@ -1740,7 +1740,7 @@ jffs_write_node(struct jffs_control *c, struct jffs_node *node,
{
struct jffs_fmcontrol *fmc = c->fmc;
struct jffs_fm *fm;
struct iovec node_iovec[4];
struct kvec node_iovec[4];
unsigned long iovec_cnt;
__u32 pos;
......
......@@ -132,8 +132,9 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
#define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len)
struct kstatfs;
struct kvec;
/* 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_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);
......@@ -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);
/* 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);
/* super.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_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 split_ofs = 0;
uint32_t old_totlen;
......@@ -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.
* 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)
{
struct iovec vecs[1];
struct kvec vecs[1];
if (jffs2_can_mark_obsolete(c))
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
struct jffs2_raw_node_ref *raw;
struct jffs2_full_dnode *fn;
size_t retlen;
struct iovec vecs[2];
struct kvec vecs[2];
int ret;
int retried = 0;
unsigned long cnt = 2;
......@@ -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_full_dirent *fd;
size_t retlen;
struct iovec vecs[2];
struct kvec vecs[2];
int retried = 0;
int ret;
......
......@@ -18,7 +18,7 @@
/* This ought to be in core MTD code. All registered MTD devices
without writev should have this put in place. Bug the MTD
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 i;
......@@ -39,7 +39,7 @@ static inline int mtd_fake_writev(struct mtd_info *mtd, const struct iovec *vecs
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)
{
if (c->mtd->writev)
......
......@@ -12,6 +12,11 @@
#include <linux/module.h>
#include <linux/uio.h>
struct kvec {
void *iov_base; /* and that should *never* hold a userland pointer */
size_t iov_len;
};
#endif /* __KERNEL__ */
struct erase_info_user {
......@@ -200,16 +205,16 @@ struct mtd_info {
/* 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);
/* 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.
NB: The 'count' parameter is the number of _vectors_, each of
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_ecc) (struct mtd_info *mtd, struct iovec *vecs, unsigned long count, loff_t from,
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 kvec *vecs, unsigned long count, loff_t from,
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_ecc) (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, loff_t to,
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 kvec *vecs, unsigned long count, loff_t to,
size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
/* Sync */
......@@ -250,10 +255,10 @@ struct mtd_notifier {
extern void register_mtd_user (struct mtd_notifier *new);
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);
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);
#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