diff options
Diffstat (limited to 'drivers/mtd/mtdpart.c')
-rw-r--r-- | drivers/mtd/mtdpart.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index da8a0b28316c..fbe2c8a22e1c 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -65,11 +65,6 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
65 | int res; | 65 | int res; |
66 | 66 | ||
67 | stats = part->master->ecc_stats; | 67 | stats = part->master->ecc_stats; |
68 | |||
69 | if (from >= mtd->size) | ||
70 | len = 0; | ||
71 | else if (from + len > mtd->size) | ||
72 | len = mtd->size - from; | ||
73 | res = mtd_read(part->master, from + part->offset, len, retlen, buf); | 68 | res = mtd_read(part->master, from + part->offset, len, retlen, buf); |
74 | if (unlikely(res)) { | 69 | if (unlikely(res)) { |
75 | if (mtd_is_bitflip(res)) | 70 | if (mtd_is_bitflip(res)) |
@@ -84,10 +79,7 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, | |||
84 | size_t *retlen, void **virt, resource_size_t *phys) | 79 | size_t *retlen, void **virt, resource_size_t *phys) |
85 | { | 80 | { |
86 | struct mtd_part *part = PART(mtd); | 81 | struct mtd_part *part = PART(mtd); |
87 | if (from >= mtd->size) | 82 | |
88 | len = 0; | ||
89 | else if (from + len > mtd->size) | ||
90 | len = mtd->size - from; | ||
91 | return mtd_point(part->master, from + part->offset, len, retlen, | 83 | return mtd_point(part->master, from + part->offset, len, retlen, |
92 | virt, phys); | 84 | virt, phys); |
93 | } | 85 | } |
@@ -182,10 +174,6 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
182 | struct mtd_part *part = PART(mtd); | 174 | struct mtd_part *part = PART(mtd); |
183 | if (!(mtd->flags & MTD_WRITEABLE)) | 175 | if (!(mtd->flags & MTD_WRITEABLE)) |
184 | return -EROFS; | 176 | return -EROFS; |
185 | if (to >= mtd->size) | ||
186 | len = 0; | ||
187 | else if (to + len > mtd->size) | ||
188 | len = mtd->size - to; | ||
189 | return mtd_write(part->master, to + part->offset, len, retlen, buf); | 177 | return mtd_write(part->master, to + part->offset, len, retlen, buf); |
190 | } | 178 | } |
191 | 179 | ||
@@ -195,10 +183,6 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
195 | struct mtd_part *part = PART(mtd); | 183 | struct mtd_part *part = PART(mtd); |
196 | if (!(mtd->flags & MTD_WRITEABLE)) | 184 | if (!(mtd->flags & MTD_WRITEABLE)) |
197 | return -EROFS; | 185 | return -EROFS; |
198 | if (to >= mtd->size) | ||
199 | len = 0; | ||
200 | else if (to + len > mtd->size) | ||
201 | len = mtd->size - to; | ||
202 | return mtd_panic_write(part->master, to + part->offset, len, retlen, | 186 | return mtd_panic_write(part->master, to + part->offset, len, retlen, |
203 | buf); | 187 | buf); |
204 | } | 188 | } |
@@ -248,8 +232,6 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
248 | int ret; | 232 | int ret; |
249 | if (!(mtd->flags & MTD_WRITEABLE)) | 233 | if (!(mtd->flags & MTD_WRITEABLE)) |
250 | return -EROFS; | 234 | return -EROFS; |
251 | if (instr->addr >= mtd->size) | ||
252 | return -EINVAL; | ||
253 | instr->addr += part->offset; | 235 | instr->addr += part->offset; |
254 | ret = mtd_erase(part->master, instr); | 236 | ret = mtd_erase(part->master, instr); |
255 | if (ret) { | 237 | if (ret) { |
@@ -277,24 +259,18 @@ EXPORT_SYMBOL_GPL(mtd_erase_callback); | |||
277 | static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 259 | static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
278 | { | 260 | { |
279 | struct mtd_part *part = PART(mtd); | 261 | struct mtd_part *part = PART(mtd); |
280 | if ((len + ofs) > mtd->size) | ||
281 | return -EINVAL; | ||
282 | return mtd_lock(part->master, ofs + part->offset, len); | 262 | return mtd_lock(part->master, ofs + part->offset, len); |
283 | } | 263 | } |
284 | 264 | ||
285 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 265 | static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
286 | { | 266 | { |
287 | struct mtd_part *part = PART(mtd); | 267 | struct mtd_part *part = PART(mtd); |
288 | if ((len + ofs) > mtd->size) | ||
289 | return -EINVAL; | ||
290 | return mtd_unlock(part->master, ofs + part->offset, len); | 268 | return mtd_unlock(part->master, ofs + part->offset, len); |
291 | } | 269 | } |
292 | 270 | ||
293 | static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 271 | static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
294 | { | 272 | { |
295 | struct mtd_part *part = PART(mtd); | 273 | struct mtd_part *part = PART(mtd); |
296 | if ((len + ofs) > mtd->size) | ||
297 | return -EINVAL; | ||
298 | return mtd_is_locked(part->master, ofs + part->offset, len); | 274 | return mtd_is_locked(part->master, ofs + part->offset, len); |
299 | } | 275 | } |
300 | 276 | ||
@@ -319,8 +295,6 @@ static void part_resume(struct mtd_info *mtd) | |||
319 | static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) | 295 | static int part_block_isbad(struct mtd_info *mtd, loff_t ofs) |
320 | { | 296 | { |
321 | struct mtd_part *part = PART(mtd); | 297 | struct mtd_part *part = PART(mtd); |
322 | if (ofs >= mtd->size) | ||
323 | return -EINVAL; | ||
324 | ofs += part->offset; | 298 | ofs += part->offset; |
325 | return mtd_block_isbad(part->master, ofs); | 299 | return mtd_block_isbad(part->master, ofs); |
326 | } | 300 | } |
@@ -332,8 +306,6 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
332 | 306 | ||
333 | if (!(mtd->flags & MTD_WRITEABLE)) | 307 | if (!(mtd->flags & MTD_WRITEABLE)) |
334 | return -EROFS; | 308 | return -EROFS; |
335 | if (ofs >= mtd->size) | ||
336 | return -EINVAL; | ||
337 | ofs += part->offset; | 309 | ofs += part->offset; |
338 | res = mtd_block_markbad(part->master, ofs); | 310 | res = mtd_block_markbad(part->master, ofs); |
339 | if (!res) | 311 | if (!res) |