Re: [PATCH 02/13] mtd: spinand: winbond: Generalize the KV OOB layout

From: Dominique Martinet

Date: Fri Oct 30 2026 - 16:29:38 EST


Miquel Raynal wrote on Fri, Oct 30, 2026 at 06:45:26PM +0100:
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -318,16 +318,11 @@ static int w25n01kv_ooblayout_ecc(struct mtd_info *mtd, int section,
> return 0;
> }
>
> -static int w25n02kv_ooblayout_ecc(struct mtd_info *mtd, int section,
> - struct mtd_oob_region *region)
> +static int w25nxxkv_kw_ooblayout_ecc(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region)
> {
> - int num_sections = 4;
> - int offset = 64;
> -
> - if (mtd->oobsize == 256) {
> - num_sections = 8;
> - offset = 128;
> - }
> + unsigned int offset = mtd->oobsize / 2;
> + unsigned int num_sections = mtd->writesize / 512;

Ah, I couldn't use oobsize for num_sections because of W25N01KV but
using writesize makes sense as well as there's one section per 512 bytes
chunk, and this works for all devices.

Good cleanup!

Reviewed-by: Dominique Martinet <dominique.martinet@xxxxxxxxxxxxxxxxx>

--
Dominique