Re: [PATCH 03/10] block: allow block devices to implement the cdev erase operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 30, 2024 at 09:19:22AM +0200, Ahmad Fatoum wrote:
> We mainly implement cdev erase for raw flashes. Many block devices, like
> NVMe, SSD or SD/MMC are also flash-based and expose a mechanism or
> multiple to trigger an erase on hardware or flash translation layer
> level without an accompanied write.
> 
> To make it possible to use this functionality elsewhere in barebox,
> let's have the common block device layer pass through the erase
> operation, so it may be implemented in a device-specific manner.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  common/block.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
>  include/block.h |  1 +
>  2 files changed, 44 insertions(+)
> 
> diff --git a/common/block.c b/common/block.c
> index f55da775a797..b43fcbe6927b 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -380,10 +380,45 @@ static int block_op_discard_range(struct cdev *cdev, loff_t count, loff_t offset
>  	return 0;
>  }
>  
> +static bool region_overlap(loff_t starta, loff_t lena,
> +                           loff_t startb, loff_t lenb)
> +{
> +        if (starta + lena <= startb)
> +                return 0;
> +        if (startb + lenb <= starta)
> +                return 0;
> +        return 1;
> +}

We already have this function in fs/devfs-core.c. Time to export it?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux