aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/vmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/vmt.c')
-rw-r--r--drivers/mtd/ubi/vmt.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index df5483562b7a..ab64cb56df6e 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -198,7 +198,7 @@ static void volume_sysfs_close(struct ubi_volume *vol)
198 * %UBI_VOL_NUM_AUTO, this function automatically assign ID to the new volume 198 * %UBI_VOL_NUM_AUTO, this function automatically assign ID to the new volume
199 * and saves it in @req->vol_id. Returns zero in case of success and a negative 199 * and saves it in @req->vol_id. Returns zero in case of success and a negative
200 * error code in case of failure. Note, the caller has to have the 200 * error code in case of failure. Note, the caller has to have the
201 * @ubi->volumes_mutex locked. 201 * @ubi->device_mutex locked.
202 */ 202 */
203int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) 203int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
204{ 204{
@@ -232,8 +232,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
232 req->vol_id = vol_id; 232 req->vol_id = vol_id;
233 } 233 }
234 234
235 dbg_gen("volume ID %d, %llu bytes, type %d, name %s", 235 dbg_gen("create device %d, volume %d, %llu bytes, type %d, name %s",
236 vol_id, (unsigned long long)req->bytes, 236 ubi->ubi_num, vol_id, (unsigned long long)req->bytes,
237 (int)req->vol_type, req->name); 237 (int)req->vol_type, req->name);
238 238
239 /* Ensure that this volume does not exist */ 239 /* Ensure that this volume does not exist */
@@ -317,10 +317,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
317 goto out_mapping; 317 goto out_mapping;
318 } 318 }
319 319
320 err = ubi_create_gluebi(ubi, vol);
321 if (err)
322 goto out_cdev;
323
324 vol->dev.release = vol_release; 320 vol->dev.release = vol_release;
325 vol->dev.parent = &ubi->dev; 321 vol->dev.parent = &ubi->dev;
326 vol->dev.devt = dev; 322 vol->dev.devt = dev;
@@ -330,7 +326,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
330 err = device_register(&vol->dev); 326 err = device_register(&vol->dev);
331 if (err) { 327 if (err) {
332 ubi_err("cannot register device"); 328 ubi_err("cannot register device");
333 goto out_gluebi; 329 goto out_cdev;
334 } 330 }
335 331
336 err = volume_sysfs_init(ubi, vol); 332 err = volume_sysfs_init(ubi, vol);
@@ -358,7 +354,9 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
358 ubi->vol_count += 1; 354 ubi->vol_count += 1;
359 spin_unlock(&ubi->volumes_lock); 355 spin_unlock(&ubi->volumes_lock);
360 356
361 err = paranoid_check_volumes(ubi); 357 ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
358 if (paranoid_check_volumes(ubi))
359 dbg_err("check failed while creating volume %d", vol_id);
362 return err; 360 return err;
363 361
364out_sysfs: 362out_sysfs:
@@ -373,10 +371,6 @@ out_sysfs:
373 do_free = 0; 371 do_free = 0;
374 get_device(&vol->dev); 372 get_device(&vol->dev);
375 volume_sysfs_close(vol); 373 volume_sysfs_close(vol);
376out_gluebi:
377 if (ubi_destroy_gluebi(vol))
378 dbg_err("cannot destroy gluebi for volume %d:%d",
379 ubi->ubi_num, vol_id);
380out_cdev: 374out_cdev:
381 cdev_del(&vol->cdev); 375 cdev_del(&vol->cdev);
382out_mapping: 376out_mapping:
@@ -403,7 +397,7 @@ out_unlock:
403 * 397 *
404 * This function removes volume described by @desc. The volume has to be opened 398 * This function removes volume described by @desc. The volume has to be opened
405 * in "exclusive" mode. Returns zero in case of success and a negative error 399 * in "exclusive" mode. Returns zero in case of success and a negative error
406 * code in case of failure. The caller has to have the @ubi->volumes_mutex 400 * code in case of failure. The caller has to have the @ubi->device_mutex
407 * locked. 401 * locked.
408 */ 402 */
409int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) 403int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
@@ -412,7 +406,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
412 struct ubi_device *ubi = vol->ubi; 406 struct ubi_device *ubi = vol->ubi;
413 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs; 407 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs;
414 408
415 dbg_gen("remove UBI volume %d", vol_id); 409 dbg_gen("remove device %d, volume %d", ubi->ubi_num, vol_id);
416 ubi_assert(desc->mode == UBI_EXCLUSIVE); 410 ubi_assert(desc->mode == UBI_EXCLUSIVE);
417 ubi_assert(vol == ubi->volumes[vol_id]); 411 ubi_assert(vol == ubi->volumes[vol_id]);
418 412
@@ -431,10 +425,6 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
431 ubi->volumes[vol_id] = NULL; 425 ubi->volumes[vol_id] = NULL;
432 spin_unlock(&ubi->volumes_lock); 426 spin_unlock(&ubi->volumes_lock);
433 427
434 err = ubi_destroy_gluebi(vol);
435 if (err)
436 goto out_err;
437
438 if (!no_vtbl) { 428 if (!no_vtbl) {
439 err = ubi_change_vtbl_record(ubi, vol_id, NULL); 429 err = ubi_change_vtbl_record(ubi, vol_id, NULL);
440 if (err) 430 if (err)
@@ -465,8 +455,10 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
465 ubi->vol_count -= 1; 455 ubi->vol_count -= 1;
466 spin_unlock(&ubi->volumes_lock); 456 spin_unlock(&ubi->volumes_lock);
467 457
468 if (!no_vtbl) 458 ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED);
469 err = paranoid_check_volumes(ubi); 459 if (!no_vtbl && paranoid_check_volumes(ubi))
460 dbg_err("check failed while removing volume %d", vol_id);
461
470 return err; 462 return err;
471 463
472out_err: 464out_err:
@@ -485,7 +477,7 @@ out_unlock:
485 * 477 *
486 * This function re-sizes the volume and returns zero in case of success, and a 478 * This function re-sizes the volume and returns zero in case of success, and a
487 * negative error code in case of failure. The caller has to have the 479 * negative error code in case of failure. The caller has to have the
488 * @ubi->volumes_mutex locked. 480 * @ubi->device_mutex locked.
489 */ 481 */
490int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) 482int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
491{ 483{
@@ -498,8 +490,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
498 if (ubi->ro_mode) 490 if (ubi->ro_mode)
499 return -EROFS; 491 return -EROFS;
500 492
501 dbg_gen("re-size volume %d to from %d to %d PEBs", 493 dbg_gen("re-size device %d, volume %d to from %d to %d PEBs",
502 vol_id, vol->reserved_pebs, reserved_pebs); 494 ubi->ubi_num, vol_id, vol->reserved_pebs, reserved_pebs);
503 495
504 if (vol->vol_type == UBI_STATIC_VOLUME && 496 if (vol->vol_type == UBI_STATIC_VOLUME &&
505 reserved_pebs < vol->used_ebs) { 497 reserved_pebs < vol->used_ebs) {
@@ -587,7 +579,9 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
587 (long long)vol->used_ebs * vol->usable_leb_size; 579 (long long)vol->used_ebs * vol->usable_leb_size;
588 } 580 }
589 581
590 err = paranoid_check_volumes(ubi); 582 ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED);
583 if (paranoid_check_volumes(ubi))
584 dbg_err("check failed while re-sizing volume %d", vol_id);
591 return err; 585 return err;
592 586
593out_acc: 587out_acc:
@@ -632,11 +626,12 @@ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
632 vol->name_len = re->new_name_len; 626 vol->name_len = re->new_name_len;
633 memcpy(vol->name, re->new_name, re->new_name_len + 1); 627 memcpy(vol->name, re->new_name, re->new_name_len + 1);
634 spin_unlock(&ubi->volumes_lock); 628 spin_unlock(&ubi->volumes_lock);
629 ubi_volume_notify(ubi, vol, UBI_VOLUME_RENAMED);
635 } 630 }
636 } 631 }
637 632
638 if (!err) 633 if (!err && paranoid_check_volumes(ubi))
639 err = paranoid_check_volumes(ubi); 634 ;
640 return err; 635 return err;
641} 636}
642 637
@@ -667,10 +662,6 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
667 return err; 662 return err;
668 } 663 }
669 664
670 err = ubi_create_gluebi(ubi, vol);
671 if (err)
672 goto out_cdev;
673
674 vol->dev.release = vol_release; 665 vol->dev.release = vol_release;
675 vol->dev.parent = &ubi->dev; 666 vol->dev.parent = &ubi->dev;
676 vol->dev.devt = dev; 667 vol->dev.devt = dev;
@@ -678,21 +669,19 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
678 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); 669 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
679 err = device_register(&vol->dev); 670 err = device_register(&vol->dev);
680 if (err) 671 if (err)
681 goto out_gluebi; 672 goto out_cdev;
682 673
683 err = volume_sysfs_init(ubi, vol); 674 err = volume_sysfs_init(ubi, vol);
684 if (err) { 675 if (err) {
685 cdev_del(&vol->cdev); 676 cdev_del(&vol->cdev);
686 err = ubi_destroy_gluebi(vol);
687 volume_sysfs_close(vol); 677 volume_sysfs_close(vol);
688 return err; 678 return err;
689 } 679 }
690 680
691 err = paranoid_check_volumes(ubi); 681 if (paranoid_check_volumes(ubi))
682 dbg_err("check failed while adding volume %d", vol_id);
692 return err; 683 return err;
693 684
694out_gluebi:
695 err = ubi_destroy_gluebi(vol);
696out_cdev: 685out_cdev:
697 cdev_del(&vol->cdev); 686 cdev_del(&vol->cdev);
698 return err; 687 return err;
@@ -708,12 +697,9 @@ out_cdev:
708 */ 697 */
709void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) 698void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
710{ 699{
711 int err;
712
713 dbg_gen("free volume %d", vol->vol_id); 700 dbg_gen("free volume %d", vol->vol_id);
714 701
715 ubi->volumes[vol->vol_id] = NULL; 702 ubi->volumes[vol->vol_id] = NULL;
716 err = ubi_destroy_gluebi(vol);
717 cdev_del(&vol->cdev); 703 cdev_del(&vol->cdev);
718 volume_sysfs_close(vol); 704 volume_sysfs_close(vol);
719} 705}
@@ -868,6 +854,7 @@ fail:
868 if (vol) 854 if (vol)
869 ubi_dbg_dump_vol_info(vol); 855 ubi_dbg_dump_vol_info(vol);
870 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); 856 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
857 dump_stack();
871 spin_unlock(&ubi->volumes_lock); 858 spin_unlock(&ubi->volumes_lock);
872 return -EINVAL; 859 return -EINVAL;
873} 860}