Skip to content

Commit 0267e9c

Browse files
Christoph Hellwigaxboe
authored andcommitted
ubd: remove ubd_disk_register
Fold it into the only caller to remove lots of references to the global ubd_devs array. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Richard Weinberger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 32621ad commit 0267e9c

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -849,27 +849,6 @@ static const struct attribute_group *ubd_attr_groups[] = {
849849
NULL,
850850
};
851851

852-
static int ubd_disk_register(int major, u64 size, int unit,
853-
struct gendisk *disk)
854-
{
855-
disk->major = major;
856-
disk->first_minor = unit << UBD_SHIFT;
857-
disk->minors = 1 << UBD_SHIFT;
858-
disk->fops = &ubd_blops;
859-
set_capacity(disk, size / 512);
860-
sprintf(disk->disk_name, "ubd%c", 'a' + unit);
861-
862-
ubd_devs[unit].pdev.id = unit;
863-
ubd_devs[unit].pdev.name = DRIVER_NAME;
864-
ubd_devs[unit].pdev.dev.release = ubd_device_release;
865-
dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]);
866-
platform_device_register(&ubd_devs[unit].pdev);
867-
868-
disk->private_data = &ubd_devs[unit];
869-
disk->queue = ubd_devs[unit].queue;
870-
return device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups);
871-
}
872-
873852
#define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE))
874853

875854
static const struct blk_mq_ops ubd_mq_ops = {
@@ -916,7 +895,21 @@ static int ubd_add(int n, char **error_out)
916895
ubd_dev->queue = disk->queue;
917896

918897
blk_queue_write_cache(ubd_dev->queue, true, false);
919-
err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk);
898+
disk->major = UBD_MAJOR;
899+
disk->first_minor = n << UBD_SHIFT;
900+
disk->minors = 1 << UBD_SHIFT;
901+
disk->fops = &ubd_blops;
902+
set_capacity(disk, ubd_dev->size / 512);
903+
sprintf(disk->disk_name, "ubd%c", 'a' + n);
904+
disk->private_data = ubd_dev;
905+
906+
ubd_dev->pdev.id = n;
907+
ubd_dev->pdev.name = DRIVER_NAME;
908+
ubd_dev->pdev.dev.release = ubd_device_release;
909+
dev_set_drvdata(&ubd_dev->pdev.dev, ubd_dev);
910+
platform_device_register(&ubd_dev->pdev);
911+
912+
err = device_add_disk(&ubd_dev->pdev.dev, disk, ubd_attr_groups);
920913
if (err)
921914
goto out_cleanup_disk;
922915

0 commit comments

Comments
 (0)