mtd: MTD API rework
Subsystems (5)
cover mtd: MTD API rework
From: Artem Bityutskiy <[email protected]>
Hi,
here are the latest MTD API rework patches. I have plans to also harmonize the OOB-related functions, try to harmonize alignment checking in erase and write functions as well. Not sure I'll have time for this, though, will see.
Please, do test the changes if you use MTD - it is easy to break something when you are trying to clean-up ancient crap.
Artem.
PATCH 1/9 mtd: return error code from mtd_unpoint
From: Artem Bityutskiy <[email protected]>
The 'mtd_unpoint()' API function should be able to return an error code because it may fail if you specify incorrect offset. This patch changes this MTD API function and amends all the drivers correspondingly.
Also return '-EOPNOTSUPP' from 'mtd_unpoint()' when the '->unpoint()' method is undefined. We do not really need this currently, but this just makes sense to be consistent with 'mtd_point()'.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 16 ++++++++++------ drivers/mtd/devices/mtdram.c | 3 ++- drivers/mtd/devices/phram.c | 3 ++- drivers/mtd/devices/pmc551.c | 3 ++- drivers/mtd/devices/slram.c | 5 +++-- drivers/mtd/lpddr/lpddr_cmds.c | 12 ++++++++---- drivers/mtd/mtdpart.c | 4 ++-- include/linux/mtd/mtd.h | 6 ++++-- include/linux/mtd/pmc551.h | 1 - 9 files changed, 33 insertions(+), 20 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +10 -6
@@ -87,7 +87,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **static int cfi_intelext_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys); -static void cfi_intelext_unpoint (struct mtd_info *mtd,loff_t from,size_t len); +static int cfi_intelext_unpoint (struct mtd_info *mtd,loff_t from,size_t len);static int chip_ready (struct map_info *map,struct flchip *chip,unsigned long adr,int mode);static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode);
@@ -1369,12 +1369,12 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,return 0 ; } -static void cfi_intelext_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int cfi_intelext_unpoint (struct mtd_info *mtd,loff_t from,size_t len) {struct map_info *map = mtd->priv;struct cfi_private *cfi = map->fldrv_priv;unsigned long ofs; -int chipnum; +int chipnum, err =0 ;/* Now unlock the chip(s) POINT state */
@@ -1382,7 +1382,7 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) chipnum = (from >> cfi->chipshift); ofs = from - (chipnum << cfi->chipshift); -while (len) { +while (len && !err) {unsigned long thislen;struct flchip *chip;
@@ -1400,8 +1400,10 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) chip->ref_point_counter--;if (chip->ref_point_counter ==0 ) chip->state =FL_READY ; - }else -printk (KERN_ERR "%s: Warning: unpoint called on non pointed region\n" , map->name);/* Should this give an error? */ + }else { +printk (KERN_ERR "%s: Error: unpoint called on non pointed region\n" , map->name); + err = -EINVAL ; + }put_chip (map, chip, chip->start);mutex_unlock (&chip->mutex);
@@ -1410,6 +1412,8 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) ofs =0 ; chipnum++; } + +return err; }static inline int do_read_onechip (struct map_info *map,struct flchip *chip,loff_t adr,size_t len,u_char *buf)
drivers/mtd/devices/mtdram.c +2 -1
@@ -60,8 +60,9 @@ static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,return 0 ; } -static void ram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int ram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) { +return 0 ; }/*
drivers/mtd/devices/phram.c +2 -1
@@ -70,8 +70,9 @@ static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,return 0 ; } -static void phram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int phram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) { +return 0 ; } static int phram_read(struct mtd_info *mtd, loff_t from, size_t len,
drivers/mtd/devices/pmc551.c +2 -1
@@ -206,11 +206,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,return 0 ; } -static void pmc551_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int pmc551_unpoint (struct mtd_info *mtd,loff_t from,size_t len) {#ifdef CONFIG_MTD_PMC551_DEBUG printk (KERN_DEBUG "pmc551_unpoint()\n" );#endif +return 0 ; } static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
drivers/mtd/devices/slram.c +3 -2
@@ -76,7 +76,7 @@ static slram_mtd_list_t *slram_mtdlist = NULL;static int slram_erase (struct mtd_info *,struct erase_info *);static int slram_point (struct mtd_info *,loff_t ,size_t ,size_t *,void **,resource_size_t *); -static void slram_unpoint (struct mtd_info *,loff_t ,size_t ); +static int slram_unpoint (struct mtd_info *,loff_t ,size_t );static int slram_read (struct mtd_info *,loff_t ,size_t ,size_t *,u_char *);static int slram_write (struct mtd_info *,loff_t ,size_t ,size_t *,const u_char *);
@@ -119,8 +119,9 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,return (0 ); } -static void slram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int slram_unpoint (struct mtd_info *mtd,loff_t from,size_t len) { +return 0 ; } static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
drivers/mtd/lpddr/lpddr_cmds.c +8 -4
@@ -40,7 +40,7 @@ static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);static int lpddr_unlock (struct mtd_info *mtd,loff_t ofs,uint64_t len);static int lpddr_point (struct mtd_info *mtd,loff_t adr,size_t len,size_t *retlen,void **mtdbuf,resource_size_t *phys); -static void lpddr_unpoint (struct mtd_info *mtd,loff_t adr,size_t len); +static int lpddr_unpoint (struct mtd_info *mtd,loff_t adr,size_t len);static int get_chip (struct map_info *map,struct flchip *chip,int mode);static int chip_ready (struct map_info *map,struct flchip *chip,int mode);static void put_chip (struct map_info *map,struct flchip *chip);
@@ -575,11 +575,11 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,return 0 ; } -static void lpddr_unpoint (struct mtd_info *mtd,loff_t adr,size_t len) +static int lpddr_unpoint (struct mtd_info *mtd,loff_t adr,size_t len) {struct map_info *map = mtd->priv;struct lpddr_private *lpddr = map->fldrv_priv; -int chipnum = adr >> lpddr->chipshift; +int chipnum = adr >> lpddr->chipshift, err =0 ;unsigned long ofs;/* ofs: offset within the first chip that the first read should start */
@@ -603,9 +603,11 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) chip->ref_point_counter--;if (chip->ref_point_counter ==0 ) chip->state =FL_READY ; - }else + }else {printk (KERN_WARNING "%s: Warning: unpoint called on non" "pointed region\n" , map->name); + err = -EINVAL ; + }put_chip (map, chip);mutex_unlock (&chip->mutex);
@@ -614,6 +616,8 @@ static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len) ofs =0 ; chipnum++; } + +return err; } static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
drivers/mtd/mtdpart.c +2 -2
@@ -92,11 +92,11 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, virt, phys); } -static void part_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static int part_unpoint (struct mtd_info *mtd,loff_t from,size_t len) {struct mtd_part *part =PART (mtd); -mtd_unpoint (part->master, from + part->offset, len); +return mtd_unpoint (part->master, from + part->offset, len); } static unsigned long part_get_unmapped_area(struct mtd_info *mtd,
include/linux/mtd/mtd.h +4 -2
@@ -177,7 +177,7 @@ struct mtd_info {int (*_erase) (struct mtd_info *mtd,struct erase_info *instr);int (*_point) (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys); -void (*_unpoint) (struct mtd_info *mtd,loff_t from,size_t len); +int (*_unpoint) (struct mtd_info *mtd,loff_t from,size_t len); unsigned long (*_get_unmapped_area) (struct mtd_info *mtd, unsigned long len, unsigned long offset,
@@ -265,8 +265,10 @@ static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, }/* We probably shouldn't allow XIP if the unpoint isn't a NULL */ -static inline void mtd_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +static inline int mtd_unpoint (struct mtd_info *mtd,loff_t from,size_t len) { +if (!mtd->_point) +return -EOPNOTSUPP ;return mtd->_unpoint (mtd, from, len); }
include/linux/mtd/pmc551.h +0 -1
@@ -34,7 +34,6 @@ struct mypriv {* Function Prototypes */ static int pmc551_erase (struct mtd_info *,struct erase_info *); -static void pmc551_unpoint (struct mtd_info *,loff_t ,size_t );static int pmc551_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys);static int pmc551_read (struct mtd_info *,loff_t ,size_t ,size_t *,u_char *);
Signature · 1 line
1.7.9
PATCH 2/9 mtd: add offset and length checks to the API function
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Add verification of the offset and length to MTD API functions and verify that MTD device offset and length are within MTD device size.
The modified API functions are:
'mtd_erase()'
'mtd_point()'
'mtd_unpoint()'
'mtd_get_unmapped_area()'
'mtd_read()'
'mtd_write()'
'mtd_panic_write()'
'mtd_lock()'
'mtd_unlock()'
'mtd_is_locked()'
'mtd_block_isbad()'
'mtd_block_markbad()'
This patch also uninlines these functions and exports in mtdcore.c because they are not performance-critical and do not have to be inlined.
--- drivers/mtd/mtdcore.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mtd/mtd.h | 129 ++++++----------------------------------- 2 files changed, 165 insertions(+), 112 deletions(-)
drivers/mtd/mtdcore.c +148 -0
@@ -683,6 +683,154 @@ void __put_mtd_device(struct mtd_info *mtd)EXPORT_SYMBOL_GPL (__put_mtd_device);/* +* Erase is an asynchronous operation. Device drivers are supposed +* to call instr->callback() whenever the operation completes, even +* if it completes with a failure. +* Callers are supposed to pass a callback function and wait for it +* to be called before writing to the block. +*/ +int mtd_erase (struct mtd_info *mtd,struct erase_info *instr) +{ +if (instr->addr > mtd->size || instr->len > mtd->size - instr->addr) +return -EINVAL ; +return mtd->_erase (mtd, instr); +} +EXPORT_SYMBOL_GPL (mtd_erase); + +/* +* This stuff for eXecute-In-Place. phys is optional and may be set to NULL. +*/ +int mtd_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen, +void **virt,resource_size_t *phys) +{ + *retlen =0 ; +if (!mtd->_point) +return -EOPNOTSUPP ; +if (from <0 || from > mtd->size || len > mtd->size - from) +return -EINVAL ; +return mtd->_point (mtd, from, len, retlen, virt, phys); +} +EXPORT_SYMBOL_GPL (mtd_point); + +/* We probably shouldn't allow XIP if the unpoint isn't a NULL */ +int mtd_unpoint (struct mtd_info *mtd,loff_t from,size_t len) +{ +if (!mtd->_point) +return -EOPNOTSUPP ; +if (from <0 || from > mtd->size || len > mtd->size - from) +return -EINVAL ; +return mtd->_unpoint (mtd, from, len); +} +EXPORT_SYMBOL_GPL (mtd_unpoint); + +/* +* Allow NOMMU mmap() to directly map the device (if not NULL) +* - return the address to which the offset maps +* - return -ENOSYS to indicate refusal to do the mapping +*/ +unsigned long mtd_get_unmapped_area (struct mtd_info *mtd,unsigned long len, +unsigned long offset,unsigned long flags) +{ +if (!mtd->_get_unmapped_area) +return -EOPNOTSUPP ; +if (offset > mtd->size || len > mtd->size - offset) +return -EINVAL ; +return mtd->_get_unmapped_area (mtd, len, offset, flags); +} +EXPORT_SYMBOL_GPL (mtd_get_unmapped_area); + +int mtd_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen, +u_char *buf) +{ +if (from <0 || from > mtd->size || len > mtd->size - from) +return -EINVAL ; +return mtd->_read (mtd, from, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_read); + +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 ; +if (to <0 || to > mtd->size || len > mtd->size - to) +return -EINVAL ; +return mtd->_write (mtd, to, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_write); + +/* +* In blackbox flight recorder like scenarios we want to make successful writes +* in interrupt context. panic_write() is only intended to be called when its +* known the kernel is about to panic and we need the write to succeed. Since +* the kernel is not going to be running for much longer, this function can +* break locks and delay to ensure the write succeeds (but not sleep). +*/ +int mtd_panic_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen, +const u_char *buf) +{ + *retlen =0 ; +if (!mtd->_panic_write) +return -EOPNOTSUPP ; +if (to <0 || to > mtd->size || len > mtd->size - to) +return -EINVAL ; +return mtd->_panic_write (mtd, to, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_panic_write); + +/* Chip-supported device locking */ +int mtd_lock (struct mtd_info *mtd,loff_t ofs,uint64_t len) +{ +if (!mtd->_lock) +return -EOPNOTSUPP ; +if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs) +return -EINVAL ; +return mtd->_lock (mtd, ofs, len); +} +EXPORT_SYMBOL_GPL (mtd_lock); + +int mtd_unlock (struct mtd_info *mtd,loff_t ofs,uint64_t len) +{ +if (!mtd->_unlock) +return -EOPNOTSUPP ; +if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs) +return -EINVAL ; +return mtd->_unlock (mtd, ofs, len); +} +EXPORT_SYMBOL_GPL (mtd_unlock); + +int mtd_is_locked (struct mtd_info *mtd,loff_t ofs,uint64_t len) +{ +if (!mtd->_is_locked) +return -EOPNOTSUPP ; +if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs) +return -EINVAL ; +return mtd->_is_locked (mtd, ofs, len); +} +EXPORT_SYMBOL_GPL (mtd_is_locked); + +int mtd_block_isbad (struct mtd_info *mtd,loff_t ofs) +{ +if (!mtd->_block_isbad) +return 0 ; +if (ofs <0 || ofs > mtd->size) +return -EINVAL ; +return mtd->_block_isbad (mtd, ofs); +} +EXPORT_SYMBOL_GPL (mtd_block_isbad); + +int mtd_block_markbad (struct mtd_info *mtd,loff_t ofs) +{ +if (!mtd->_block_markbad) +return -EOPNOTSUPP ; +if (ofs <0 || ofs > mtd->size) +return -EINVAL ; +return mtd->_block_markbad (mtd, ofs); +} +EXPORT_SYMBOL_GPL (mtd_block_markbad); + +/* * default_mtd_writev - the default writev method * @mtd: mtd device description object pointer * @vecs: the vectors to write
include/linux/mtd/mtd.h +17 -112
147 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 4/9 mtd: remove R/O checking duplication
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Many drivers check whether the partition is R/O and return -EROFS if yes. Let's stop having duplicated checks and move them to the API functions instead.
And again a bit of noise - deleted few too sparse newlines, sorry.
--- drivers/mtd/chips/map_ram.c | 4 ---- drivers/mtd/chips/map_rom.c | 3 +-- drivers/mtd/devices/phram.c | 1 - drivers/mtd/mtdconcat.c | 27 +++------------------------ drivers/mtd/mtdcore.c | 12 ++++++++++-- drivers/mtd/mtdpart.c | 14 +------------- drivers/mtd/ubi/gluebi.c | 8 -------- include/linux/mtd/mtd.h | 2 ++ 8 files changed, 17 insertions(+), 54 deletions(-)
drivers/mtd/chips/map_ram.c +0 -4
@@ -122,14 +122,10 @@ static int mapram_erase (struct mtd_info *mtd, struct erase_info *instr)unsigned long i; allff =map_word_ff (map); -for (i=0 ; i<instr->len; i +=map_bankwidth (map))map_write (map, allff, instr->addr + i); - instr->state =MTD_ERASE_DONE ; -mtd_erase_callback (instr); -return 0 ; }
drivers/mtd/chips/map_rom.c +1 -2
@@ -85,8 +85,7 @@ static void maprom_nop(struct mtd_info *mtd)static int maprom_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf) { -printk (KERN_NOTICE "maprom_write called\n" ); -return -EIO ; +return -EROFS ; }static int maprom_erase (struct mtd_info *mtd,struct erase_info *info)
drivers/mtd/devices/phram.c +0 -1
@@ -33,7 +33,6 @@ struct phram_mtd_list {static LIST_HEAD (phram_list); -static int phram_erase (struct mtd_info *mtd,struct erase_info *instr) {u_char *start = mtd->priv;
drivers/mtd/mtdconcat.c +3 -24
@@ -126,9 +126,6 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,int err = -EINVAL ;int i; -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; - *retlen =0 ;for (i =0 ; i < concat->num_subdev; i++) {
@@ -145,11 +142,7 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,else size = len; -if (!(subdev->flags &MTD_WRITEABLE )) - err = -EROFS ; -else - err =mtd_write (subdev, to, size, &retsize, buf); - + err =mtd_write (subdev, to, size, &retsize, buf);if (err)break ;
@@ -176,9 +169,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,int i;int err = -EINVAL ; -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; - *retlen =0 ;/* Calculate total length of data */
@@ -220,12 +210,8 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs, old_iov_len = vecs_copy[entry_high].iov_len; vecs_copy[entry_high].iov_len = size; -if (!(subdev->flags &MTD_WRITEABLE )) - err = -EROFS ; -else - err =mtd_writev (subdev, &vecs_copy[entry_low], - entry_high - entry_low +1 , to, - &retsize); + err =mtd_writev (subdev, &vecs_copy[entry_low], + entry_high - entry_low +1 , to, &retsize); vecs_copy[entry_high].iov_len = old_iov_len - size; vecs_copy[entry_high].iov_base += size;
@@ -399,9 +385,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)uint64_t length, offset =0 ;struct erase_info *erase; -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; -/* * Check for proper erase block alignment of the to-be-erased area. * It is easier to do this based on the super device's erase
@@ -489,10 +472,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)else erase->len = length; -if (!(subdev->flags &MTD_WRITEABLE )) { - err = -EROFS ; -break ; - } length -= erase->len;if ((err =concat_dev_erase (subdev, erase))) {/* sanity check: should never happen since
drivers/mtd/mtdcore.c +10 -2
@@ -693,6 +693,8 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) {if (instr->addr > mtd->size || instr->len > mtd->size - instr->addr)return -EINVAL ; +if (!(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;return mtd->_erase (mtd, instr); }EXPORT_SYMBOL_GPL (mtd_erase);
@@ -752,10 +754,10 @@ 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 ;if (to <0 || to > mtd->size || len > mtd->size - to)return -EINVAL ; +if (!mtd->_write || !(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;return mtd->_write (mtd, to, len, retlen, buf); }EXPORT_SYMBOL_GPL (mtd_write);
@@ -775,6 +777,8 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,return -EOPNOTSUPP ;if (to <0 || to > mtd->size || len > mtd->size - to)return -EINVAL ; +if (!(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;return mtd->_panic_write (mtd, to, len, retlen, buf); }EXPORT_SYMBOL_GPL (mtd_panic_write);
@@ -826,6 +830,8 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs)return -EOPNOTSUPP ;if (ofs <0 || ofs > mtd->size)return -EINVAL ; +if (!(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;return mtd->_block_markbad (mtd, ofs); }EXPORT_SYMBOL_GPL (mtd_block_markbad);
@@ -877,6 +883,8 @@ int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen) { *retlen =0 ; +if (!(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;if (!mtd->_writev)return default_mtd_writev (mtd, vecs, count, to, retlen);return mtd->_writev (mtd, vecs, count, to, retlen);
drivers/mtd/mtdpart.c +1 -13
@@ -172,8 +172,6 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { struct mtd_part *part = PART(mtd); -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ;return mtd_write (part->master, to + part->offset, len, retlen, buf); }
@@ -181,8 +179,6 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { struct mtd_part *part = PART(mtd); -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ;return mtd_panic_write (part->master, to + part->offset, len, retlen, buf); }
@@ -192,9 +188,6 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, {struct mtd_part *part =PART (mtd); -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; -if (to >= mtd->size)return -EINVAL ;if (ops->datbuf && to + ops->len > mtd->size)
@@ -220,8 +213,6 @@ static int part_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen) { struct mtd_part *part = PART(mtd); -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ;return mtd_writev (part->master, vecs, count, to + part->offset, retlen); }
@@ -230,8 +221,7 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) {struct mtd_part *part =PART (mtd);int ret; -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; + instr->addr += part->offset; ret =mtd_erase (part->master, instr);if (ret) {
@@ -304,8 +294,6 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)struct mtd_part *part =PART (mtd);int res; -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; ofs += part->offset; res =mtd_block_markbad (part->master, ofs);if (!res)
drivers/mtd/ubi/gluebi.c +0 -8
@@ -215,10 +215,6 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,struct gluebi_device *gluebi; gluebi = container_of(mtd, struct gluebi_device, mtd); - -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; - lnum =div_u64_rem (to, mtd->erasesize, &offs);if (len % mtd->writesize || offs % mtd->writesize)
@@ -263,12 +259,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) lnum =mtd_div_by_eb (instr->addr, mtd); count =mtd_div_by_eb (instr->len, mtd); - gluebi = container_of(mtd, struct gluebi_device, mtd); -if (!(mtd->flags &MTD_WRITEABLE )) -return -EROFS ; -for (i =0 ; i < count -1 ; i++) { err =ubi_leb_unmap (gluebi->desc, lnum + i);if (err)
include/linux/mtd/mtd.h +2 -0
@@ -268,6 +268,8 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, ops->retlen = ops->oobretlen =0 ;if (!mtd->_write_oob)return -EOPNOTSUPP ; +if (!(mtd->flags &MTD_WRITEABLE )) +return -EROFS ;return mtd->_write_oob (mtd, to, ops); }
Signature · 1 line
1.7.9
PATCH 5/9 mtd: remove retlen zeroing duplication
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
The MTD API function now zero the 'retlen' parameter before calling the driver's method - do not do this again in dirvers. This removes duplicated '*retlen = 0' assignent from the following methods:
'mtd_point()'
'mtd_read()'
'mtd_write()'
'mtd_writev()'
'mtd_panic_write()'--- drivers/mtd/chips/cfi_cmdset_0001.c | 5 ----- drivers/mtd/chips/cfi_cmdset_0002.c | 12 ------------ drivers/mtd/chips/cfi_cmdset_0020.c | 3 --- drivers/mtd/chips/map_absent.c | 2 -- drivers/mtd/devices/block2mtd.c | 5 ----- drivers/mtd/devices/doc2000.c | 4 ---- drivers/mtd/devices/doc2001.c | 1 - drivers/mtd/devices/doc2001plus.c | 1 - drivers/mtd/devices/lart.c | 2 -- drivers/mtd/devices/m25p80.c | 7 ------- drivers/mtd/devices/mtd_dataflash.c | 4 ---- drivers/mtd/devices/phram.c | 2 -- drivers/mtd/devices/spear_smi.c | 10 ---------- drivers/mtd/devices/sst25l.c | 3 --- drivers/mtd/lpddr/lpddr_cmds.c | 3 --- drivers/mtd/mtdconcat.c | 6 ------ drivers/mtd/mtdcore.c | 1 + drivers/mtd/onenand/onenand_base.c | 3 --- 18 files changed, 1 insertions(+), 73 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +0 -5
@@ -1334,7 +1334,6 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len, ofs = from - (chipnum << cfi->chipshift); *virt = map->virt + cfi->chips[chipnum].start + ofs; - *retlen =0 ;if (phys) *phys = map->phys + cfi->chips[chipnum].start + ofs;
@@ -1460,8 +1459,6 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz chipnum = (from >> cfi->chipshift); ofs = from - (chipnum << cfi->chipshift); - *retlen =0 ; -while (len) {unsigned long thislen;
@@ -1569,7 +1566,6 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t leint chipnum;unsigned long ofs; - *retlen =0 ;if (!len)return 0 ;
@@ -1817,7 +1813,6 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,for (i =0 ; i < count; i++) len += vecs[i].iov_len; - *retlen =0 ;if (!len)return 0 ;
drivers/mtd/chips/cfi_cmdset_0002.c +0 -12
@@ -1017,13 +1017,9 @@ static int cfi_amdstd_read (struct mtd_info *mtd, loff_t from, size_t len, size_int ret =0 ;/* ofs: offset within the first chip that the first read should start */ - chipnum = (from >> cfi->chipshift); ofs = from - (chipnum << cfi->chipshift); - - *retlen =0 ; -while (len) {unsigned long thislen;
@@ -1101,16 +1097,11 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len,int chipnum;int ret =0 ; -/* ofs: offset within the first chip that the first read should start */ -/* 8 secsi bytes per chip */ chipnum=from>>3 ; ofs=from &7 ; - - *retlen =0 ; -while (len) {unsigned long thislen;
@@ -1255,7 +1246,6 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,unsigned long ofs, chipstart;DECLARE_WAITQUEUE (wait, current); - *retlen =0 ;if (!len)return 0 ;
@@ -1497,7 +1487,6 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,int chipnum;unsigned long ofs; - *retlen =0 ;if (!len)return 0 ;
@@ -1708,7 +1697,6 @@ static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,int ret =0 ;int chipnum; - *retlen =0 ;if (!len)return 0 ;
drivers/mtd/chips/cfi_cmdset_0020.c +0 -3
@@ -394,8 +394,6 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t chipnum = (from >> cfi->chipshift); ofs = from - (chipnum << cfi->chipshift); - *retlen =0 ; -while (len) {unsigned long thislen;
@@ -617,7 +615,6 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,int chipnum;unsigned long ofs; - *retlen =0 ;if (!len)return 0 ;
drivers/mtd/chips/map_absent.c +0 -2
@@ -70,13 +70,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map)static int map_absent_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf) { - *retlen =0 ;return -ENODEV ; }static int map_absent_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf) { - *retlen =0 ;return -ENODEV ; }
drivers/mtd/devices/block2mtd.c +0 -5
@@ -104,9 +104,6 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,int offset = from & (PAGE_SIZE -1 );int cpylen; -if (retlen) - *retlen =0 ; -while (len) {if ((offset + len) >PAGE_SIZE ) cpylen =PAGE_SIZE - offset;// multiple pages
@@ -143,8 +140,6 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,int offset = to & ~PAGE_MASK ;// page offset int cpylen; -if (retlen) - *retlen =0 ;while (len) {if ((offset+len) >PAGE_SIZE ) cpylen =PAGE_SIZE - offset;// multiple pages
drivers/mtd/devices/doc2000.c +0 -4
@@ -603,8 +603,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,size_t left = len;mutex_lock (&this->lock); - - *retlen =0 ;while (left) { len = left;
@@ -745,8 +743,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,int status;mutex_lock (&this->lock); - - *retlen =0 ;while (left) { len = left;
drivers/mtd/devices/doc2001.c +0 -1
@@ -591,7 +591,6 @@ static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,printk ("Error programming flash\n" );/* Error in programming FIXME: implement Bad Block Replacement (in nftl.c ??) */ - *retlen =0 ; ret = -EIO ; } dummy =ReadDOC (docptr, LastDataRead);
drivers/mtd/devices/doc2001plus.c +0 -1
@@ -792,7 +792,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,printk ("MTD: Error 0x%x programming at 0x%x\n" , dummy, (int )to);/* Error in programming FIXME: implement Bad Block Replacement (in nftl.c ??) */ - *retlen =0 ; ret = -EIO ; } dummy =ReadDOC (docptr, Mplus_LastDataRead);
drivers/mtd/devices/lart.c +0 -2
@@ -518,8 +518,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlenprintk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n" , __func__, (__u32 )to, len);#endif - *retlen =0 ; -/* sanity checks */ if (!len)return (0 );
drivers/mtd/devices/m25p80.c +0 -7
@@ -365,9 +365,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, t[1 ].len = len;spi_message_add_tail (&t[1 ], &m); -/* Byte count starts at zero. */ - *retlen =0 ; -mutex_lock (&flash->lock);/* Wait till previous write/erase is done. */
@@ -411,8 +408,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: %s to 0x%08x, len %zd\n" ,dev_name (&flash->spi->dev), __func__, (u32 )to, len); - *retlen =0 ; -/* sanity checks */ if (!len)return (0 );
@@ -500,8 +495,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: %s to 0x%08x, len %zd\n" ,dev_name (&flash->spi->dev), __func__, (u32 )to, len); - *retlen =0 ; -/* sanity checks */ if (!len)return 0 ;
drivers/mtd/devices/mtd_dataflash.c +0 -4
@@ -249,8 +249,6 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,pr_debug ("%s: read 0x%x..0x%x\n" ,dev_name (&priv->spi->dev), (unsigned )from, (unsigned )(from + len)); - *retlen =0 ; -/* Sanity checks */ if (!len)return 0 ;
@@ -323,8 +321,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: write 0x%x..0x%x\n" ,dev_name (&spi->dev), (unsigned )to, (unsigned )(to + len)); - *retlen =0 ; -/* Sanity checks */ if (!len)return 0 ;
drivers/mtd/devices/phram.c +0 -2
@@ -85,8 +85,6 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,return 0 ; } - -static void unregister_devices (void ) {struct phram_mtd_list *this, *safe;
drivers/mtd/devices/spear_smi.c +0 -10
@@ -576,11 +576,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,return -EINVAL ; } -if (!retlen) -return -EINVAL ; -else - *retlen =0 ; -/* select address as per bank number */ src = flash->base_addr + from;
@@ -677,11 +672,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,return -EINVAL ; } -if (!retlen) -return -EINVAL ; -else - *retlen =0 ; -/* select address as per bank number */ dest = flash->base_addr + to;mutex_lock (&flash->lock);
drivers/mtd/devices/sst25l.c +0 -3
@@ -224,9 +224,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len,if (len ==0 )return 0 ; -if (retlen) - *retlen =0 ; -spi_message_init (&message);memset (&transfer,0 ,sizeof (transfer));
drivers/mtd/lpddr/lpddr_cmds.c +0 -3
@@ -535,9 +535,7 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,/* ofs: offset within the first chip that the first read should start */ ofs = adr - (chipnum << lpddr->chipshift); - *mtdbuf = (void *)map->virt + chip->start + ofs; - *retlen =0 ;while (len) {unsigned long thislen;
@@ -647,7 +645,6 @@ static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,for (i =0 ; i < count; i++) len += vecs[i].iov_len; - *retlen =0 ;if (!len)return 0 ;
drivers/mtd/mtdconcat.c +0 -6
@@ -72,8 +72,6 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len,int ret =0 , err;int i; - *retlen =0 ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];size_t size, retsize;
@@ -126,8 +124,6 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,int err = -EINVAL ;int i; - *retlen =0 ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];size_t size, retsize;
@@ -169,8 +165,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,int i;int err = -EINVAL ; - *retlen =0 ; -/* Calculate total length of data */ for (i =0 ; i < count; i++) total_len += vecs[i].iov_len;
drivers/mtd/mtdcore.c +1 -0
@@ -744,6 +744,7 @@ EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);int mtd_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf) { + *retlen =0 ;if (from <0 || from > mtd->size || len > mtd->size - from)return -EINVAL ;return mtd->_read (mtd, from, len, retlen, buf);
drivers/mtd/onenand/onenand_base.c +0 -3
@@ -1753,9 +1753,6 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: to = 0x%08x, len = %i\n" , __func__, (unsigned int )to, (int )len); -/* Initialize retlen, in case of early exit */ - *retlen =0 ; -/* Reject writes, which are not page aligned */ if (unlikely (NOTALIGNED (to) ||NOTALIGNED (len))) { printk(KERN_ERR "%s: Attempt to write not page aligned data\n",
Signature · 1 line
1.7.9
PATCH 3/9 mtd: do not duplicate length and offset checks in drivers
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
We already verify that offset and length are within the MTD device size in the MTD API functions. Let's remove the duplicated checks in drivers. This patch only affects the following API's:
'mtd_erase()'
'mtd_point()'
'mtd_unpoint()'
'mtd_get_unmapped_area()'
'mtd_read()'
'mtd_write()'
'mtd_panic_write()'
'mtd_lock()'
'mtd_unlock()'
'mtd_is_locked()'
'mtd_block_isbad()'
'mtd_block_markbad()'
This patch adds a bit of noise by removing too sparse empty lines, but this is not too bad.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 2 +- drivers/mtd/chips/cfi_cmdset_0020.c | 9 -------- drivers/mtd/chips/cfi_util.c | 6 ----- drivers/mtd/devices/block2mtd.c | 9 -------- drivers/mtd/devices/doc2000.c | 8 ------- drivers/mtd/devices/doc2001.c | 8 ------- drivers/mtd/devices/doc2001plus.c | 8 ------- drivers/mtd/devices/lart.c | 5 ---- drivers/mtd/devices/m25p80.c | 12 ----------- drivers/mtd/devices/ms02-nv.c | 8 ------- drivers/mtd/devices/mtd_dataflash.c | 7 ------ drivers/mtd/devices/mtdram.c | 17 --------------- drivers/mtd/devices/phram.c | 23 --------------------- drivers/mtd/devices/pmc551.c | 38 ----------------------------------- drivers/mtd/devices/slram.c | 23 --------------------- drivers/mtd/devices/spear_smi.c | 12 ----------- drivers/mtd/devices/sst25l.c | 9 -------- drivers/mtd/lpddr/lpddr_cmds.c | 5 +--- drivers/mtd/mtdconcat.c | 26 ----------------------- drivers/mtd/mtdpart.c | 30 +-------------------------- drivers/mtd/nand/nand_base.c | 28 ------------------------- drivers/mtd/onenand/onenand_base.c | 20 ------------------ drivers/mtd/ubi/gluebi.c | 11 ---------- 23 files changed, 3 insertions(+), 321 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +1 -1
@@ -1324,7 +1324,7 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,int chipnum;int ret =0 ; -if (!map->virt || (from + len > mtd->size)) +if (!map->virt)return -EINVAL ;/* Now lock the chip(s) to POINT state */
drivers/mtd/chips/cfi_cmdset_0020.c +0 -9
@@ -904,12 +904,6 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,int i, first;struct mtd_erase_region_info *regions = mtd->eraseregions; -if (instr->addr > mtd->size) -return -EINVAL ; - -if ((instr->len + instr->addr) > mtd->size) -return -EINVAL ; -/* Check that both start and end of the requested erase are * aligned with the erasesize at the appropriate addresses. */
@@ -1155,9 +1149,6 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)if (len & (mtd->erasesize -1 ))return -EINVAL ; -if ((len + ofs) > mtd->size) -return -EINVAL ; - chipnum = ofs >> cfi->chipshift; adr = ofs - (chipnum << cfi->chipshift);
drivers/mtd/chips/cfi_util.c +0 -6
@@ -173,12 +173,6 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,int i, first;struct mtd_erase_region_info *regions = mtd->eraseregions; -if (ofs > mtd->size) -return -EINVAL ; - -if ((len + ofs) > mtd->size) -return -EINVAL ; -/* Check that both start and end of the requested erase are * aligned with the erasesize at the appropriate addresses. */
drivers/mtd/devices/block2mtd.c +0 -9
@@ -104,11 +104,6 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,int offset = from & (PAGE_SIZE -1 );int cpylen; -if (from > mtd->size) -return -EINVAL ; -if (from + len > mtd->size) - len = mtd->size - from; -if (retlen) *retlen =0 ;
@@ -190,10 +185,6 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,if (!len)return 0 ; -if (to >= mtd->size) -return -ENOSPC ; -if (to + len > mtd->size) - len = mtd->size - to;mutex_lock (&dev->write_mutex); err =_block2mtd_write (dev, buf, to, len, retlen);
drivers/mtd/devices/doc2000.c +0 -8
@@ -602,10 +602,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,int i, len256 =0 , ret=0 ;size_t left = len; -/* Don't allow read past end of device */ -if (from >= this->totlen) -return -EINVAL ; -mutex_lock (&this->lock); *retlen =0 ;
@@ -748,10 +744,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,size_t left = len;int status; -/* Don't allow write past end of device */ -if (to >= this->totlen) -return -EINVAL ; -mutex_lock (&this->lock); *retlen =0 ;
drivers/mtd/devices/doc2001.c +0 -8
@@ -383,10 +383,6 @@ static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,void __iomem *docptr = this->virtadr;struct Nand *mychip = &this->chips[from >> (this->chipshift)]; -/* Don't allow read past end of device */ -if (from >= this->totlen) -return -EINVAL ; -/* Don't allow a single read to cross a 512-byte block boundary */ if (from + len > ((from |0x1ff ) +1 )) len = ((from |0x1ff ) +1 ) - from;
@@ -494,10 +490,6 @@ static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,void __iomem *docptr = this->virtadr;struct Nand *mychip = &this->chips[to >> (this->chipshift)]; -/* Don't allow write past end of device */ -if (to >= this->totlen) -return -EINVAL ; -#if 0 /* Don't allow a single write to cross a 512-byte block boundary */ if (to + len > ( (to |0x1ff ) +1 ))
drivers/mtd/devices/doc2001plus.c +0 -8
@@ -581,10 +581,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,void __iomem * docptr = this->virtadr;struct Nand *mychip = &this->chips[from >> (this->chipshift)]; -/* Don't allow read past end of device */ -if (from >= this->totlen) -return -EINVAL ; -/* Don't allow a single read to cross a 512-byte block boundary */ if (from + len > ((from |0x1ff ) +1 )) len = ((from |0x1ff ) +1 ) - from;
@@ -700,10 +696,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,void __iomem * docptr = this->virtadr;struct Nand *mychip = &this->chips[to >> (this->chipshift)]; -/* Don't allow write past end of device */ -if (to >= this->totlen) -return -EINVAL ; -/* Don't allow writes which aren't exactly one block (512 bytes) */ if ((to &0x1ff ) || (len !=0x200 ))return -EINVAL ;
drivers/mtd/devices/lart.c +0 -5
@@ -367,9 +367,6 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr)printk (KERN_DEBUG "%s(addr = 0x%.8x, len = %d)\n" , __func__, instr->addr, instr->len);#endif -/* sanity checks */ -if (instr->addr + instr->len > mtd->size)return (-EINVAL ); -/* * check that both start and end of the requested erase are * aligned with the erasesize at the appropriate addresses.
@@ -442,7 +439,6 @@ static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retle/* sanity checks */ if (!len)return (0 ); -if (from + len > mtd->size)return (-EINVAL );/* we always read len bytes */ *retlen = len;
@@ -526,7 +522,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen/* sanity checks */ if (!len)return (0 ); -if (to + len > mtd->size)return (-EINVAL );/* first, we write a 0xFF.... padded byte until we reach a dword boundary */ if (to & (BUSWIDTH -1 ))
drivers/mtd/devices/m25p80.c +0 -12
@@ -288,9 +288,6 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) __func__, (long long )instr->addr, (long long)instr->len); -/* sanity checks */ -if (instr->addr + instr->len > flash->mtd.size) -return -EINVAL ;div_u64_rem (instr->len, mtd->erasesize, &rem);if (rem)return -EINVAL ;
@@ -353,9 +350,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,if (!len)return 0 ; -if (from + len > flash->mtd.size) -return -EINVAL ; -spi_message_init (&m);memset (t,0 , (sizeof t));
@@ -423,9 +417,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,if (!len)return (0 ); -if (to + len > flash->mtd.size) -return -EINVAL ; -spi_message_init (&m);memset (t,0 , (sizeof t));
@@ -515,9 +506,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,if (!len)return 0 ; -if (to + len > flash->mtd.size) -return -EINVAL ; -spi_message_init (&m);memset (t,0 , (sizeof t));
drivers/mtd/devices/ms02-nv.c +0 -8
@@ -59,12 +59,8 @@ static int ms02nv_read(struct mtd_info *mtd, loff_t from, {struct ms02nv_private *mp = mtd->priv; -if (from + len > mtd->size) -return -EINVAL ; -memcpy (buf, mp->uaddr + from, len); *retlen = len; -return 0 ; }
@@ -73,12 +69,8 @@ static int ms02nv_write(struct mtd_info *mtd, loff_t to, {struct ms02nv_private *mp = mtd->priv; -if (to + len > mtd->size) -return -EINVAL ; -memcpy (mp->uaddr + to, buf, len); *retlen = len; -return 0 ; }
drivers/mtd/devices/mtd_dataflash.c +0 -7
@@ -164,9 +164,6 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)dev_name (&spi->dev), (long long )instr->addr, (long long)instr->len); -/* Sanity checks */ -if (instr->addr + instr->len > mtd->size) -return -EINVAL ;div_u64_rem (instr->len, priv->page_size, &rem);if (rem)return -EINVAL ;
@@ -257,8 +254,6 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,/* Sanity checks */ if (!len)return 0 ; -if (from + len > mtd->size) -return -EINVAL ;/* Calculate flash page/byte address */ addr = (((unsigned )from / priv->page_size) << priv->page_offset)
@@ -333,8 +328,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,/* Sanity checks */ if (!len)return 0 ; -if ((to + len) > mtd->size) -return -EINVAL ;spi_message_init (&msg);
drivers/mtd/devices/mtdram.c +0 -17
@@ -34,27 +34,18 @@ static struct mtd_info *mtd_info;static int ram_erase (struct mtd_info *mtd,struct erase_info *instr) { -if (instr->addr + instr->len > mtd->size) -return -EINVAL ; -memset ((char *)mtd->priv + instr->addr,0xff , instr->len); - instr->state =MTD_ERASE_DONE ;mtd_erase_callback (instr); -return 0 ; }static int ram_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys) { -if (from + len > mtd->size) -return -EINVAL ; -/* can we return a physical address with this driver? */ if (phys)return -EINVAL ; - *virt = mtd->priv + from; *retlen = len;return 0 ;
@@ -81,11 +72,7 @@ static unsigned long ram_get_unmapped_area(struct mtd_info *mtd,static int ram_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,u_char *buf) { -if (from + len > mtd->size) -return -EINVAL ; -memcpy (buf, mtd->priv + from, len); - *retlen = len;return 0 ; }
@@ -93,11 +80,7 @@ static int ram_read(struct mtd_info *mtd, loff_t from, size_t len,static int ram_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf) { -if (to + len > mtd->size) -return -EINVAL ; -memcpy ((char *)mtd->priv + to, buf, len); - *retlen = len;return 0 ; }
drivers/mtd/devices/phram.c +0 -23
@@ -38,29 +38,20 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) {u_char *start = mtd->priv; -if (instr->addr + instr->len > mtd->size) -return -EINVAL ; -memset (start + instr->addr,0xff , instr->len);/* This'll catch a few races. Free the thing before returning :) * I don't feel at all ashamed. This kind of thing is possible anyway * with flash, but unlikely. */ - instr->state =MTD_ERASE_DONE ; -mtd_erase_callback (instr); -return 0 ; }static int phram_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys) { -if (from + len > mtd->size) -return -EINVAL ; -/* can we return a physical address with this driver? */ if (phys)return -EINVAL ;
@@ -80,14 +71,7 @@ static int phram_read(struct mtd_info *mtd, loff_t from, size_t len, {u_char *start = mtd->priv; -if (from >= mtd->size) -return -EINVAL ; - -if (len > mtd->size - from) - len = mtd->size - from; -memcpy (buf, start + from, len); - *retlen = len;return 0 ; }
@@ -97,14 +81,7 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len, {u_char *start = mtd->priv; -if (to >= mtd->size) -return -EINVAL ; - -if (len > mtd->size - to) - len = mtd->size - to; -memcpy (start + to, buf, len); - *retlen = len;return 0 ; }
drivers/mtd/devices/pmc551.c +0 -38
@@ -116,16 +116,6 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)#endif end = instr->addr + instr->len -1 ; - -/* Is it past the end? */ -if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -printk (KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n" , - (long )end, (long )mtd->size); -#endif -return -EINVAL ; - } - eoff_hi = end & ~(priv->asize -1 ); soff_hi = instr->addr & ~(priv->asize -1 ); eoff_lo = end & (priv->asize -1 );
@@ -179,14 +169,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,printk (KERN_DEBUG "pmc551_point(%ld, %ld)\n" , (long )from, (long )len);#endif -if (from + len > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -printk (KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n" , - (long )from + len, (long )mtd->size); -#endif -return -EINVAL ; - } -/* can we return a physical address with this driver? */ if (phys)return -EINVAL ;
@@ -230,16 +212,6 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,#endif end = from + len -1 ; - -/* Is it past the end? */ -if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -printk (KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n" , - (long )end, (long )mtd->size); -#endif -return -EINVAL ; - } - soff_hi = from & ~(priv->asize -1 ); eoff_hi = end & ~(priv->asize -1 ); soff_lo = from & (priv->asize -1 );
@@ -297,16 +269,6 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,#endif end = to + len -1 ; -/* Is it past the end? or did the u32 wrap? */ -if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -printk (KERN_DEBUG "pmc551_write() out of bounds (end: %ld, " -"size: %ld, to: %ld)\n" , (long )end, (long )mtd->size, - (long )to); -#endif -return -EINVAL ; - } - soff_hi = to & ~(priv->asize -1 ); eoff_hi = end & ~(priv->asize -1 ); soff_lo = to & (priv->asize -1 );
drivers/mtd/devices/slram.c +0 -23
@@ -84,21 +84,13 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr) {slram_priv_t *priv = mtd->priv; -if (instr->addr + instr->len > mtd->size) { -return (-EINVAL ); - } -memset (priv->start + instr->addr,0xff , instr->len); -/* This'll catch a few races. Free the thing before returning :) * I don't feel at all ashamed. This kind of thing is possible anyway * with flash, but unlikely. */ - instr->state =MTD_ERASE_DONE ; -mtd_erase_callback (instr); -return (0 ); }
@@ -110,10 +102,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,/* can we return a physical address with this driver? */ if (phys)return -EINVAL ; - -if (from + len > mtd->size) -return -EINVAL ; - *virt = priv->start + from; *retlen = len;return (0 );
@@ -129,14 +117,7 @@ static int slram_read(struct mtd_info *mtd, loff_t from, size_t len, {slram_priv_t *priv = mtd->priv; -if (from > mtd->size) -return -EINVAL ; - -if (from + len > mtd->size) - len = mtd->size - from; -memcpy (buf, priv->start + from, len); - *retlen = len;return (0 ); }
@@ -146,11 +127,7 @@ static int slram_write(struct mtd_info *mtd, loff_t to, size_t len, {slram_priv_t *priv = mtd->priv; -if (to + len > mtd->size) -return -EINVAL ; -memcpy (priv->start + to, buf, len); - *retlen = len;return (0 ); }
drivers/mtd/devices/spear_smi.c +0 -12
@@ -512,10 +512,6 @@ static int spear_mtd_erase(struct mtd_info *mtd, struct erase_info *e_info)if (!flash || !dev)return -ENODEV ; -/* do not allow erase past end of device */ -if (e_info->addr + e_info->len > flash->mtd.size) -return -EINVAL ; - bank = flash->bank;if (bank > dev->num_flashes -1 ) {dev_err (&dev->pdev->dev,"Invalid Bank Num" );
@@ -575,10 +571,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,if (!flash || !dev)return -ENODEV ; -/* do not allow reads past end of device */ -if (from + len > flash->mtd.size) -return -EINVAL ; -if (flash->bank > dev->num_flashes -1 ) {dev_err (&dev->pdev->dev,"Invalid Bank Num" );return -EINVAL ;
@@ -680,10 +672,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,if (!len)return 0 ; -/* do not allow write past end of page */ -if (to + len > flash->mtd.size) -return -EINVAL ; -if (flash->bank > dev->num_flashes -1 ) {dev_err (&dev->pdev->dev,"Invalid Bank Num" );return -EINVAL ;
drivers/mtd/devices/sst25l.c +0 -9
@@ -175,9 +175,6 @@ static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr)int err;/* Sanity checks */ -if (instr->addr + instr->len > flash->mtd.size) -return -EINVAL ; -if ((uint32_t )instr->len % mtd->erasesize)return -EINVAL ;
@@ -227,9 +224,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len,if (len ==0 )return 0 ; -if (from + len > flash->mtd.size) -return -EINVAL ; -if (retlen) *retlen =0 ;
@@ -278,9 +272,6 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len,if (!len)return 0 ; -if (to + len > flash->mtd.size) -return -EINVAL ; -if ((uint32_t )to % mtd->writesize)return -EINVAL ;
drivers/mtd/lpddr/lpddr_cmds.c +1 -4
@@ -530,7 +530,7 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,struct flchip *chip = &lpddr->chips[chipnum];int ret =0 ; -if (!map->virt || (adr + len > mtd->size)) +if (!map->virt)return -EINVAL ;/* ofs: offset within the first chip that the first read should start */
@@ -692,9 +692,6 @@ static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr) ofs = instr->addr; len = instr->len; -if (ofs > mtd->size || (len + ofs) > mtd->size) -return -EINVAL ; -while (len >0 ) { ret =do_erase_oneblock (mtd, ofs);if (ret)
drivers/mtd/mtdconcat.c +0 -26
@@ -185,10 +185,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,for (i =0 ; i < count; i++) total_len += vecs[i].iov_len; -/* Do not allow write past end of device */ -if ((to + total_len) > mtd->size) -return -EINVAL ; -/* Check alignment */ if (mtd->writesize >1 ) {uint64_t __to = to;
@@ -406,12 +402,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; -if (instr->addr > concat->mtd.size) -return -EINVAL ; - -if (instr->len + instr->addr > concat->mtd.size) -return -EINVAL ; -/* * Check for proper erase block alignment of the to-be-erased area. * It is easier to do this based on the super device's erase
@@ -538,9 +528,6 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)struct mtd_concat *concat =CONCAT (mtd);int i, err = -EINVAL ; -if ((len + ofs) > mtd->size) -return -EINVAL ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];uint64_t size;
@@ -575,9 +562,6 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)struct mtd_concat *concat =CONCAT (mtd);int i, err =0 ; -if ((len + ofs) > mtd->size) -return -EINVAL ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];uint64_t size;
@@ -650,9 +634,6 @@ static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs)if (!mtd_can_have_bb (concat->subdev[0 ]))return res; -if (ofs > mtd->size) -return -EINVAL ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];
@@ -673,9 +654,6 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)struct mtd_concat *concat =CONCAT (mtd);int i, err = -EINVAL ; -if (ofs > mtd->size) -return -EINVAL ; -for (i =0 ; i < concat->num_subdev; i++) {struct mtd_info *subdev = concat->subdev[i];
@@ -713,10 +691,6 @@ static unsigned long concat_get_unmapped_area(struct mtd_info *mtd,continue ; } -/* we've found the subdev over which the mapping will reside */ -if (offset + len > subdev->size) -return (unsigned long ) -EINVAL ; -return mtd_get_unmapped_area (subdev, len, offset, flags); }
drivers/mtd/mtdpart.c +1 -29
@@ -65,11 +65,6 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len,int res; stats = part->master->ecc_stats; - -if (from >= mtd->size) - len =0 ; -else if (from + len > mtd->size) - len = mtd->size - from; res =mtd_read (part->master, from + part->offset, len, retlen, buf);if (unlikely (res)) {if (mtd_is_bitflip (res))
@@ -84,10 +79,7 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys) { struct mtd_part *part = PART(mtd); -if (from >= mtd->size) - len =0 ; -else if (from + len > mtd->size) - len = mtd->size - from; +return mtd_point (part->master, from + part->offset, len, retlen, virt, phys); }
@@ -182,10 +174,6 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len,struct mtd_part *part =PART (mtd);if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; -if (to >= mtd->size) - len =0 ; -else if (to + len > mtd->size) - len = mtd->size - to;return mtd_write (part->master, to + part->offset, len, retlen, buf); }
@@ -195,10 +183,6 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,struct mtd_part *part =PART (mtd);if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; -if (to >= mtd->size) - len =0 ; -else if (to + len > mtd->size) - len = mtd->size - to;return mtd_panic_write (part->master, to + part->offset, len, retlen, buf); }
@@ -248,8 +232,6 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr)int ret;if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; -if (instr->addr >= mtd->size) -return -EINVAL ; instr->addr += part->offset; ret =mtd_erase (part->master, instr);if (ret) {
@@ -277,24 +259,18 @@ EXPORT_SYMBOL_GPL(mtd_erase_callback);static int part_lock (struct mtd_info *mtd,loff_t ofs,uint64_t len) {struct mtd_part *part =PART (mtd); -if ((len + ofs) > mtd->size) -return -EINVAL ;return mtd_lock (part->master, ofs + part->offset, len); }static int part_unlock (struct mtd_info *mtd,loff_t ofs,uint64_t len) {struct mtd_part *part =PART (mtd); -if ((len + ofs) > mtd->size) -return -EINVAL ;return mtd_unlock (part->master, ofs + part->offset, len); }static int part_is_locked (struct mtd_info *mtd,loff_t ofs,uint64_t len) {struct mtd_part *part =PART (mtd); -if ((len + ofs) > mtd->size) -return -EINVAL ;return mtd_is_locked (part->master, ofs + part->offset, len); }
@@ -319,8 +295,6 @@ static void part_resume(struct mtd_info *mtd)static int part_block_isbad (struct mtd_info *mtd,loff_t ofs) {struct mtd_part *part =PART (mtd); -if (ofs >= mtd->size) -return -EINVAL ; ofs += part->offset;return mtd_block_isbad (part->master, ofs); }
@@ -332,8 +306,6 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; -if (ofs >= mtd->size) -return -EINVAL ; ofs += part->offset; res =mtd_block_markbad (part->master, ofs);if (!res)
drivers/mtd/nand/nand_base.c +0 -28
@@ -123,12 +123,6 @@ static int check_offs_len(struct mtd_info *mtd, ret = -EINVAL ; } -/* Do not allow past end of device */ -if (ofs + len > mtd->size) { -pr_debug ("%s: past end of device\n" , __func__); - ret = -EINVAL ; - } -return ret; }
@@ -1620,25 +1614,17 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,struct mtd_oob_ops ops;int ret; -/* Do not allow reads past end of device */ -if ((from + len) > mtd->size) -return -EINVAL ;if (!len)return 0 ;nand_get_device (chip, mtd,FL_READING ); - ops.len = len; ops.datbuf = buf; ops.oobbuf =NULL ; ops.mode =0 ; - ret =nand_do_read_ops (mtd, from, &ops); - *retlen = ops.retlen; -nand_release_device (mtd); -return ret; }
@@ -2328,8 +2314,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,int ret;/* Do not allow reads past end of device */ -if ((to + len) > mtd->size) -return -EINVAL ;if (!len)return 0 ;
@@ -2367,25 +2351,17 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,struct mtd_oob_ops ops;int ret; -/* Do not allow reads past end of device */ -if ((to + len) > mtd->size) -return -EINVAL ;if (!len)return 0 ;nand_get_device (chip, mtd,FL_WRITING ); - ops.len = len; ops.datbuf = (uint8_t *)buf; ops.oobbuf =NULL ; ops.mode =0 ; - ret =nand_do_write_ops (mtd, to, &ops); - *retlen = ops.retlen; -nand_release_device (mtd); -return ret; }
@@ -2749,10 +2725,6 @@ static void nand_sync(struct mtd_info *mtd)*/ static int nand_block_isbad (struct mtd_info *mtd,loff_t offs) { -/* Check for invalid offset */ -if (offs > mtd->size) -return -EINVAL ; -return nand_block_checkbad (mtd, offs,1 ,0 ); }
drivers/mtd/onenand/onenand_base.c +0 -20
@@ -1756,13 +1756,6 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,/* Initialize retlen, in case of early exit */ *retlen =0 ; -/* Do not allow writes past end of device */ -if (unlikely ((to + len) > mtd->size)) { -printk (KERN_ERR "%s: Attempt write to past end of device\n" , - __func__); -return -EINVAL ; - } -/* Reject writes, which are not page aligned */ if (unlikely (NOTALIGNED (to) ||NOTALIGNED (len))) { printk(KERN_ERR "%s: Attempt to write not page aligned data\n",
@@ -1890,13 +1883,6 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to, ops->retlen =0 ; ops->oobretlen =0 ; -/* Do not allow writes past end of device */ -if (unlikely ((to + len) > mtd->size)) { -printk (KERN_ERR "%s: Attempt write to past end of device\n" , - __func__); -return -EINVAL ; - } -/* Reject writes, which are not page aligned */ if (unlikely (NOTALIGNED (to) ||NOTALIGNED (len))) { printk(KERN_ERR "%s: Attempt to write not page aligned data\n",
@@ -2493,12 +2479,6 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) (unsigned long long )instr->addr, (unsigned long long)instr->len); -/* Do not allow erase past end of device */ -if (unlikely ((len + addr) > mtd->size)) { -printk (KERN_ERR "%s: Erase past end of device\n" , __func__); -return -EINVAL ; - } -if (FLEXONENAND (this)) {/* Find the eraseregion of this address */ int i =flexonenand_region (mtd, addr);
drivers/mtd/ubi/gluebi.c +0 -11
@@ -174,11 +174,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,int err =0 , lnum, offs, total_read;struct gluebi_device *gluebi; -if (len <0 || from <0 || from + len > mtd->size) -return -EINVAL ; - gluebi = container_of(mtd, struct gluebi_device, mtd); - lnum =div_u64_rem (from, mtd->erasesize, &offs); total_read = len;while (total_read) {
@@ -218,9 +214,6 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,int err =0 , lnum, offs, total_written;struct gluebi_device *gluebi; -if (len <0 || to <0 || len + to > mtd->size) -return -EINVAL ; - gluebi = container_of(mtd, struct gluebi_device, mtd);if (!(mtd->flags &MTD_WRITEABLE ))
@@ -265,10 +258,6 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)int err, i, lnum, count;struct gluebi_device *gluebi; -if (instr->addr <0 || instr->addr > mtd->size - mtd->erasesize) -return -EINVAL ; -if (instr->len <0 || instr->addr + instr->len > mtd->size) -return -EINVAL ;if (mtd_mod_by_ws (instr->addr, mtd) ||mtd_mod_by_ws (instr->len, mtd))return -EINVAL ;
Signature · 1 line
1.7.9
PATCH 6/9 mtd: remove junk pmc551.h
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
This header is tiny and contains only pmc551-private stuff, so it should not live in 'include/linux' - let's just merge it with pmc551.c.
--- drivers/mtd/devices/pmc551.c | 40 ++++++++++++++++++++- include/linux/mtd/pmc551.h | 77 ------------------------------------------ 2 files changed, 38 insertions(+), 79 deletions(-) delete mode 100644 include/linux/mtd/pmc551.h
drivers/mtd/devices/pmc551.c +38 -2
@@ -95,12 +95,48 @@#include <asm/io.h> #include <asm/system.h> #include <linux/pci.h> -#include <linux/mtd/mtd.h> -#include <linux/mtd/pmc551.h> + +#define PMC551_VERSION \ + "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n" + +#define PCI_VENDOR_ID_V3_SEMI 0x11b0 +#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200 + +#define PMC551_PCI_MEM_MAP0 0x50 +#define PMC551_PCI_MEM_MAP1 0x54 +#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000 +#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0 +#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002 +#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001 + +#define PMC551_SDRAM_MA 0x60 +#define PMC551_SDRAM_CMD 0x62 +#define PMC551_DRAM_CFG 0x64 +#define PMC551_SYS_CTRL_REG 0x78 + +#define PMC551_DRAM_BLK0 0x68 +#define PMC551_DRAM_BLK1 0x6c +#define PMC551_DRAM_BLK2 0x70 +#define PMC551_DRAM_BLK3 0x74 +#define PMC551_DRAM_BLK_GET_SIZE (x) (524288 << ((x >> 4) & 0x0f)) +#define PMC551_DRAM_BLK_SET_COL_MUX (x, v) (((x) & ~0x00007000) | (((v) & 0x7) << 12)) +#define PMC551_DRAM_BLK_SET_ROW_MUX (x, v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8)) + +struct mypriv { +struct pci_dev *dev; +u_char *start; +u32 base_map0; +u32 curr_map0; +u32 asize; +struct mtd_info *nextpmc551; +};static struct mtd_info *pmc551list; +static int pmc551_point (struct mtd_info *mtd,loff_t from,size_t len, +size_t *retlen,void **virt,resource_size_t *phys); +static int pmc551_erase (struct mtd_info *mtd,struct erase_info *instr) {struct mypriv *priv = mtd->priv;
include/linux/mtd/pmc551.h deleted +0 -77
77 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 7/9 mtd: harmonize mtd_point interface implementation
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
Some MTD drivers return -EINVAL if the 'phys' parameter is not NULL, trying to convey that they cannot return the physical address. However, this is not very logical because they still can return the virtual address ('virt'). But some drivers (lpddr) just ignore the 'phys' parameter instead, which is a more logical thing to do.
Let's harmonize this and:
1. Always initialize 'virt' and 'phys' to 'NULL' in 'mtd_point()'.
2. Do not return an error if the physical address cannot be found.
So as a result, all drivers will set 'phys' to 'NULL' if it is not supported. None of the 'mtd_point()' users use 'phys' anyway, so this should not break anything. I guess we could also just delete this parameter later.
--- drivers/mtd/devices/mtdram.c | 3 --- drivers/mtd/devices/phram.c | 4 ---- drivers/mtd/devices/pmc551.c | 4 ---- drivers/mtd/devices/slram.c | 3 --- drivers/mtd/mtdcore.c | 3 +++ 5 files changed, 3 insertions(+), 14 deletions(-)
drivers/mtd/devices/mtdram.c +0 -3
@@ -43,9 +43,6 @@ static int ram_erase(struct mtd_info *mtd, struct erase_info *instr)static int ram_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys) { -/* can we return a physical address with this driver? */ -if (phys) -return -EINVAL ; *virt = mtd->priv + from; *retlen = len;return 0 ;
drivers/mtd/devices/phram.c +0 -4
@@ -51,10 +51,6 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)static int phram_point (struct mtd_info *mtd,loff_t from,size_t len,size_t *retlen,void **virt,resource_size_t *phys) { -/* can we return a physical address with this driver? */ -if (phys) -return -EINVAL ; - *virt = mtd->priv + from; *retlen = len;return 0 ;
drivers/mtd/devices/pmc551.c +0 -4
@@ -205,10 +205,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,printk (KERN_DEBUG "pmc551_point(%ld, %ld)\n" , (long )from, (long )len);#endif -/* can we return a physical address with this driver? */ -if (phys) -return -EINVAL ; - soff_hi = from & ~(priv->asize -1 ); soff_lo = from & (priv->asize -1 );
drivers/mtd/devices/slram.c +0 -3
@@ -99,9 +99,6 @@ static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, {slram_priv_t *priv = mtd->priv; -/* can we return a physical address with this driver? */ -if (phys) -return -EINVAL ; *virt = priv->start + from; *retlen = len;return (0 );
drivers/mtd/mtdcore.c +3 -0
@@ -706,6 +706,9 @@ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys) { *retlen =0 ; + *virt =NULL ; +if (phys) + *phys =0 ;if (!mtd->_point)return -EOPNOTSUPP ;if (from <0 || from > mtd->size || len > mtd->size - from)
Signature · 1 line
1.7.9
PATCH 8/9 mtd: move zero length verification to MTD API functions
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
In many places in drivers we verify for the zero length, but this is very inconsistent across drivers. This is obviously the right thing to do, though. This patch moves the check to the MTD API functions instead and removes a lot of duplication.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 3 --- drivers/mtd/chips/cfi_cmdset_0002.c | 9 --------- drivers/mtd/chips/cfi_cmdset_0020.c | 3 --- drivers/mtd/devices/block2mtd.c | 3 --- drivers/mtd/devices/lart.c | 3 --- drivers/mtd/devices/m25p80.c | 12 ------------ drivers/mtd/devices/mtd_dataflash.c | 10 ---------- drivers/mtd/devices/spear_smi.c | 6 ------ drivers/mtd/devices/sst25l.c | 8 -------- drivers/mtd/lpddr/lpddr_cmds.c | 1 - drivers/mtd/maps/vmu-flash.c | 8 -------- drivers/mtd/mtdcore.c | 21 +++++++++++++++++++++ drivers/mtd/nand/nand_base.c | 10 ---------- 13 files changed, 21 insertions(+), 76 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +0 -3
@@ -1566,9 +1566,6 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t leint chipnum;unsigned long ofs; -if (!len) -return 0 ; - chipnum = to >> cfi->chipshift; ofs = to - (chipnum << cfi->chipshift);
drivers/mtd/chips/cfi_cmdset_0002.c +0 -9
@@ -1246,9 +1246,6 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,unsigned long ofs, chipstart;DECLARE_WAITQUEUE (wait, current); -if (!len) -return 0 ; - chipnum = to >> cfi->chipshift; ofs = to - (chipnum << cfi->chipshift); chipstart = cfi->chips[chipnum].start;
@@ -1487,9 +1484,6 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,int chipnum;unsigned long ofs; -if (!len) -return 0 ; - chipnum = to >> cfi->chipshift; ofs = to - (chipnum << cfi->chipshift);
@@ -1697,9 +1691,6 @@ static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,int ret =0 ;int chipnum; -if (!len) -return 0 ; - chipnum = to >> cfi->chipshift; ofs = to - (chipnum << cfi->chipshift); chipstart = cfi->chips[chipnum].start;
drivers/mtd/chips/cfi_cmdset_0020.c +0 -3
@@ -615,9 +615,6 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,int chipnum;unsigned long ofs; -if (!len) -return 0 ; - chipnum = to >> cfi->chipshift; ofs = to - (chipnum << cfi->chipshift);
drivers/mtd/devices/block2mtd.c +0 -3
@@ -178,9 +178,6 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,struct block2mtd_dev *dev = mtd->priv;int err; -if (!len) -return 0 ; -mutex_lock (&dev->write_mutex); err =_block2mtd_write (dev, buf, to, len, retlen);mutex_unlock (&dev->write_mutex);
drivers/mtd/devices/lart.c +0 -3
@@ -437,9 +437,6 @@ static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retleprintk (KERN_DEBUG "%s(from = 0x%.8x, len = %d)\n" , __func__, (__u32 )from, len);#endif -/* sanity checks */ -if (!len)return (0 ); -/* we always read len bytes */ *retlen = len;
drivers/mtd/devices/m25p80.c +0 -12
@@ -346,10 +346,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,pr_debug ("%s: %s from 0x%08x, len %zd\n" ,dev_name (&flash->spi->dev), __func__, (u32 )from, len); -/* sanity checks */ -if (!len) -return 0 ; -spi_message_init (&m);memset (t,0 , (sizeof t));
@@ -408,10 +404,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: %s to 0x%08x, len %zd\n" ,dev_name (&flash->spi->dev), __func__, (u32 )to, len); -/* sanity checks */ -if (!len) -return (0 ); -spi_message_init (&m);memset (t,0 , (sizeof t));
@@ -495,10 +487,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: %s to 0x%08x, len %zd\n" ,dev_name (&flash->spi->dev), __func__, (u32 )to, len); -/* sanity checks */ -if (!len) -return 0 ; -spi_message_init (&m);memset (t,0 , (sizeof t));
drivers/mtd/devices/mtd_dataflash.c +0 -10
@@ -249,10 +249,6 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,pr_debug ("%s: read 0x%x..0x%x\n" ,dev_name (&priv->spi->dev), (unsigned )from, (unsigned )(from + len)); -/* Sanity checks */ -if (!len) -return 0 ; -/* Calculate flash page/byte address */ addr = (((unsigned )from / priv->page_size) << priv->page_offset) + ((unsigned )from % priv->page_size);
@@ -321,10 +317,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,pr_debug ("%s: write 0x%x..0x%x\n" ,dev_name (&spi->dev), (unsigned )to, (unsigned )(to + len)); -/* Sanity checks */ -if (!len) -return 0 ; -spi_message_init (&msg); x[0 ].tx_buf = command = priv->command;
@@ -479,8 +471,6 @@ static ssize_t otp_read(struct spi_device *spi, unsigned base,if ((off + len) >64 ) len =64 - off; -if (len ==0 ) -return len;spi_message_init (&m);
drivers/mtd/devices/spear_smi.c +0 -6
@@ -565,9 +565,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,u32 ctrlreg1, val;int ret; -if (!len) -return 0 ; -if (!flash || !dev)return -ENODEV ;
@@ -664,9 +661,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,if (!flash || !dev)return -ENODEV ; -if (!len) -return 0 ; -if (flash->bank > dev->num_flashes -1 ) {dev_err (&dev->pdev->dev,"Invalid Bank Num" );return -EINVAL ;
drivers/mtd/devices/sst25l.c +0 -8
@@ -220,10 +220,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len,unsigned char command[4 ];int ret; -/* Sanity checking */ -if (len ==0 ) -return 0 ; -spi_message_init (&message);memset (&transfer,0 ,sizeof (transfer));
@@ -265,10 +261,6 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len,int i, j, ret, bytes, copied =0 ;unsigned char command[5 ]; -/* Sanity checks */ -if (!len) -return 0 ; -if ((uint32_t )to % mtd->writesize)return -EINVAL ;
drivers/mtd/lpddr/lpddr_cmds.c +0 -1
@@ -639,7 +639,6 @@ static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,int chipnum;unsigned long ofs, vec_seek, i;int wbufsize =1 << lpddr->qinfo->BufSizeShift; -size_t len =0 ;for (i =0 ; i < count; i++)
drivers/mtd/maps/vmu-flash.c +0 -8
@@ -360,9 +360,6 @@ static int vmu_flash_read(struct mtd_info *mtd, loff_t from, size_t len,int index =0 , retval, partition, leftover, numblocks;unsigned char cx; -if (len <1 ) -return -EIO ; - mpart = mtd->priv; mdev = mpart->mdev; partition = mpart->partition;
@@ -434,11 +431,6 @@ static int vmu_flash_write(struct mtd_info *mtd, loff_t to, size_t len, partition = mpart->partition; card =maple_get_drvdata (mdev); -/* simple sanity checks */ -if (len <1 ) { - error = -EIO ; - goto failed; - } numblocks = card->parts[partition].numblocks;if (to + len > numblocks * card->blocklen) len = numblocks * card->blocklen - to;
drivers/mtd/mtdcore.c +21 -0
@@ -695,6 +695,11 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)return -EINVAL ;if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; +if (!instr->len) { + instr->state =MTD_ERASE_DONE ; +mtd_erase_callback (instr); +return 0 ; + }return mtd->_erase (mtd, instr); }EXPORT_SYMBOL_GPL (mtd_erase);
@@ -713,6 +718,8 @@ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,return -EOPNOTSUPP ;if (from <0 || from > mtd->size || len > mtd->size - from)return -EINVAL ; +if (!len) +return 0 ;return mtd->_point (mtd, from, len, retlen, virt, phys); }EXPORT_SYMBOL_GPL (mtd_point);
@@ -724,6 +731,8 @@ int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len)return -EOPNOTSUPP ;if (from <0 || from > mtd->size || len > mtd->size - from)return -EINVAL ; +if (!len) +return 0 ;return mtd->_unpoint (mtd, from, len); }EXPORT_SYMBOL_GPL (mtd_unpoint);
@@ -750,6 +759,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, *retlen =0 ;if (from <0 || from > mtd->size || len > mtd->size - from)return -EINVAL ; +if (!len) +return 0 ;return mtd->_read (mtd, from, len, retlen, buf); }EXPORT_SYMBOL_GPL (mtd_read);
@@ -762,6 +773,8 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,return -EINVAL ;if (!mtd->_write || !(mtd->flags &MTD_WRITEABLE ))return -EROFS ; +if (!len) +return 0 ;return mtd->_write (mtd, to, len, retlen, buf); }EXPORT_SYMBOL_GPL (mtd_write);
@@ -783,6 +796,8 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,return -EINVAL ;if (!(mtd->flags &MTD_WRITEABLE ))return -EROFS ; +if (!len) +return 0 ;return mtd->_panic_write (mtd, to, len, retlen, buf); }EXPORT_SYMBOL_GPL (mtd_panic_write);
@@ -794,6 +809,8 @@ int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)return -EOPNOTSUPP ;if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs)return -EINVAL ; +if (!len) +return 0 ;return mtd->_lock (mtd, ofs, len); }EXPORT_SYMBOL_GPL (mtd_lock);
@@ -804,6 +821,8 @@ int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)return -EOPNOTSUPP ;if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs)return -EINVAL ; +if (!len) +return 0 ;return mtd->_unlock (mtd, ofs, len); }EXPORT_SYMBOL_GPL (mtd_unlock);
@@ -814,6 +833,8 @@ int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)return -EOPNOTSUPP ;if (ofs <0 || ofs > mtd->size || len > mtd->size - ofs)return -EINVAL ; +if (!len) +return 0 ;return mtd->_is_locked (mtd, ofs, len); }EXPORT_SYMBOL_GPL (mtd_is_locked);
drivers/mtd/nand/nand_base.c +0 -10
@@ -1614,9 +1614,6 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,struct mtd_oob_ops ops;int ret; -if (!len) -return 0 ; -nand_get_device (chip, mtd,FL_READING ); ops.len = len; ops.datbuf = buf;
@@ -2313,10 +2310,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,struct mtd_oob_ops ops;int ret; -/* Do not allow reads past end of device */ -if (!len) -return 0 ; -/* Wait for the device to get ready */ panic_nand_wait (mtd, chip,400 );
@@ -2351,9 +2344,6 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,struct mtd_oob_ops ops;int ret; -if (!len) -return 0 ; -nand_get_device (chip, mtd,FL_WRITING ); ops.len = len; ops.datbuf = (uint8_t *)buf;
Signature · 1 line
1.7.9
PATCH 9/9 mtd: check for zero length in OTP functions
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
This patch changes all the OTP functions like 'mtd_get_fact_prot_info()' and makes them return zero immediately if the input 'len' parameter is 0. This is not really needed currently, but most of the other functions do this, and it is just consistent to do the same in the OTP functions.
This patch also moves the OTP functions from the header file to mtdcore.c because they become a bit too big for being inlined.
--- drivers/mtd/mtdcore.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mtd/mtd.h | 70 +++++++-------------------------------------- 2 files changed, 84 insertions(+), 59 deletions(-)
drivers/mtd/mtdcore.c +73 -0
@@ -802,6 +802,79 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, }EXPORT_SYMBOL_GPL (mtd_panic_write); +/* +* Method to access the protection register area, present in some flash +* devices. The user data is one time programmable but the factory data is read +* only. +*/ +int mtd_get_fact_prot_info (struct mtd_info *mtd,struct otp_info *buf, +size_t len) +{ +if (!mtd->_get_fact_prot_info) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_get_fact_prot_info (mtd, buf, len); +} +EXPORT_SYMBOL_GPL (mtd_get_fact_prot_info); + +int mtd_read_fact_prot_reg (struct mtd_info *mtd,loff_t from,size_t len, +size_t *retlen,u_char *buf) +{ + *retlen =0 ; +if (!mtd->_read_fact_prot_reg) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_read_fact_prot_reg (mtd, from, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_read_fact_prot_reg); + +int mtd_get_user_prot_info (struct mtd_info *mtd,struct otp_info *buf, +size_t len) +{ +if (!mtd->_get_user_prot_info) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_get_user_prot_info (mtd, buf, len); +} +EXPORT_SYMBOL_GPL (mtd_get_user_prot_info); + +int mtd_read_user_prot_reg (struct mtd_info *mtd,loff_t from,size_t len, +size_t *retlen,u_char *buf) +{ + *retlen =0 ; +if (!mtd->_read_user_prot_reg) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_read_user_prot_reg (mtd, from, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_read_user_prot_reg); + +int mtd_write_user_prot_reg (struct mtd_info *mtd,loff_t to,size_t len, +size_t *retlen,u_char *buf) +{ + *retlen =0 ; +if (!mtd->_write_user_prot_reg) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_write_user_prot_reg (mtd, to, len, retlen, buf); +} +EXPORT_SYMBOL_GPL (mtd_write_user_prot_reg); + +int mtd_lock_user_prot_reg (struct mtd_info *mtd,loff_t from,size_t len) +{ +if (!mtd->_lock_user_prot_reg) +return -EOPNOTSUPP ; +if (!len) +return 0 ; +return mtd->_lock_user_prot_reg (mtd, from, len); +} +EXPORT_SYMBOL_GPL (mtd_lock_user_prot_reg); +/* Chip-supported device locking */ int mtd_lock (struct mtd_info *mtd,loff_t ofs,uint64_t len) {
include/linux/mtd/mtd.h +11 -59
76 lines not on this page · raw message
Signature · 1 line
1.7.9
Quoted 3 lines · Artem Bityutskiy
here are the latest MTD API rework patches. I have plans to also harmonize the OOB-related functions, try to harmonize alignment checking in erase and write functions as well. Not sure I'll have time for this, though, will see.
I forgot this:
drivers/mtd/chips/cfi_cmdset_0001.c | 26 ++-- drivers/mtd/chips/cfi_cmdset_0002.c | 21 --- drivers/mtd/chips/cfi_cmdset_0020.c | 15 -- drivers/mtd/chips/cfi_util.c | 6 - drivers/mtd/chips/map_absent.c | 2 - drivers/mtd/chips/map_ram.c | 4 - drivers/mtd/chips/map_rom.c | 3 +- drivers/mtd/devices/block2mtd.c | 17 --- drivers/mtd/devices/doc2000.c | 12 -- drivers/mtd/devices/doc2001.c | 9 -- drivers/mtd/devices/doc2001plus.c | 9 -- drivers/mtd/devices/lart.c | 10 -- drivers/mtd/devices/m25p80.c | 31 ----- drivers/mtd/devices/ms02-nv.c | 8 - drivers/mtd/devices/mtd_dataflash.c | 21 --- drivers/mtd/devices/mtdram.c | 23 +--- drivers/mtd/devices/phram.c | 33 +----- drivers/mtd/devices/pmc551.c | 85 ++++++------ drivers/mtd/devices/slram.c | 31 +---- drivers/mtd/devices/spear_smi.c | 28 ---- drivers/mtd/devices/sst25l.c | 20 --- drivers/mtd/lpddr/lpddr_cmds.c | 21 ++-- drivers/mtd/maps/vmu-flash.c | 8 - drivers/mtd/mtdconcat.c | 59 +-------- drivers/mtd/mtdcore.c | 254 +++++++++++++++++++++++++++++++++++ drivers/mtd/mtdpart.c | 48 +------ drivers/mtd/nand/nand_base.c | 38 ----- drivers/mtd/onenand/onenand_base.c | 23 --- drivers/mtd/ubi/gluebi.c | 19 --- include/linux/mtd/mtd.h | 201 +++++----------------------- include/linux/mtd/pmc551.h | 78 ----------- 31 files changed, 360 insertions(+), 803 deletions(-)
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 1 line · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
...zip..
Quoted 3 lines
Please, do test the changes if you use MTD - it is easy to break something when you are trying to clean-up ancient crap.
Hi Artem,
Just a note to let you know I tested these patches with the docg3, and everything is alright. Of course, docg3 is less impacted than others, but still read/write/erase do work, on an UBIFS mounted filesystem (which tends to proove things do work, don't it ?)
Cheers.
Signature · 1 line
Robert
Quoted 2 lines · Robert Jarzmik
Just a note to let you know I tested these patches with the docg3, and everything is alright.
Thanks for letting me know!
Signature · 2 lines
Best Regards, Artem Bityutskiy