loop: remove the l argument to loop_add
authorChristoph Hellwig <hch@lst.de>
Wed, 23 Jun 2021 14:59:02 +0000 (16:59 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Jun 2021 21:34:13 +0000 (15:34 -0600)
None of the callers cares about the allocated struct loop_device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210623145908.92973-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c

index 4a3712e..d587ad2 100644 (file)
@@ -2237,7 +2237,7 @@ static const struct blk_mq_ops loop_mq_ops = {
        .complete       = lo_complete_rq,
 };
 
-static int loop_add(struct loop_device **l, int i)
+static int loop_add(int i)
 {
        struct loop_device *lo;
        struct gendisk *disk;
@@ -2326,7 +2326,6 @@ static int loop_add(struct loop_device **l, int i)
        disk->queue             = lo->lo_queue;
        sprintf(disk->disk_name, "loop%d", i);
        add_disk(disk);
-       *l = lo;
        return lo->lo_number;
 
 out_cleanup_tags:
@@ -2396,7 +2395,7 @@ static void loop_probe(dev_t dev)
 
        mutex_lock(&loop_ctl_mutex);
        if (loop_lookup(&lo, idx) < 0)
-               loop_add(&lo, idx);
+               loop_add(idx);
        mutex_unlock(&loop_ctl_mutex);
 }
 
@@ -2418,7 +2417,7 @@ static long loop_control_ioctl(struct file *file, unsigned int cmd,
                        ret = -EEXIST;
                        break;
                }
-               ret = loop_add(&lo, parm);
+               ret = loop_add(parm);
                break;
        case LOOP_CTL_REMOVE:
                ret = loop_lookup(&lo, parm);
@@ -2446,7 +2445,7 @@ static long loop_control_ioctl(struct file *file, unsigned int cmd,
                ret = loop_lookup(&lo, -1);
                if (ret >= 0)
                        break;
-               ret = loop_add(&lo, -1);
+               ret = loop_add(-1);
        }
        mutex_unlock(&loop_ctl_mutex);
 
@@ -2473,7 +2472,6 @@ MODULE_ALIAS("devname:loop-control");
 static int __init loop_init(void)
 {
        int i, nr;
-       struct loop_device *lo;
        int err;
 
        part_shift = 0;
@@ -2527,7 +2525,7 @@ static int __init loop_init(void)
        /* pre-create number of devices given by config or max_loop */
        mutex_lock(&loop_ctl_mutex);
        for (i = 0; i < nr; i++)
-               loop_add(&lo, i);
+               loop_add(i);
        mutex_unlock(&loop_ctl_mutex);
 
        printk(KERN_INFO "loop: module loaded\n");