mtdconcat.c (0a1340c185734a57fbf4775927966ad4a1347b02) | mtdconcat.c (7014568bad55c20b7ee4f439d78c9e875912d51f) |
---|---|
1/* 2 * MTD device concatenation layer 3 * 4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de> 5 * 6 * NAND support by Christian Gan <cgan@iders.ca> 7 * 8 * This code is GPL --- 233 unchanged lines hidden (view full) --- 242 243static int 244concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) 245{ 246 struct mtd_concat *concat = CONCAT(mtd); 247 struct mtd_oob_ops devops = *ops; 248 int i, err, ret = 0; 249 | 1/* 2 * MTD device concatenation layer 3 * 4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de> 5 * 6 * NAND support by Christian Gan <cgan@iders.ca> 7 * 8 * This code is GPL --- 233 unchanged lines hidden (view full) --- 242 243static int 244concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) 245{ 246 struct mtd_concat *concat = CONCAT(mtd); 247 struct mtd_oob_ops devops = *ops; 248 int i, err, ret = 0; 249 |
250 ops->retlen = 0; | 250 ops->retlen = ops->oobretlen = 0; |
251 252 for (i = 0; i < concat->num_subdev; i++) { 253 struct mtd_info *subdev = concat->subdev[i]; 254 255 if (from >= subdev->size) { 256 from -= subdev->size; 257 continue; 258 } 259 260 /* partial read ? */ 261 if (from + devops.len > subdev->size) 262 devops.len = subdev->size - from; 263 264 err = subdev->read_oob(subdev, from, &devops); 265 ops->retlen += devops.retlen; | 251 252 for (i = 0; i < concat->num_subdev; i++) { 253 struct mtd_info *subdev = concat->subdev[i]; 254 255 if (from >= subdev->size) { 256 from -= subdev->size; 257 continue; 258 } 259 260 /* partial read ? */ 261 if (from + devops.len > subdev->size) 262 devops.len = subdev->size - from; 263 264 err = subdev->read_oob(subdev, from, &devops); 265 ops->retlen += devops.retlen; |
266 ops->oobretlen += devops.oobretlen; |
|
266 267 /* Save information about bitflips! */ 268 if (unlikely(err)) { 269 if (err == -EBADMSG) { 270 mtd->ecc_stats.failed++; 271 ret = err; 272 } else if (err == -EUCLEAN) { 273 mtd->ecc_stats.corrected++; 274 /* Do not overwrite -EBADMSG !! */ 275 if (!ret) 276 ret = err; 277 } else 278 return err; 279 } 280 | 267 268 /* Save information about bitflips! */ 269 if (unlikely(err)) { 270 if (err == -EBADMSG) { 271 mtd->ecc_stats.failed++; 272 ret = err; 273 } else if (err == -EUCLEAN) { 274 mtd->ecc_stats.corrected++; 275 /* Do not overwrite -EBADMSG !! */ 276 if (!ret) 277 ret = err; 278 } else 279 return err; 280 } 281 |
281 devops.len = ops->len - ops->retlen; 282 if (!devops.len) 283 return ret; 284 285 if (devops.datbuf) | 282 if (devops.datbuf) { 283 devops.len = ops->len - ops->retlen; 284 if (!devops.len) 285 return ret; |
286 devops.datbuf += devops.retlen; | 286 devops.datbuf += devops.retlen; |
287 if (devops.oobbuf) 288 devops.oobbuf += devops.ooblen; | 287 } 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 290 from = 0; 291 } 292 return -EINVAL; 293} 294 295static int 296concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) --- 19 unchanged lines hidden (view full) --- 316 if (to + devops.len > subdev->size) 317 devops.len = subdev->size - to; 318 319 err = subdev->write_oob(subdev, to, &devops); 320 ops->retlen += devops.retlen; 321 if (err) 322 return err; 323 | 294 295 from = 0; 296 } 297 return -EINVAL; 298} 299 300static int 301concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) --- 19 unchanged lines hidden (view full) --- 321 if (to + devops.len > subdev->size) 322 devops.len = subdev->size - to; 323 324 err = subdev->write_oob(subdev, to, &devops); 325 ops->retlen += devops.retlen; 326 if (err) 327 return err; 328 |
324 devops.len = ops->len - ops->retlen; 325 if (!devops.len) 326 return 0; 327 328 if (devops.datbuf) | 329 if (devops.datbuf) { 330 devops.len = ops->len - ops->retlen; 331 if (!devops.len) 332 return 0; |
329 devops.datbuf += devops.retlen; | 333 devops.datbuf += devops.retlen; |
330 if (devops.oobbuf) 331 devops.oobbuf += devops.ooblen; | 334 } 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; 333 } 334 return -EINVAL; 335} 336 337static void concat_erase_callback(struct erase_info *instr) 338{ 339 wake_up((wait_queue_head_t *) instr->priv); --- 598 unchanged lines hidden --- | 341 to = 0; 342 } 343 return -EINVAL; 344} 345 346static void concat_erase_callback(struct erase_info *instr) 347{ 348 wake_up((wait_queue_head_t *) instr->priv); --- 598 unchanged lines hidden --- |