diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-01-24 02:14:25 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-01-24 02:14:25 -0500 |
commit | e47b207a5bcb73bb097f94d9fe364f50737b0eb2 (patch) | |
tree | 57389653c37d001de3a90655cb4172ba29199ce4 /drivers/mtd/mtdconcat.c | |
parent | d344bff9c36db17dc4765215495aaa7212c1eb6c (diff) | |
parent | 419dd8378dfa32985672ab7927b4bc827f33b332 (diff) |
Merge branch 'master' into upstream-fixes
Diffstat (limited to 'drivers/mtd/mtdconcat.c')
-rw-r--r-- | drivers/mtd/mtdconcat.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 1fea631b5852..06902683bc2a 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -247,7 +247,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
247 | struct mtd_oob_ops devops = *ops; | 247 | struct mtd_oob_ops devops = *ops; |
248 | int i, err, ret = 0; | 248 | int i, err, ret = 0; |
249 | 249 | ||
250 | ops->retlen = 0; | 250 | ops->retlen = ops->oobretlen = 0; |
251 | 251 | ||
252 | for (i = 0; i < concat->num_subdev; i++) { | 252 | for (i = 0; i < concat->num_subdev; i++) { |
253 | struct mtd_info *subdev = concat->subdev[i]; | 253 | struct mtd_info *subdev = concat->subdev[i]; |
@@ -263,6 +263,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
263 | 263 | ||
264 | err = subdev->read_oob(subdev, from, &devops); | 264 | err = subdev->read_oob(subdev, from, &devops); |
265 | ops->retlen += devops.retlen; | 265 | ops->retlen += devops.retlen; |
266 | ops->oobretlen += devops.oobretlen; | ||
266 | 267 | ||
267 | /* Save information about bitflips! */ | 268 | /* Save information about bitflips! */ |
268 | if (unlikely(err)) { | 269 | if (unlikely(err)) { |
@@ -278,14 +279,18 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
278 | return err; | 279 | return err; |
279 | } | 280 | } |
280 | 281 | ||
281 | devops.len = ops->len - ops->retlen; | 282 | if (devops.datbuf) { |
282 | if (!devops.len) | 283 | devops.len = ops->len - ops->retlen; |
283 | return ret; | 284 | if (!devops.len) |
284 | 285 | return ret; | |
285 | if (devops.datbuf) | ||
286 | devops.datbuf += devops.retlen; | 286 | devops.datbuf += devops.retlen; |
287 | if (devops.oobbuf) | 287 | } |
288 | devops.oobbuf += devops.ooblen; | 288 | if (devops.oobbuf) { |
289 | devops.ooblen = ops->ooblen - ops->oobretlen; | ||
290 | if (!devops.ooblen) | ||
291 | return ret; | ||
292 | devops.oobbuf += ops->oobretlen; | ||
293 | } | ||
289 | 294 | ||
290 | from = 0; | 295 | from = 0; |
291 | } | 296 | } |
@@ -321,14 +326,18 @@ concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) | |||
321 | if (err) | 326 | if (err) |
322 | return err; | 327 | return err; |
323 | 328 | ||
324 | devops.len = ops->len - ops->retlen; | 329 | if (devops.datbuf) { |
325 | if (!devops.len) | 330 | devops.len = ops->len - ops->retlen; |
326 | return 0; | 331 | if (!devops.len) |
327 | 332 | return 0; | |
328 | if (devops.datbuf) | ||
329 | devops.datbuf += devops.retlen; | 333 | devops.datbuf += devops.retlen; |
330 | if (devops.oobbuf) | 334 | } |
331 | devops.oobbuf += devops.ooblen; | 335 | if (devops.oobbuf) { |
336 | devops.ooblen = ops->ooblen - ops->oobretlen; | ||
337 | if (!devops.ooblen) | ||
338 | return 0; | ||
339 | devops.oobbuf += devops.oobretlen; | ||
340 | } | ||
332 | to = 0; | 341 | to = 0; |
333 | } | 342 | } |
334 | return -EINVAL; | 343 | return -EINVAL; |
@@ -699,14 +708,13 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
699 | 708 | ||
700 | /* allocate the device structure */ | 709 | /* allocate the device structure */ |
701 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); | 710 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); |
702 | concat = kmalloc(size, GFP_KERNEL); | 711 | concat = kzalloc(size, GFP_KERNEL); |
703 | if (!concat) { | 712 | if (!concat) { |
704 | printk | 713 | printk |
705 | ("memory allocation error while creating concatenated device \"%s\"\n", | 714 | ("memory allocation error while creating concatenated device \"%s\"\n", |
706 | name); | 715 | name); |
707 | return NULL; | 716 | return NULL; |
708 | } | 717 | } |
709 | memset(concat, 0, size); | ||
710 | concat->subdev = (struct mtd_info **) (concat + 1); | 718 | concat->subdev = (struct mtd_info **) (concat + 1); |
711 | 719 | ||
712 | /* | 720 | /* |
@@ -764,6 +772,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
764 | concat->mtd.ecc_stats.badblocks += | 772 | concat->mtd.ecc_stats.badblocks += |
765 | subdev[i]->ecc_stats.badblocks; | 773 | subdev[i]->ecc_stats.badblocks; |
766 | if (concat->mtd.writesize != subdev[i]->writesize || | 774 | if (concat->mtd.writesize != subdev[i]->writesize || |
775 | concat->mtd.subpage_sft != subdev[i]->subpage_sft || | ||
767 | concat->mtd.oobsize != subdev[i]->oobsize || | 776 | concat->mtd.oobsize != subdev[i]->oobsize || |
768 | concat->mtd.ecctype != subdev[i]->ecctype || | 777 | concat->mtd.ecctype != subdev[i]->ecctype || |
769 | concat->mtd.eccsize != subdev[i]->eccsize || | 778 | concat->mtd.eccsize != subdev[i]->eccsize || |