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

Konrad Dybcio konrad.dybcio at oss.qualcomm.com
Mon Aug 4 02:04:22 PDT 2025


On 8/4/25 9:22 AM, Gabor Juhos wrote:
> 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?

That works too

Konrad



More information about the linux-mtd mailing list