mtd: remove unused default_mtd_readv prototype
PATCH 1/4 mtd: remove unused default_mtd_readv prototype
From: Artem Bityutskiy <[email protected]>
--- include/linux/mtd/mtd.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
include/linux/mtd/mtd.h +0 -3
@@ -512,9 +512,6 @@ extern int unregister_mtd_user (struct mtd_notifier *old);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 kvec *vecs, -unsigned long count,loff_t from,size_t *retlen); -void *mtd_kmalloc_up_to (const struct mtd_info *mtd,size_t *size);void mtd_erase_callback (struct erase_info *instr);
Signature · 1 line
1.7.7.3
PATCH 2/4 jffs: remove custom mtd_fake_writev function
From: Artem Bityutskiy <[email protected]>
Instead, use 'default_mtd_writev()' function which MTD provides.
--- fs/jffs2/writev.c | 27 +-------------------------- 1 files changed, 1 insertions(+), 26 deletions(-)
fs/jffs2/writev.c +1 -26
@@ -13,31 +13,6 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -/* 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 kvec *vecs, -unsigned long count,loff_t to,size_t *retlen) -{ -unsigned long i; -size_t totlen =0 , thislen; -int ret =0 ; - -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; -return ret; -} -int jffs2_flash_direct_writev (struct jffs2_sb_info *c,const struct kvec *vecs,unsigned long count,loff_t to,size_t *retlen) {
@@ -54,7 +29,7 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,if (c->mtd->writev)return mtd_writev (c->mtd, vecs, count, to, retlen);else { -return mtd_fake_writev (c->mtd, vecs, count, to, retlen); +return default_mtd_writev (c->mtd, vecs, count, to, retlen); } }
Signature · 1 line
1.7.7.3
PATCH 3/4 mtd: clean-up the default_mtd_writev function
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
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.
--- drivers/mtd/mtdcore.c | 41 ++++++++++++++++++++++------------------- include/linux/mtd/mtd.h | 2 ++ 2 files changed, 24 insertions(+), 19 deletions(-)
drivers/mtd/mtdcore.c +22 -19
@@ -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 ; 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
include/linux/mtd/mtd.h +2 -0
@@ -295,6 +295,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); }
Signature · 1 line
1.7.7.3
PATCH 4/4 mtd: mtdcore: export symbols cleanup
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
The mtdcore.c file is a bit inconsistent - some EXPORT_SYMBOL_GPL declarations follow the corresponding functions, some are placed at the end. This patch harmonizes the file so that EXPORT_SYMBOL_GPL declarations follow the corresponding function.
It also removes few extra newlines and trailing white-spaces.
--- drivers/mtd/mtdcore.c | 24 +++++++++--------------- 1 files changed, 9 insertions(+), 15 deletions(-)
drivers/mtd/mtdcore.c +9 -15
@@ -128,7 +128,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)static int mtd_cls_resume (struct device *dev) {struct mtd_info *mtd =dev_get_drvdata (dev); - +if (mtd && mtd->resume)mtd_resume (mtd);return 0 ;
@@ -517,7 +517,6 @@ EXPORT_SYMBOL_GPL(mtd_device_unregister);* or removal of MTD devices. Causes the 'add' callback to be immediately * invoked for each MTD device currently present in the system. */ -void register_mtd_user (struct mtd_notifier *new) {struct mtd_info *mtd;
@@ -533,6 +532,7 @@ void register_mtd_user (struct mtd_notifier *new)mutex_unlock (&mtd_table_mutex); } +EXPORT_SYMBOL_GPL (register_mtd_user);/** * unregister_mtd_user - unregister a 'user' of MTD devices.
@@ -543,7 +543,6 @@ void register_mtd_user (struct mtd_notifier *new)* 'remove' callback to be immediately invoked for each MTD device * currently present in the system. */ -int unregister_mtd_user (struct mtd_notifier *old) {struct mtd_info *mtd;
@@ -559,7 +558,7 @@ int unregister_mtd_user (struct mtd_notifier *old)mutex_unlock (&mtd_table_mutex);return 0 ; } - +EXPORT_SYMBOL_GPL (unregister_mtd_user);/** * get_mtd_device - obtain a validated handle for an MTD device
@@ -572,7 +571,6 @@ int unregister_mtd_user (struct mtd_notifier *old)* both, return the num'th driver only if its address matches. Return * error code if not. */ -struct mtd_info *get_mtd_device (struct mtd_info *mtd,int num) {struct mtd_info *ret =NULL , *other;
@@ -605,6 +603,7 @@ out:mutex_unlock (&mtd_table_mutex);return ret; } +EXPORT_SYMBOL_GPL (get_mtd_device);int __get_mtd_device (struct mtd_info *mtd)
@@ -625,6 +624,7 @@ int __get_mtd_device(struct mtd_info *mtd) mtd->usecount++;return 0 ; } +EXPORT_SYMBOL_GPL (__get_mtd_device);/** * get_mtd_device_nm - obtain a validated handle for an MTD device by
@@ -634,7 +634,6 @@ int __get_mtd_device(struct mtd_info *mtd)* This function returns MTD device description structure in case of * success and an error code in case of failure. */ -struct mtd_info *get_mtd_device_nm (const char *name) {int err = -ENODEV ;
@@ -663,6 +662,7 @@ out_unlock:mutex_unlock (&mtd_table_mutex);return ERR_PTR (err); } +EXPORT_SYMBOL_GPL (get_mtd_device_nm);void put_mtd_device (struct mtd_info *mtd) {
@@ -671,6 +671,7 @@ void put_mtd_device(struct mtd_info *mtd)mutex_unlock (&mtd_table_mutex); } +EXPORT_SYMBOL_GPL (put_mtd_device);void __put_mtd_device (struct mtd_info *mtd) {
@@ -682,6 +683,7 @@ void __put_mtd_device(struct mtd_info *mtd)module_put (mtd->owner); } +EXPORT_SYMBOL_GPL (__put_mtd_device);/* * default_mtd_writev - the default writev method
@@ -714,6 +716,7 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, *retlen = totlen;return ret; } +EXPORT_SYMBOL_GPL (default_mtd_writev);/** * mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size
@@ -763,15 +766,6 @@ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)*/ return kmalloc (*size,GFP_KERNEL ); } - -EXPORT_SYMBOL_GPL (get_mtd_device); -EXPORT_SYMBOL_GPL (get_mtd_device_nm); -EXPORT_SYMBOL_GPL (__get_mtd_device); -EXPORT_SYMBOL_GPL (put_mtd_device); -EXPORT_SYMBOL_GPL (__put_mtd_device); -EXPORT_SYMBOL_GPL (register_mtd_user); -EXPORT_SYMBOL_GPL (unregister_mtd_user); -EXPORT_SYMBOL_GPL (default_mtd_writev);EXPORT_SYMBOL_GPL (mtd_kmalloc_up_to);#ifdef CONFIG_PROC_FS
Signature · 1 line
1.7.7.3