diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-30 20:31:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-30 20:31:56 -0400 |
commit | 623ff7739e7c00fa3d55dbfd42a492a68298fd7a (patch) | |
tree | 0b7461753a1b13b27ea2958a7d48c6efb47bba54 /drivers/mtd/ubi | |
parent | c39e8ede284f469971589f2e04af78216e1a771d (diff) | |
parent | 7b0e67f604e1829e5292e1ad7743eb18dc42ea7c (diff) |
Merge tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6
Pull MTD changes from David Woodhouse:
- Artem's cleanup of the MTD API continues apace.
- Fixes and improvements for ST FSMC and SuperH FLCTL NAND, amongst
others.
- More work on DiskOnChip G3, new driver for DiskOnChip G4.
- Clean up debug/warning printks in JFFS2 to use pr_<level>.
Fix up various trivial conflicts, largely due to changes in calling
conventions for things like dmaengine_prep_slave_sg() (new inline
wrapper to hide new parameter, clashing with rewrite of previously last
parameter that used to be an 'append' flag, and is now a bitmap of
'unsigned long flags').
(Also some header file fallout - like so many merges this merge window -
and silly conflicts with sparse fixes)
* tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6: (120 commits)
mtd: docg3 add protection against concurrency
mtd: docg3 refactor cascade floors structure
mtd: docg3 increase write/erase timeout
mtd: docg3 fix inbound calculations
mtd: nand: gpmi: fix function annotations
mtd: phram: fix section mismatch for phram_setup
mtd: unify initialization of erase_info->fail_addr
mtd: support ONFI multi lun NAND
mtd: sm_ftl: fix typo in major number.
mtd: add device-tree support to spear_smi
mtd: spear_smi: Remove default partition information from driver
mtd: Add device-tree support to fsmc_nand
mtd: fix section mismatch for doc_probe_device
mtd: nand/fsmc: Remove sparse warnings and errors
mtd: nand/fsmc: Add DMA support
mtd: nand/fsmc: Access the NAND device word by word whenever possible
mtd: nand/fsmc: Use dev_err to report error scenario
mtd: nand/fsmc: Use devm routines
mtd: nand/fsmc: Modify fsmc driver to accept nand timing parameters via platform
mtd: fsmc_nand: add pm callbacks to support hibernation
...
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r-- | drivers/mtd/ubi/gluebi.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c index 941bc3c05d6e..90b98822d9a4 100644 --- a/drivers/mtd/ubi/gluebi.c +++ b/drivers/mtd/ubi/gluebi.c | |||
@@ -174,11 +174,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
174 | int err = 0, lnum, offs, total_read; | 174 | int err = 0, lnum, offs, total_read; |
175 | struct gluebi_device *gluebi; | 175 | struct gluebi_device *gluebi; |
176 | 176 | ||
177 | if (len < 0 || from < 0 || from + len > mtd->size) | ||
178 | return -EINVAL; | ||
179 | |||
180 | gluebi = container_of(mtd, struct gluebi_device, mtd); | 177 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
181 | |||
182 | lnum = div_u64_rem(from, mtd->erasesize, &offs); | 178 | lnum = div_u64_rem(from, mtd->erasesize, &offs); |
183 | total_read = len; | 179 | total_read = len; |
184 | while (total_read) { | 180 | while (total_read) { |
@@ -218,14 +214,7 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
218 | int err = 0, lnum, offs, total_written; | 214 | int err = 0, lnum, offs, total_written; |
219 | struct gluebi_device *gluebi; | 215 | struct gluebi_device *gluebi; |
220 | 216 | ||
221 | if (len < 0 || to < 0 || len + to > mtd->size) | ||
222 | return -EINVAL; | ||
223 | |||
224 | gluebi = container_of(mtd, struct gluebi_device, mtd); | 217 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
225 | |||
226 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
227 | return -EROFS; | ||
228 | |||
229 | lnum = div_u64_rem(to, mtd->erasesize, &offs); | 218 | lnum = div_u64_rem(to, mtd->erasesize, &offs); |
230 | 219 | ||
231 | if (len % mtd->writesize || offs % mtd->writesize) | 220 | if (len % mtd->writesize || offs % mtd->writesize) |
@@ -265,21 +254,13 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
265 | int err, i, lnum, count; | 254 | int err, i, lnum, count; |
266 | struct gluebi_device *gluebi; | 255 | struct gluebi_device *gluebi; |
267 | 256 | ||
268 | if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) | ||
269 | return -EINVAL; | ||
270 | if (instr->len < 0 || instr->addr + instr->len > mtd->size) | ||
271 | return -EINVAL; | ||
272 | if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) | 257 | if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) |
273 | return -EINVAL; | 258 | return -EINVAL; |
274 | 259 | ||
275 | lnum = mtd_div_by_eb(instr->addr, mtd); | 260 | lnum = mtd_div_by_eb(instr->addr, mtd); |
276 | count = mtd_div_by_eb(instr->len, mtd); | 261 | count = mtd_div_by_eb(instr->len, mtd); |
277 | |||
278 | gluebi = container_of(mtd, struct gluebi_device, mtd); | 262 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
279 | 263 | ||
280 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
281 | return -EROFS; | ||
282 | |||
283 | for (i = 0; i < count - 1; i++) { | 264 | for (i = 0; i < count - 1; i++) { |
284 | err = ubi_leb_unmap(gluebi->desc, lnum + i); | 265 | err = ubi_leb_unmap(gluebi->desc, lnum + i); |
285 | if (err) | 266 | if (err) |
@@ -340,11 +321,11 @@ static int gluebi_create(struct ubi_device_info *di, | |||
340 | mtd->owner = THIS_MODULE; | 321 | mtd->owner = THIS_MODULE; |
341 | mtd->writesize = di->min_io_size; | 322 | mtd->writesize = di->min_io_size; |
342 | mtd->erasesize = vi->usable_leb_size; | 323 | mtd->erasesize = vi->usable_leb_size; |
343 | mtd->read = gluebi_read; | 324 | mtd->_read = gluebi_read; |
344 | mtd->write = gluebi_write; | 325 | mtd->_write = gluebi_write; |
345 | mtd->erase = gluebi_erase; | 326 | mtd->_erase = gluebi_erase; |
346 | mtd->get_device = gluebi_get_device; | 327 | mtd->_get_device = gluebi_get_device; |
347 | mtd->put_device = gluebi_put_device; | 328 | mtd->_put_device = gluebi_put_device; |
348 | 329 | ||
349 | /* | 330 | /* |
350 | * In case of dynamic a volume, MTD device size is just volume size. In | 331 | * In case of dynamic a volume, MTD device size is just volume size. In |