Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 282900
b: refs/heads/master
c: 52b0203
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and David Woodhouse committed Jan 9, 2012
1 parent 480b4d1 commit 1a9418e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4ccf2f1349e681401b5fae73efc87b8d2d70ce0e
refs/heads/master: 52b020317f65114eeba2ee2cfa70a51a286f1d8a
41 changes: 22 additions & 19 deletions trunk/drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,39 +683,42 @@ void __put_mtd_device(struct mtd_info *mtd)
module_put(mtd->owner);
}

/* default_mtd_writev - default mtd writev method for MTD devices that
* don't implement their own
/*
* default_mtd_writev - the default writev method
* @mtd: mtd device description object pointer
* @vecs: the vectors to write
* @count: count of vectors in @vecs
* @to: the MTD device offset to write to
* @retlen: on exit contains the count of bytes written to the MTD device.
*
* This function returns zero in case of success and a negative error code in
* case of failure.
*/

int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen)
{
unsigned long i;
size_t totlen = 0, thislen;
int ret = 0;

if(!mtd->write) {
ret = -EROFS;
} else {
for (i=0; i<count; i++) {
if (!vecs[i].iov_len)
continue;
ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen,
vecs[i].iov_base);
totlen += thislen;
if (ret || thislen != vecs[i].iov_len)
break;
to += vecs[i].iov_len;
}
for (i = 0; i < count; i++) {
if (!vecs[i].iov_len)
continue;
ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen,
vecs[i].iov_base);
totlen += thislen;
if (ret || thislen != vecs[i].iov_len)
break;
to += vecs[i].iov_len;
}
if (retlen)
*retlen = totlen;
*retlen = totlen;
return ret;
}

/**
* mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size
* @size: A pointer to the ideal or maximum size of the allocation. Points
* @mtd: mtd device description object pointer
* @size: a pointer to the ideal or maximum size of the allocation, points
* to the actual allocation size on success.
*
* This routine attempts to allocate a contiguous kernel buffer up to
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ static inline int mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
*retlen = 0;
if (!mtd->write)
return -EROFS;
return mtd->write(mtd, to, len, retlen, buf);
}

Expand Down

0 comments on commit 1a9418e

Please sign in to comment.