mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -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
|
|
@ -812,7 +812,6 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
|||
struct gendisk *disk;
|
||||
struct request_queue *q;
|
||||
struct blkcg_gq *blkg;
|
||||
struct module *owner;
|
||||
unsigned int major, minor;
|
||||
int key_len, part, ret;
|
||||
char *body;
|
||||
|
|
@ -904,9 +903,7 @@ fail_unlock:
|
|||
spin_unlock_irq(q->queue_lock);
|
||||
rcu_read_unlock();
|
||||
fail:
|
||||
owner = disk->fops->owner;
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
/*
|
||||
* If queue was bypassing, we should retry. Do so after a
|
||||
* short msleep(). It isn't strictly necessary but queue
|
||||
|
|
@ -931,13 +928,9 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep);
|
|||
void blkg_conf_finish(struct blkg_conf_ctx *ctx)
|
||||
__releases(ctx->disk->queue->queue_lock) __releases(rcu)
|
||||
{
|
||||
struct module *owner;
|
||||
|
||||
spin_unlock_irq(ctx->disk->queue->queue_lock);
|
||||
rcu_read_unlock();
|
||||
owner = ctx->disk->fops->owner;
|
||||
put_disk(ctx->disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(ctx->disk);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blkg_conf_finish);
|
||||
|
||||
|
|
|
|||
|
|
@ -817,10 +817,7 @@ struct gendisk *get_gendisk(dev_t devt, int *partno)
|
|||
}
|
||||
|
||||
if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) {
|
||||
struct module *owner = disk->fops->owner;
|
||||
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
put_disk_and_module(disk);
|
||||
disk = NULL;
|
||||
}
|
||||
return disk;
|
||||
|
|
@ -1483,6 +1480,21 @@ void put_disk(struct gendisk *disk)
|
|||
}
|
||||
EXPORT_SYMBOL(put_disk);
|
||||
|
||||
/*
|
||||
* This is a counterpart of get_disk_and_module() and thus also of
|
||||
* get_gendisk().
|
||||
*/
|
||||
void put_disk_and_module(struct gendisk *disk)
|
||||
{
|
||||
if (disk) {
|
||||
struct module *owner = disk->fops->owner;
|
||||
|
||||
put_disk(disk);
|
||||
module_put(owner);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(put_disk_and_module);
|
||||
|
||||
static void set_disk_ro_uevent(struct gendisk *gd, int ro)
|
||||
{
|
||||
char event[] = "DISK_RO=1";
|
||||
|
|
|
|||
Loading…
Reference in a new issue