diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-17 06:09:09 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 12:15:15 -0500 |
commit | 450f872a8e1763c883c9f723e6937b7ed223e6d3 (patch) | |
tree | 256c2d6a485a4d5b4d38d2e591eb8c9105b38f90 | |
parent | c63a491d3737aec3c47c5e785d87021752ad9fa6 (diff) |
UBI: get device when opening volume
When a volume is opened, get its kref via get_device() call.
And put the reference when closing the volume. With this, we
may have a bit saner volume delete.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 9 | ||||
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 5 |
3 files changed, 8 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 24344ba3cfed..35d34b675c78 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -635,9 +635,12 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, | |||
635 | } | 635 | } |
636 | 636 | ||
637 | err = ubi_remove_volume(desc); | 637 | err = ubi_remove_volume(desc); |
638 | if (err) | 638 | /* |
639 | ubi_close_volume(desc); | 639 | * The volume is deleted, and the 'struct ubi_volume' object |
640 | 640 | * will be freed when 'ubi_close_volume()' will call | |
641 | * 'put_device()'. | ||
642 | */ | ||
643 | ubi_close_volume(desc); | ||
641 | break; | 644 | break; |
642 | } | 645 | } |
643 | 646 | ||
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 8e15002a36c3..96f5fef5f3fa 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c | |||
@@ -156,6 +156,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode) | |||
156 | vol->exclusive = 1; | 156 | vol->exclusive = 1; |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | get_device(&vol->dev); | ||
159 | spin_unlock(&ubi->volumes_lock); | 160 | spin_unlock(&ubi->volumes_lock); |
160 | 161 | ||
161 | desc->vol = vol; | 162 | desc->vol = vol; |
@@ -274,6 +275,7 @@ void ubi_close_volume(struct ubi_volume_desc *desc) | |||
274 | spin_unlock(&vol->ubi->volumes_lock); | 275 | spin_unlock(&vol->ubi->volumes_lock); |
275 | 276 | ||
276 | kfree(desc); | 277 | kfree(desc); |
278 | put_device(&vol->dev); | ||
277 | module_put(THIS_MODULE); | 279 | module_put(THIS_MODULE); |
278 | } | 280 | } |
279 | EXPORT_SYMBOL_GPL(ubi_close_volume); | 281 | EXPORT_SYMBOL_GPL(ubi_close_volume); |
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index ec2dd3c65c43..9dd3689aecd3 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -435,7 +435,6 @@ int ubi_remove_volume(struct ubi_volume_desc *desc) | |||
435 | vol->eba_tbl = NULL; | 435 | vol->eba_tbl = NULL; |
436 | cdev_del(&vol->cdev); | 436 | cdev_del(&vol->cdev); |
437 | volume_sysfs_close(vol); | 437 | volume_sysfs_close(vol); |
438 | kfree(desc); | ||
439 | 438 | ||
440 | spin_lock(&ubi->volumes_lock); | 439 | spin_lock(&ubi->volumes_lock); |
441 | ubi->rsvd_pebs -= reserved_pebs; | 440 | ubi->rsvd_pebs -= reserved_pebs; |
@@ -453,10 +452,6 @@ int ubi_remove_volume(struct ubi_volume_desc *desc) | |||
453 | spin_unlock(&ubi->volumes_lock); | 452 | spin_unlock(&ubi->volumes_lock); |
454 | 453 | ||
455 | paranoid_check_volumes(ubi); | 454 | paranoid_check_volumes(ubi); |
456 | mutex_unlock(&ubi->volumes_mutex); | ||
457 | module_put(THIS_MODULE); | ||
458 | return 0; | ||
459 | |||
460 | out: | 455 | out: |
461 | mutex_unlock(&ubi->volumes_mutex); | 456 | mutex_unlock(&ubi->volumes_mutex); |
462 | return err; | 457 | return err; |