[PATCH] spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties

Gabor Juhos j4g8y7 at gmail.com
Mon Aug 4 00:22:06 PDT 2025


Hi Konrad,

2025. 08. 01. 13:56 keltezéssel, Konrad Dybcio írta:
> On 7/31/25 8:11 PM, Gabor Juhos wrote:

...

>> --- a/drivers/spi/spi-qpic-snand.c
>> +++ b/drivers/spi/spi-qpic-snand.c
>> @@ -213,8 +213,16 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section,
>>  	if (section > 1)
>>  		return -ERANGE;
>>  
>> -	oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes;
>> -	oobregion->offset = mtd->oobsize - oobregion->length;
>> +	if (!section) {
>> +		oobregion->offset = 0;
>> +		oobregion->length = qecc->bytes * (qecc->steps - 1) +
>> +				    qecc->bbm_size;
>> +	} else {
>> +		oobregion->offset = qecc->bytes * (qecc->steps - 1) +
>> +				    qecc->bbm_size +
>> +				    qecc->steps * 4;
>> +		oobregion->length = mtd->oobsize - oobregion->offset;
>> +	}
> 
> How about
> 
> if (section == 0) {
> } else if (section == 1) {
> } else { return -ERANGE }
> 
> ?

The current way follows the implementation in the qcom_nandc driver, so it makes
it easier to compare the two, but it can be changed of course.

However, since the 'section' parameter is an integer can we agree up on using a
switch statement instead of multiple ifs?

Regards,
Gabor



More information about the linux-mtd mailing list