Skip to content

Commit af3c570

Browse files
YongjiXieaxboe
authored andcommitted
loop: Use blk_validate_block_size() to validate block size
Remove loop_validate_block_size() and use the block layer helper to validate block size. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Link: https://lore.kernel.org/r/20211026144015.188-4-xieyongji@bytedance.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c4318d6 commit af3c570

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

‎drivers/block/loop.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
272272
blk_mq_unfreeze_queue(lo->lo_queue);
273273
}
274274

275-
/**
276-
* loop_validate_block_size() - validates the passed in block size
277-
* @bsize: size to validate
278-
*/
279-
static int
280-
loop_validate_block_size(unsigned short bsize)
281-
{
282-
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
283-
return -EINVAL;
284-
285-
return 0;
286-
}
287-
288275
/**
289276
* loop_set_size() - sets device size and notifies userspace
290277
* @lo: struct loop_device to set the size for
@@ -1236,7 +1223,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
12361223
}
12371224

12381225
if (config->block_size) {
1239-
error = loop_validate_block_size(config->block_size);
1226+
error = blk_validate_block_size(config->block_size);
12401227
if (error)
12411228
goto out_unlock;
12421229
}
@@ -1752,7 +1739,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
17521739
if (lo->lo_state != Lo_bound)
17531740
return -ENXIO;
17541741

1755-
err = loop_validate_block_size(arg);
1742+
err = blk_validate_block_size(arg);
17561743
if (err)
17571744
return err;
17581745

0 commit comments

Comments
 (0)