diff mbox series

[v5,01/14] mtd: spi-nor: Fix mtd size for s3an flashes

Message ID 20211203142256.47370-2-tudor.ambarus@microchip.com (mailing list archive)
State New, archived
Headers show
Series mtd: spi-nor: Clean params init | expand

Commit Message

Tudor Ambarus Dec. 3, 2021, 2:22 p.m. UTC
As it was before the blamed commit, s3an_nor_scan() was called
after mtd size was set with params->size, and it overwrote the mtd
size value with '8 * nor->page_size * nor->info->n_sectors' when
XSR_PAGESIZE was set. With the introduction of
s3an_post_sfdp_fixups(), we missed to update the mtd size for the
s3an flashes. Fix the mtd size by updating both nor->params->size,
(which will update the mtd_info size later on) and nor->mtd.size
(which is used in spi_nor_set_addr_width()).

Fixes: 641edddb4f43 ("mtd: spi-nor: Add s3an_post_sfdp_fixups()")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/mtd/spi-nor/xilinx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pratyush Yadav Dec. 6, 2021, 11:54 a.m. UTC | #1
On 03/12/21 04:22PM, Tudor Ambarus wrote:
> As it was before the blamed commit, s3an_nor_scan() was called
> after mtd size was set with params->size, and it overwrote the mtd
> size value with '8 * nor->page_size * nor->info->n_sectors' when
> XSR_PAGESIZE was set. With the introduction of
> s3an_post_sfdp_fixups(), we missed to update the mtd size for the
> s3an flashes. Fix the mtd size by updating both nor->params->size,
> (which will update the mtd_info size later on) and nor->mtd.size
> (which is used in spi_nor_set_addr_width()).
> 
> Fixes: 641edddb4f43 ("mtd: spi-nor: Add s3an_post_sfdp_fixups()")
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>  drivers/mtd/spi-nor/xilinx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c
> index 7e970ccf7903..03d3b006a039 100644
> --- a/drivers/mtd/spi-nor/xilinx.c
> +++ b/drivers/mtd/spi-nor/xilinx.c
> @@ -69,7 +69,8 @@ static int xilinx_nor_setup(struct spi_nor *nor,
>  		page_size = (nor->params->page_size == 264) ? 256 : 512;
>  		nor->params->page_size = page_size;
>  		nor->mtd.writebufsize = page_size;
> -		nor->mtd.size = 8 * page_size * nor->info->n_sectors;
> +		nor->params->size = 8 * page_size * nor->info->n_sectors;
> +		nor->mtd.size = nor->params->size;

I supposed you could just have done this in patch 2 directly, but this 
is fine too.

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Tudor Ambarus Dec. 6, 2021, 2:40 p.m. UTC | #2
On 12/6/21 1:54 PM, Pratyush Yadav wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 03/12/21 04:22PM, Tudor Ambarus wrote:
>> As it was before the blamed commit, s3an_nor_scan() was called
>> after mtd size was set with params->size, and it overwrote the mtd
>> size value with '8 * nor->page_size * nor->info->n_sectors' when
>> XSR_PAGESIZE was set. With the introduction of
>> s3an_post_sfdp_fixups(), we missed to update the mtd size for the
>> s3an flashes. Fix the mtd size by updating both nor->params->size,
>> (which will update the mtd_info size later on) and nor->mtd.size
>> (which is used in spi_nor_set_addr_width()).
>>
>> Fixes: 641edddb4f43 ("mtd: spi-nor: Add s3an_post_sfdp_fixups()")
>> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
>> ---
>>  drivers/mtd/spi-nor/xilinx.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c
>> index 7e970ccf7903..03d3b006a039 100644
>> --- a/drivers/mtd/spi-nor/xilinx.c
>> +++ b/drivers/mtd/spi-nor/xilinx.c
>> @@ -69,7 +69,8 @@ static int xilinx_nor_setup(struct spi_nor *nor,
>>               page_size = (nor->params->page_size == 264) ? 256 : 512;
>>               nor->params->page_size = page_size;
>>               nor->mtd.writebufsize = page_size;
>> -             nor->mtd.size = 8 * page_size * nor->info->n_sectors;
>> +             nor->params->size = 8 * page_size * nor->info->n_sectors;
>> +             nor->mtd.size = nor->params->size;
> 
> I supposed you could just have done this in patch 2 directly, but this
> is fine too.

I've done it in a separate patch because this can be backported as a fix.
I will drop the Fixes tag from patch 2/14, the tag is just a leftover.

> 
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
> 
> --
> Regards,
> Pratyush Yadav
> Texas Instruments Inc.
>
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/xilinx.c b/drivers/mtd/spi-nor/xilinx.c
index 7e970ccf7903..03d3b006a039 100644
--- a/drivers/mtd/spi-nor/xilinx.c
+++ b/drivers/mtd/spi-nor/xilinx.c
@@ -69,7 +69,8 @@  static int xilinx_nor_setup(struct spi_nor *nor,
 		page_size = (nor->params->page_size == 264) ? 256 : 512;
 		nor->params->page_size = page_size;
 		nor->mtd.writebufsize = page_size;
-		nor->mtd.size = 8 * page_size * nor->info->n_sectors;
+		nor->params->size = 8 * page_size * nor->info->n_sectors;
+		nor->mtd.size = nor->params->size;
 		nor->mtd.erasesize = 8 * page_size;
 	} else {
 		/* Flash in Default addressing mode */