mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
genhd: Add helper put_disk_and_module()
Add a proper counterpart to get_disk_and_module() - put_disk_and_module(). Currently it is opencoded in several places. Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
3079c22ea8
commit
9df6c29912
4 changed files with 24 additions and 27 deletions
|
|
@ -1111,8 +1111,7 @@ static struct block_device *bd_start_claiming(struct block_device *bdev,
|
|||
else
|
||||
whole = bdgrab(bdev);
|
||||
|
||||
module_put(disk->fops->owner);
|
||||
put_disk(disk);
|
||||
put_disk_and_module(disk);
|
||||
if (!whole)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
|
@ -1407,7 +1406,6 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
|
|||
static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
|
||||
{
|
||||
struct gendisk *disk;
|
||||
struct module *owner;
|
||||
int ret;
|
||||
int partno;
|
||||
int perm = 0;
|
||||
|
|
@ -1433,7 +1431,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
disk = get_gendisk(bdev->bd_dev, &partno);
|
||||
if (!disk)
|
||||
goto out;
|
||||
owner = disk->fops->owner;
|
||||
|
||||
disk_block_events(disk);
|
||||
mutex_lock_nested(&bdev->bd_mutex, for_part);
|
||||
|
|
@ -1463,8 +1460,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
bdev->bd_queue = NULL;
|
||||
mutex_unlock(&bdev->bd_mutex);
|
||||
disk_unblock_events(disk);
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
|
@ -1525,8 +1521,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
goto out_unlock_bdev;
|
||||
}
|
||||
/* only one opener holds refs to the module and disk */
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
}
|
||||
bdev->bd_openers++;
|
||||
if (for_part)
|
||||
|
|
@ -1546,8 +1541,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
out_unlock_bdev:
|
||||
mutex_unlock(&bdev->bd_mutex);
|
||||
disk_unblock_events(disk);
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
out:
|
||||
bdput(bdev);
|
||||
|
||||
|
|
@ -1770,8 +1764,6 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
disk->fops->release(disk, mode);
|
||||
}
|
||||
if (!bdev->bd_openers) {
|
||||
struct module *owner = disk->fops->owner;
|
||||
|
||||
disk_put_part(bdev->bd_part);
|
||||
bdev->bd_part = NULL;
|
||||
bdev->bd_disk = NULL;
|
||||
|
|
@ -1779,8 +1771,7 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
|
|||
victim = bdev->bd_contains;
|
||||
bdev->bd_contains = NULL;
|
||||
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
}
|
||||
mutex_unlock(&bdev->bd_mutex);
|
||||
bdput(bdev);
|
||||
|
|
|
|||
Loading…
Reference in a new issue