[PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format

Michael Walle posted 41 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format
Posted by Michael Walle 2 years, 3 months ago
The INFOx() macros are going away. Convert the flash_info database to
the new format.

Signed-off-by: Michael Walle <mwalle@kernel.org>
---
 drivers/mtd/spi-nor/atmel.c | 122 +++++++++++++++++++++++++++++---------------
 1 file changed, 80 insertions(+), 42 deletions(-)

diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c
index d2de2cb0c066..ccc985c48ae3 100644
--- a/drivers/mtd/spi-nor/atmel.c
+++ b/drivers/mtd/spi-nor/atmel.c
@@ -163,48 +163,86 @@ static const struct spi_nor_fixups atmel_nor_global_protection_fixups = {
 };
 
 static const struct flash_info atmel_nor_parts[] = {
-	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4)
-		FLAGS(SPI_NOR_HAS_LOCK)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &at25fs_nor_fixups },
-	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8)
-		FLAGS(SPI_NOR_HAS_LOCK)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &at25fs_nor_fixups },
-	{ "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at25df321",  INFO(0x1f4700, 0, 64 * 1024,  64)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at25df321a", INFO(0x1f4701, 0, 64 * 1024,  64)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at25sl321",	INFO(0x1f4216, 0, 64 * 1024, 64)
-		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
-	{ "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8)
-		NO_SFDP_FLAGS(SECT_4K) },
-	{ "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at26df321",  INFO(0x1f4700, 0, 64 * 1024, 64)
-		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
-		NO_SFDP_FLAGS(SECT_4K)
-		.fixups = &atmel_nor_global_protection_fixups },
-	{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16)
-		NO_SFDP_FLAGS(SECT_4K) },
+	{
+		.id = SNOR_ID(0x1f, 0x66, 0x01),
+		.name = "at25fs010",
+		.sector_size = SZ_32K,
+		.size = SZ_128K,
+		.flags = SPI_NOR_HAS_LOCK,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &at25fs_nor_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x66, 0x04),
+		.name = "at25fs040",
+		.size = SZ_512K,
+		.flags = SPI_NOR_HAS_LOCK,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &at25fs_nor_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x44, 0x01),
+		.name = "at25df041a",
+		.size = SZ_512K,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups,
+	}, {
+		.id = SNOR_ID(0x1f, 0x47, 0x00),
+		.name = "at25df321",
+		.size = SZ_4M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x47, 0x01),
+		.name = "at25df321a",
+		.size = SZ_4M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x48, 0x00),
+		.name = "at25df641",
+		.size = SZ_8M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x42, 0x16),
+		.name = "at25sl321",
+		.size = SZ_4M,
+		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
+	}, {
+		.id = SNOR_ID(0x1f, 0x04, 0x00),
+		.name = "at26f004",
+		.size = SZ_512K,
+		.no_sfdp_flags = SECT_4K,
+	}, {
+		.id = SNOR_ID(0x1f, 0x45, 0x01),
+		.name = "at26df081a",
+		.size = SZ_1M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x46, 0x01),
+		.name = "at26df161a",
+		.size = SZ_2M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x47, 0x00),
+		.name = "at26df321",
+		.size = SZ_4M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+		.no_sfdp_flags = SECT_4K,
+		.fixups = &atmel_nor_global_protection_fixups
+	}, {
+		.id = SNOR_ID(0x1f, 0x25, 0x00),
+		.name = "at45db081d",
+		.size = SZ_1M,
+		.no_sfdp_flags = SECT_4K,
+	},
 };
 
 const struct spi_nor_manufacturer spi_nor_atmel = {

-- 
2.39.2
Re: [PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format
Posted by Tudor Ambarus 2 years, 3 months ago

On 22.08.2023 10:09, Michael Walle wrote:
> The INFOx() macros are going away. Convert the flash_info database to
> the new format.
> 
> Signed-off-by: Michael Walle <mwalle@kernel.org>
> ---
>  drivers/mtd/spi-nor/atmel.c | 122 +++++++++++++++++++++++++++++---------------
>  1 file changed, 80 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c
> index d2de2cb0c066..ccc985c48ae3 100644
> --- a/drivers/mtd/spi-nor/atmel.c
> +++ b/drivers/mtd/spi-nor/atmel.c
> @@ -163,48 +163,86 @@ static const struct spi_nor_fixups atmel_nor_global_protection_fixups = {
>  };
>  
>  static const struct flash_info atmel_nor_parts[] = {
> -	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4)
> -		FLAGS(SPI_NOR_HAS_LOCK)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &at25fs_nor_fixups },
> -	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8)
> -		FLAGS(SPI_NOR_HAS_LOCK)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &at25fs_nor_fixups },
> -	{ "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at25df321",  INFO(0x1f4700, 0, 64 * 1024,  64)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at25df321a", INFO(0x1f4701, 0, 64 * 1024,  64)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at25sl321",	INFO(0x1f4216, 0, 64 * 1024, 64)
> -		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
> -	{ "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8)
> -		NO_SFDP_FLAGS(SECT_4K) },
> -	{ "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at26df321",  INFO(0x1f4700, 0, 64 * 1024, 64)
> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
> -		NO_SFDP_FLAGS(SECT_4K)
> -		.fixups = &atmel_nor_global_protection_fixups },
> -	{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16)
> -		NO_SFDP_FLAGS(SECT_4K) },
> +	{
> +		.id = SNOR_ID(0x1f, 0x66, 0x01),
> +		.name = "at25fs010",

nitpick, we shall respect the order of the members declared in
flash_info struct.

And I'll let you double check if the conversion is accurate :D.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

> +		.sector_size = SZ_32K,
> +		.size = SZ_128K,
> +		.flags = SPI_NOR_HAS_LOCK,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &at25fs_nor_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x66, 0x04),
> +		.name = "at25fs040",
> +		.size = SZ_512K,
> +		.flags = SPI_NOR_HAS_LOCK,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &at25fs_nor_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x44, 0x01),
> +		.name = "at25df041a",
> +		.size = SZ_512K,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups,
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x47, 0x00),
> +		.name = "at25df321",
> +		.size = SZ_4M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x47, 0x01),
> +		.name = "at25df321a",
> +		.size = SZ_4M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x48, 0x00),
> +		.name = "at25df641",
> +		.size = SZ_8M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x42, 0x16),
> +		.name = "at25sl321",
> +		.size = SZ_4M,
> +		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x04, 0x00),
> +		.name = "at26f004",
> +		.size = SZ_512K,
> +		.no_sfdp_flags = SECT_4K,
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x45, 0x01),
> +		.name = "at26df081a",
> +		.size = SZ_1M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x46, 0x01),
> +		.name = "at26df161a",
> +		.size = SZ_2M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x47, 0x00),
> +		.name = "at26df321",
> +		.size = SZ_4M,
> +		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
> +		.no_sfdp_flags = SECT_4K,
> +		.fixups = &atmel_nor_global_protection_fixups
> +	}, {
> +		.id = SNOR_ID(0x1f, 0x25, 0x00),
> +		.name = "at45db081d",
> +		.size = SZ_1M,
> +		.no_sfdp_flags = SECT_4K,
> +	},
>  };
>  
>  const struct spi_nor_manufacturer spi_nor_atmel = {
>
Re: [PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format
Posted by Michael Walle 2 years, 3 months ago
>> +	{
>> +		.id = SNOR_ID(0x1f, 0x66, 0x01),
>> +		.name = "at25fs010",
> 
> nitpick, we shall respect the order of the members declared in
> flash_info struct.

As mentioned in my first reply, you're fine with keeping the id
first? After this series, we can swap the name and id members in
struct flash_info.

For all the other members, they should be used consistently. So
we could also swap the members in flash_info.

> And I'll let you double check if the conversion is accurate :D.
> 
> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>

So I'll convert that one in an Acked-by: for all the conversion
patches?

-michael
Re: [PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format
Posted by Tudor Ambarus 2 years, 3 months ago

On 9/7/23 09:13, Michael Walle wrote:
>>> +    {
>>> +        .id = SNOR_ID(0x1f, 0x66, 0x01),
>>> +        .name = "at25fs010",
>>
>> nitpick, we shall respect the order of the members declared in
>> flash_info struct.
> 
> As mentioned in my first reply, you're fine with keeping the id
> first? After this series, we can swap the name and id members in
> struct flash_info.
> 
> For all the other members, they should be used consistently. So
> we could also swap the members in flash_info.

I'm ok, sounds good.
> 
>> And I'll let you double check if the conversion is accurate :D.
>>
>> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> 
> So I'll convert that one in an Acked-by: for all the conversion
> patches?
> 

No, I'll add them afterwards, I'd like to check what I skipped on first
review.
Re: [PATCH v2 17/41] mtd: spi-nor: atmel: convert flash_info to new format
Posted by Michael Walle 2 years, 3 months ago
Am 2023-09-06 09:35, schrieb Tudor Ambarus:
> On 22.08.2023 10:09, Michael Walle wrote:
>> The INFOx() macros are going away. Convert the flash_info database to
>> the new format.
>> 
>> Signed-off-by: Michael Walle <mwalle@kernel.org>
>> ---
>>  drivers/mtd/spi-nor/atmel.c | 122 
>> +++++++++++++++++++++++++++++---------------
>>  1 file changed, 80 insertions(+), 42 deletions(-)
>> 
>> diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c
>> index d2de2cb0c066..ccc985c48ae3 100644
>> --- a/drivers/mtd/spi-nor/atmel.c
>> +++ b/drivers/mtd/spi-nor/atmel.c
>> @@ -163,48 +163,86 @@ static const struct spi_nor_fixups 
>> atmel_nor_global_protection_fixups = {
>>  };
>> 
>>  static const struct flash_info atmel_nor_parts[] = {
>> -	{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4)
>> -		FLAGS(SPI_NOR_HAS_LOCK)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &at25fs_nor_fixups },
>> -	{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8)
>> -		FLAGS(SPI_NOR_HAS_LOCK)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &at25fs_nor_fixups },
>> -	{ "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at25df321",  INFO(0x1f4700, 0, 64 * 1024,  64)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at25df321a", INFO(0x1f4701, 0, 64 * 1024,  64)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at25sl321",	INFO(0x1f4216, 0, 64 * 1024, 64)
>> -		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
>> -	{ "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8)
>> -		NO_SFDP_FLAGS(SECT_4K) },
>> -	{ "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at26df321",  INFO(0x1f4700, 0, 64 * 1024, 64)
>> -		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE)
>> -		NO_SFDP_FLAGS(SECT_4K)
>> -		.fixups = &atmel_nor_global_protection_fixups },
>> -	{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16)
>> -		NO_SFDP_FLAGS(SECT_4K) },
>> +	{
>> +		.id = SNOR_ID(0x1f, 0x66, 0x01),
>> +		.name = "at25fs010",
> 
> nitpick, we shall respect the order of the members declared in
> flash_info struct.

The id is the first one on purpose, because that's our main
key to the entry. I couldn't swap the properties in flash_info
yet because the old entry style used also positional parameters,
i.e. the first entry was always the name.

> And I'll let you double check if the conversion is accurate :D.

See the cover letter for the objdump trick :)

-michael