summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-23 16:59:08 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-30 15:34:13 -0600
commit8e60947d2f1ee675681a526da99fa587e63f78e3 (patch)
tree248933eea7525af9fec0f03499f612e2fed9a11b /drivers
parentb9848081465d8734441408129bd44311c7b6d644 (diff)
loop: rewrite loop_exit using idr_for_each_entry
Use idr_for_each_entry to simplify removing all devices. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210623145908.92973-10-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/loop.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ff7014608ef6..39c05cf518fb 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2518,21 +2518,17 @@ err_out:
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)
{
+ struct loop_device *lo;
+ int id;
+
unregister_blkdev(LOOP_MAJOR, "loop");
misc_deregister(&loop_misc);
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);
idr_destroy(&loop_index_idr);