mirror of https://gitee.com/openkylin/linux.git
sx8: 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@lst.de> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210602065345.355274-25-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2c6ee0ae5f
commit
693874035e
|
@ -1343,32 +1343,25 @@ static int carm_init_disk(struct carm_host *host, unsigned int port_no)
|
|||
{
|
||||
struct carm_port *port = &host->port[port_no];
|
||||
struct gendisk *disk;
|
||||
struct request_queue *q;
|
||||
|
||||
port->host = host;
|
||||
port->port_no = port_no;
|
||||
|
||||
disk = alloc_disk(CARM_MINORS_PER_MAJOR);
|
||||
if (!disk)
|
||||
return -ENOMEM;
|
||||
disk = blk_mq_alloc_disk(&host->tag_set, port);
|
||||
if (IS_ERR(disk))
|
||||
return PTR_ERR(disk);
|
||||
|
||||
port->disk = disk;
|
||||
sprintf(disk->disk_name, DRV_NAME "/%u",
|
||||
(unsigned int)host->id * CARM_MAX_PORTS + port_no);
|
||||
disk->major = host->major;
|
||||
disk->first_minor = port_no * CARM_MINORS_PER_MAJOR;
|
||||
disk->minors = CARM_MINORS_PER_MAJOR;
|
||||
disk->fops = &carm_bd_ops;
|
||||
disk->private_data = port;
|
||||
|
||||
q = blk_mq_init_queue(&host->tag_set);
|
||||
if (IS_ERR(q))
|
||||
return PTR_ERR(q);
|
||||
|
||||
blk_queue_max_segments(q, CARM_MAX_REQ_SG);
|
||||
blk_queue_segment_boundary(q, CARM_SG_BOUNDARY);
|
||||
|
||||
q->queuedata = port;
|
||||
disk->queue = q;
|
||||
blk_queue_max_segments(disk->queue, CARM_MAX_REQ_SG);
|
||||
blk_queue_segment_boundary(disk->queue, CARM_SG_BOUNDARY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1382,9 +1375,7 @@ static void carm_free_disk(struct carm_host *host, unsigned int port_no)
|
|||
|
||||
if (disk->flags & GENHD_FL_UP)
|
||||
del_gendisk(disk);
|
||||
if (disk->queue)
|
||||
blk_cleanup_queue(disk->queue);
|
||||
put_disk(disk);
|
||||
blk_cleanup_disk(disk);
|
||||
}
|
||||
|
||||
static int carm_init_shm(struct carm_host *host)
|
||||
|
|
Loading…
Reference in New Issue