Skip to content

Commit b0a31f7

Browse files
dedekindDavid Woodhouse
authored andcommitted
mtd: introduce mtd_writev interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 4403dbf commit b0a31f7

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎drivers/mtd/mtdconcat.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,
227227
if (!(subdev->flags & MTD_WRITEABLE))
228228
err = -EROFS;
229229
else
230-
err = subdev->writev(subdev, &vecs_copy[entry_low],
231-
entry_high - entry_low + 1, to, &retsize);
230+
err = mtd_writev(subdev, &vecs_copy[entry_low],
231+
entry_high - entry_low + 1, to,
232+
&retsize);
232233

233234
vecs_copy[entry_high].iov_len = old_iov_len - size;
234235
vecs_copy[entry_high].iov_base += size;

‎drivers/mtd/mtdpart.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ static int part_writev(struct mtd_info *mtd, const struct kvec *vecs,
238238
struct mtd_part *part = PART(mtd);
239239
if (!(mtd->flags & MTD_WRITEABLE))
240240
return -EROFS;
241-
return part->master->writev(part->master, vecs, count,
242-
to + part->offset, retlen);
241+
return mtd_writev(part->master, vecs, count, to + part->offset,
242+
retlen);
243243
}
244244

245245
static int part_erase(struct mtd_info *mtd, struct erase_info *instr)

‎fs/jffs2/writev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
5252
}
5353

5454
if (c->mtd->writev)
55-
return c->mtd->writev(c->mtd, vecs, count, to, retlen);
55+
return mtd_writev(c->mtd, vecs, count, to, retlen);
5656
else {
5757
return mtd_fake_writev(c->mtd, vecs, count, to, retlen);
5858
}

‎include/linux/mtd/mtd.h‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,14 @@ struct mtd_info {
204204
size_t *retlen, u_char *buf);
205205
int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from,
206206
size_t len);
207+
int (*writev) (struct mtd_info *mtd, const struct kvec *vecs,
208+
unsigned long count, loff_t to, size_t *retlen);
207209

208210
/* Backing device capabilities for this device
209211
* - provides mmap capabilities
210212
*/
211213
struct backing_dev_info *backing_dev_info;
212214

213-
/* kvec-based read/write methods.
214-
NB: The 'count' parameter is the number of _vectors_, each of
215-
which contains an (ofs, len) tuple.
216-
*/
217-
int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
218-
219215
/* Sync */
220216
void (*sync) (struct mtd_info *mtd);
221217

@@ -375,6 +371,16 @@ static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
375371
return mtd->lock_user_prot_reg(mtd, from, len);
376372
}
377373

374+
/*
375+
* kvec-based read/write method. NB: The 'count' parameter is the number of
376+
* _vectors_, each of which contains an (ofs, len) tuple.
377+
*/
378+
static inline int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
379+
unsigned long count, loff_t to, size_t *retlen)
380+
{
381+
return mtd->writev(mtd, vecs, count, to, retlen);
382+
}
383+
378384
static inline struct mtd_info *dev_to_mtd(struct device *dev)
379385
{
380386
return dev ? dev_get_drvdata(dev) : NULL;

0 commit comments

Comments
 (0)