We look too much into struct cdev's guts. Let's add helpers to make operating on block device cdevs more concise. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/block.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/block.h b/include/block.h index 4dd2aa1f80ef..da258f509b41 100644 --- a/include/block.h +++ b/include/block.h @@ -58,4 +58,19 @@ static inline struct block_device *cdev_get_block_device(const struct cdev *cdev } #endif +static inline bool cdev_is_block_device(const struct cdev *cdev) +{ + return cdev_get_block_device(cdev) != NULL; +} + +static inline bool cdev_is_block_partition(const struct cdev *cdev) +{ + return cdev_is_block_device(cdev) && cdev_is_partition(cdev); +} + +static inline bool cdev_is_block_disk(const struct cdev *cdev) +{ + return cdev_is_block_device(cdev) && !cdev_is_partition(cdev); +} + #endif /* __BLOCK_H */ -- 2.39.2