Skip to content

Commit

Permalink
loop: Use blk_validate_block_size() to validate block size
Browse files Browse the repository at this point in the history
Remove loop_validate_block_size() and use the block layer helper
to validate block size.

Signed-off-by: Xie Yongji <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
YongjiXie authored and axboe committed Oct 27, 2021
1 parent c4318d6 commit af3c570
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
blk_mq_unfreeze_queue(lo->lo_queue);
}

/**
* loop_validate_block_size() - validates the passed in block size
* @bsize: size to validate
*/
static int
loop_validate_block_size(unsigned short bsize)
{
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
return -EINVAL;

return 0;
}

/**
* loop_set_size() - sets device size and notifies userspace
* @lo: struct loop_device to set the size for
Expand Down Expand Up @@ -1236,7 +1223,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
}

if (config->block_size) {
error = loop_validate_block_size(config->block_size);
error = blk_validate_block_size(config->block_size);
if (error)
goto out_unlock;
}
Expand Down Expand Up @@ -1752,7 +1739,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
if (lo->lo_state != Lo_bound)
return -ENXIO;

err = loop_validate_block_size(arg);
err = blk_validate_block_size(arg);
if (err)
return err;

Expand Down

0 comments on commit af3c570

Please sign in to comment.