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

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jul 30 04:10:05 PDT 2024


On 30.07.24 10:55, Sascha Hauer wrote:
> 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 at pengutronix.de>
>> ---
>>  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?

This used to be exported, but the export was removed in commit
04e2aa516ed5 ("common.h: move and rename lregion_overlap()").

I can add it back if you prefer.


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




More information about the barebox mailing list