[PATCH 13/18] block: add cdev_is_block_(device,partition,disk) helpers

Marco Felsch m.felsch at pengutronix.de
Wed May 31 10:35:18 PDT 2023


On 23-05-31, Ahmad Fatoum wrote:
> 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 at pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>

> ---
>  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
> 
> 
> 



More information about the barebox mailing list