[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 27/30] scm_blk: use blk_mq_alloc_disk and blk_cleanup_disk



Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
request_queue allocation.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 drivers/s390/block/scm_blk.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c
index a4f6f2e62b1d..88cba6212ee2 100644
--- a/drivers/s390/block/scm_blk.c
+++ b/drivers/s390/block/scm_blk.c
@@ -462,12 +462,12 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct 
scm_device *scmdev)
        if (ret)
                goto out;
 
-       rq = blk_mq_init_queue(&bdev->tag_set);
-       if (IS_ERR(rq)) {
-               ret = PTR_ERR(rq);
+       bdev->gendisk = blk_mq_alloc_disk(&bdev->tag_set, scmdev);
+       if (IS_ERR(bdev->gendisk)) {
+               ret = PTR_ERR(bdev->gendisk);
                goto out_tag;
        }
-       bdev->rq = rq;
+       rq = bdev->rq = bdev->gendisk->queue;
        nr_max_blk = min(scmdev->nr_max_block,
                         (unsigned int) (PAGE_SIZE / sizeof(struct aidaw)));
 
@@ -477,17 +477,11 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct 
scm_device *scmdev)
        blk_queue_flag_set(QUEUE_FLAG_NONROT, rq);
        blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, rq);
 
-       bdev->gendisk = alloc_disk(SCM_NR_PARTS);
-       if (!bdev->gendisk) {
-               ret = -ENOMEM;
-               goto out_queue;
-       }
-       rq->queuedata = scmdev;
        bdev->gendisk->private_data = scmdev;
        bdev->gendisk->fops = &scm_blk_devops;
-       bdev->gendisk->queue = rq;
        bdev->gendisk->major = scm_major;
        bdev->gendisk->first_minor = devindex * SCM_NR_PARTS;
+       bdev->gendisk->minors = SCM_NR_PARTS;
 
        len = snprintf(bdev->gendisk->disk_name, DISK_NAME_LEN, "scm");
        if (devindex > 25) {
@@ -504,8 +498,6 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct 
scm_device *scmdev)
        device_add_disk(&scmdev->dev, bdev->gendisk, NULL);
        return 0;
 
-out_queue:
-       blk_cleanup_queue(rq);
 out_tag:
        blk_mq_free_tag_set(&bdev->tag_set);
 out:
@@ -516,9 +508,8 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct 
scm_device *scmdev)
 void scm_blk_dev_cleanup(struct scm_blk_dev *bdev)
 {
        del_gendisk(bdev->gendisk);
-       blk_cleanup_queue(bdev->gendisk->queue);
+       blk_cleanup_disk(bdev->gendisk);
        blk_mq_free_tag_set(&bdev->tag_set);
-       put_disk(bdev->gendisk);
 }
 
 void scm_blk_set_available(struct scm_blk_dev *bdev)
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.