There are some duplicated codes to validate the block size in block drivers. This limitation actually comes from block layer, so this patch tries to add a new block layer helper for that.
Showing the changes to include/linux/blkdev.h (1 of 1 file). Show all
Unified · Split
| @@ -44,6 +44,14 @@ struct blk_crypto_profile; · 43 unmodified lines | |||
| 44 | */ | 44 | */ |
| 45 | #define BLKCG_MAX_POLS 6 | 45 | #define BLKCG_MAX_POLS 6 |
| 46 | 46 | ||
| 47 | static inline int blk_validate_block_size(unsigned int bsize) | ||
| 48 | { | ||
| 49 | if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) | ||
| 50 | return -EINVAL; | ||
| 51 | |||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | |||
| 47 | static inline bool blk_op_is_passthrough(unsigned int op) | 55 | static inline bool blk_op_is_passthrough(unsigned int op) |
| 48 | { | 56 | { |
| 49 | op &= REQ_OP_MASK; | 57 | op &= REQ_OP_MASK; |