diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-30 09:23:41 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:19 -0500 |
commit | 1dbebd32562b3c2caeca35960e5cb00bfcc12900 (patch) | |
tree | 773776d87730828adb55f3f7fe8221eabb528d8f /drivers/mtd/mtdcore.c | |
parent | e2936b2af5562c8c66060e2bc2ae2e209d0acd3d (diff) |
mtd: harmonize mtd_writev usage
This patch makes the 'mtd_writev()' function more usable and logical. We first
teach it to fall-back to the 'default_mtd_writev()' function if the MTD driver
does not define its own '->writev()' method. Then we make block2mtd and JFFS2
just 'mtd_writev()' instead of 'default_mtd_writev()' function. This means we
can now stop exporting 'default_mtd_writev()' and instead, export
'mtd_writev()'. This is much cleaner and more logical, as well as allows us to
get read of another direct 'mtd->writev' access in JFFS2.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r-- | drivers/mtd/mtdcore.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 53a200f722b6..4d0f3e557bd1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -696,8 +696,8 @@ EXPORT_SYMBOL_GPL(__put_mtd_device); | |||
696 | * This function returns zero in case of success and a negative error code in | 696 | * This function returns zero in case of success and a negative error code in |
697 | * case of failure. | 697 | * case of failure. |
698 | */ | 698 | */ |
699 | int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, | 699 | static int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, |
700 | unsigned long count, loff_t to, size_t *retlen) | 700 | unsigned long count, loff_t to, size_t *retlen) |
701 | { | 701 | { |
702 | unsigned long i; | 702 | unsigned long i; |
703 | size_t totlen = 0, thislen; | 703 | size_t totlen = 0, thislen; |
@@ -716,7 +716,27 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
716 | *retlen = totlen; | 716 | *retlen = totlen; |
717 | return ret; | 717 | return ret; |
718 | } | 718 | } |
719 | EXPORT_SYMBOL_GPL(default_mtd_writev); | 719 | |
720 | /* | ||
721 | * mtd_writev - the vector-based MTD write method | ||
722 | * @mtd: mtd device description object pointer | ||
723 | * @vecs: the vectors to write | ||
724 | * @count: count of vectors in @vecs | ||
725 | * @to: the MTD device offset to write to | ||
726 | * @retlen: on exit contains the count of bytes written to the MTD device. | ||
727 | * | ||
728 | * This function returns zero in case of success and a negative error code in | ||
729 | * case of failure. | ||
730 | */ | ||
731 | int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, | ||
732 | unsigned long count, loff_t to, size_t *retlen) | ||
733 | { | ||
734 | *retlen = 0; | ||
735 | if (!mtd->writev) | ||
736 | return default_mtd_writev(mtd, vecs, count, to, retlen); | ||
737 | return mtd->writev(mtd, vecs, count, to, retlen); | ||
738 | } | ||
739 | EXPORT_SYMBOL_GPL(mtd_writev); | ||
720 | 740 | ||
721 | /** | 741 | /** |
722 | * mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size | 742 | * mtd_kmalloc_up_to - allocate a contiguous buffer up to the specified size |