Skip to content

Commit 04e4651

Browse files
YongjiXiegregkh
authored andcommitted
loop: Use blk_validate_block_size() to validate block size
commit af3c570 upstream. 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> Cc: Tadeusz Struk <tadeusz.struk@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 79ff56c commit 04e4651

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
@@ -228,19 +228,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
228228
blk_mq_unfreeze_queue(lo->lo_queue);
229229
}
230230

231-
/**
232-
* loop_validate_block_size() - validates the passed in block size
233-
* @bsize: size to validate
234-
*/
235-
static int
236-
loop_validate_block_size(unsigned short bsize)
237-
{
238-
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
239-
return -EINVAL;
240-
241-
return 0;
242-
}
243-
244231
/**
245232
* loop_set_size() - sets device size and notifies userspace
246233
* @lo: struct loop_device to set the size for
@@ -1121,7 +1108,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
11211108
}
11221109

11231110
if (config->block_size) {
1124-
error = loop_validate_block_size(config->block_size);
1111+
error = blk_validate_block_size(config->block_size);
11251112
if (error)
11261113
goto out_unlock;
11271114
}
@@ -1617,7 +1604,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
16171604
if (lo->lo_state != Lo_bound)
16181605
return -ENXIO;
16191606

1620-
err = loop_validate_block_size(arg);
1607+
err = blk_validate_block_size(arg);
16211608
if (err)
16221609
return err;
16231610

0 commit comments

Comments
 (0)