From: Artem Bityutskiy Date: Fri, 30 Dec 2011 13:57:25 +0000 (+0200) Subject: mtd: clean-up the default_mtd_writev function X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=52b020317f65114eeba2ee2cfa70a51a286f1d8a;p=linux-beck.git mtd: clean-up the default_mtd_writev function 1. Teach 'mtd_write()' function to return '-EROFS' if the write method is undefined, and remove the corresponding check from 'default_mtd_writev()'. 2. Do not test 'retlen' for NULL - it cannot be NULL. 3. Few minor coding stile clean-ups. 4. Add a kerneldoc comment Additionally, minor fixes to the kerneldoc comments of the neighbor function. Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 8bea2d0fdb20..85a3f197e7f0 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -683,10 +683,17 @@ 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) { @@ -694,28 +701,24 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, size_t totlen = 0, thislen; int ret = 0; - if(!mtd->write) { - ret = -EROFS; - } else { - for (i=0; iwrite) + return -EROFS; return mtd->write(mtd, to, len, retlen, buf); }