Commit 8e60947d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

loop: rewrite loop_exit using idr_for_each_entry

Use idr_for_each_entry to simplify removing all devices.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210623145908.92973-10-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b9848081
...@@ -2518,21 +2518,17 @@ static int __init loop_init(void) ...@@ -2518,21 +2518,17 @@ static int __init loop_init(void)
return err; return err;
} }
static int loop_exit_cb(int id, void *ptr, void *data)
{
struct loop_device *lo = ptr;
loop_remove(lo);
return 0;
}
static void __exit loop_exit(void) static void __exit loop_exit(void)
{ {
struct loop_device *lo;
int id;
unregister_blkdev(LOOP_MAJOR, "loop"); unregister_blkdev(LOOP_MAJOR, "loop");
misc_deregister(&loop_misc); misc_deregister(&loop_misc);
mutex_lock(&loop_ctl_mutex); mutex_lock(&loop_ctl_mutex);
idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); idr_for_each_entry(&loop_index_idr, lo, id)
loop_remove(lo);
mutex_unlock(&loop_ctl_mutex); mutex_unlock(&loop_ctl_mutex);
idr_destroy(&loop_index_idr); idr_destroy(&loop_index_idr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment