[PATCH 1/6] mtd: rawnand: sunxi: fix sunxi_nand_ooblayout_free

Richard Genoud posted 6 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH 1/6] mtd: rawnand: sunxi: fix sunxi_nand_ooblayout_free
Posted by Richard Genoud 1 month, 1 week ago
The available length is really USER_DATA_LEN - 2 instead of just 2 (the
user data length minus the BBM length)
That doesn't change anything now, but if USER_DATA_LEN changes, it will.

Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
---
 drivers/mtd/nand/raw/sunxi_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 9dcdc93734cb..c420909b944b 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -1761,12 +1761,12 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,
 
 	/*
 	 * The first 2 bytes are used for BB markers, hence we
-	 * only have 2 bytes available in the first user data
+	 * only have USER_DATA_SZ - 2 bytes available in the first user data
 	 * section.
 	 */
 	if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) {
 		oobregion->offset = 2;
-		oobregion->length = 2;
+		oobregion->length = USER_DATA_SZ - 2;
 
 		return 0;
 	}
Re: [PATCH 1/6] mtd: rawnand: sunxi: fix sunxi_nand_ooblayout_free
Posted by Jernej Škrabec 1 month, 1 week ago
Dne petek, 20. februar 2026 ob 17:10:06 Srednjeevropski standardni čas je Richard Genoud napisal(a):
> The available length is really USER_DATA_LEN - 2 instead of just 2 (the
> user data length minus the BBM length)
> That doesn't change anything now, but if USER_DATA_LEN changes, it will.

s/USER_DATA_LEN/USER_DATA_SZ/

> 
> Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>

If this is really a fix as subject suggest, then Fixes tag is in order. However,
this looks more like code refactor as end result is the same. So maybe
reword subject?

Best regards,
Jernej

> ---
>  drivers/mtd/nand/raw/sunxi_nand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 9dcdc93734cb..c420909b944b 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -1761,12 +1761,12 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,
>  
>  	/*
>  	 * The first 2 bytes are used for BB markers, hence we
> -	 * only have 2 bytes available in the first user data
> +	 * only have USER_DATA_SZ - 2 bytes available in the first user data
>  	 * section.
>  	 */
>  	if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) {
>  		oobregion->offset = 2;
> -		oobregion->length = 2;
> +		oobregion->length = USER_DATA_SZ - 2;
>  
>  		return 0;
>  	}
> 
Re: [PATCH 1/6] mtd: rawnand: sunxi: fix sunxi_nand_ooblayout_free
Posted by Richard GENOUD 4 weeks, 1 day ago
Le 21/02/2026 à 10:13, Jernej Škrabec a écrit :
> Dne petek, 20. februar 2026 ob 17:10:06 Srednjeevropski standardni čas je Richard Genoud napisal(a):
>> The available length is really USER_DATA_LEN - 2 instead of just 2 (the
>> user data length minus the BBM length)
>> That doesn't change anything now, but if USER_DATA_LEN changes, it will.
> 
> s/USER_DATA_LEN/USER_DATA_SZ/
> 
>>
>> Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
> 
> If this is really a fix as subject suggest, then Fixes tag is in order. However,
> this looks more like code refactor as end result is the same. So maybe
> reword subject?
Yes, it's more a code clarification, I'll reword that.

Thanks!

> 
> Best regards,
> Jernej
> 
>> ---
>>   drivers/mtd/nand/raw/sunxi_nand.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
>> index 9dcdc93734cb..c420909b944b 100644
>> --- a/drivers/mtd/nand/raw/sunxi_nand.c
>> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
>> @@ -1761,12 +1761,12 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,
>>   
>>   	/*
>>   	 * The first 2 bytes are used for BB markers, hence we
>> -	 * only have 2 bytes available in the first user data
>> +	 * only have USER_DATA_SZ - 2 bytes available in the first user data
>>   	 * section.
>>   	 */
>>   	if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) {
>>   		oobregion->offset = 2;
>> -		oobregion->length = 2;
>> +		oobregion->length = USER_DATA_SZ - 2;
>>   
>>   		return 0;
>>   	}
>>
> 
> 
> 
>