diff mbox series

[v2,5/6] mtd: spi-nor: Call spi_nor_post_sfdp_fixups() only after spi_nor_parse_sfdp()

Message ID b396511bbb406b980f9125b1692d7cb636f07ea0.1714020303.git.Takahiro.Kuwano@infineon.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series mtd: Make sure UBIFS does not do multi-pass page programming on flashes that don't support it | expand

Commit Message

Takahiro Kuwano April 25, 2024, 4:52 a.m. UTC
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>

spi_nor_post_sfdp_fixups() was called regardless of if
spi_nor_parse_sfdp() had been called or not. late_init() should be
instead used to initialize the parameters that are not defined in SFDP.

Ideally spi_nor_post_sfdp_fixups() is called only after successful parse
of SFDP. However, in case SFDP support is disabled by .config, that can
break current functionality. Therefore, we would call it after
spi_nor_parse_sfdp() regardless of its return value.

This patch follows the upstream linux commit:
5273cc6df984("mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only
when SFDP is defined")

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
 drivers/mtd/spi/spi-nor-core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Tudor Ambarus April 25, 2024, 6:16 a.m. UTC | #1
On 4/25/24 05:52, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> 
> spi_nor_post_sfdp_fixups() was called regardless of if
> spi_nor_parse_sfdp() had been called or not. late_init() should be
> instead used to initialize the parameters that are not defined in SFDP.
> 
> Ideally spi_nor_post_sfdp_fixups() is called only after successful parse
> of SFDP. However, in case SFDP support is disabled by .config, that can
> break current functionality. Therefore, we would call it after
> spi_nor_parse_sfdp() regardless of its return value.
> 
> This patch follows the upstream linux commit:
> 5273cc6df984("mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only
> when SFDP is defined")

this shall be the first information in the commit message.

Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
> 
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> ---
>  drivers/mtd/spi/spi-nor-core.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index fda879f3a3..ee968c10e4 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -190,11 +190,10 @@ struct sfdp_bfpt {
>  /**
>   * struct spi_nor_fixups - SPI NOR fixup hooks
>   * @post_bfpt: called after the BFPT table has been parsed
> - * @post_sfdp: called after SFDP has been parsed (is also called for SPI NORs
> - *             that do not support RDSFDP). Typically used to tweak various
> - *             parameters that could not be extracted by other means (i.e.
> - *             when information provided by the SFDP/flash_info tables are
> - *             incomplete or wrong).
> + * @post_sfdp: called after SFDP has been parsed. Typically used to tweak
> + *             various parameters that could not be extracted by other means
> + *             (i.e. when information provided by the SFDP tables are incomplete
> + *             or wrong).
>   * @late_init: used to initialize flash parameters that are not declared in the
>   *             JESD216 SFDP standard, or where SFDP tables not defined at all.
>   *
> @@ -2760,13 +2759,12 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
>  
>  /**
>   * spi_nor_post_sfdp_fixups() - Updates the flash's parameters and settings
> - * after SFDP has been parsed (is also called for SPI NORs that do not
> - * support RDSFDP).
> + * after SFDP has been parsed.
>   * @nor:	pointer to a 'struct spi_nor'
>   *
>   * Typically used to tweak various parameters that could not be extracted by
> - * other means (i.e. when information provided by the SFDP/flash_info tables
> - * are incomplete or wrong).
> + * other means (i.e. when information provided by the SFDP tables are incomplete
> + * or wrong).
>   */
>  static void spi_nor_post_sfdp_fixups(struct spi_nor *nor,
>  				     struct spi_nor_flash_parameter *params)
> @@ -2901,9 +2899,10 @@ static int spi_nor_init_params(struct spi_nor *nor,
>  		} else {
>  			memcpy(params, &sfdp_params, sizeof(*params));
>  		}
> +
> +		spi_nor_post_sfdp_fixups(nor, params);
>  	}
>  
> -	spi_nor_post_sfdp_fixups(nor, params);
>  	spi_nor_late_init_fixups(nor, params);
>  
>  	return 0;
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index fda879f3a3..ee968c10e4 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -190,11 +190,10 @@  struct sfdp_bfpt {
 /**
  * struct spi_nor_fixups - SPI NOR fixup hooks
  * @post_bfpt: called after the BFPT table has been parsed
- * @post_sfdp: called after SFDP has been parsed (is also called for SPI NORs
- *             that do not support RDSFDP). Typically used to tweak various
- *             parameters that could not be extracted by other means (i.e.
- *             when information provided by the SFDP/flash_info tables are
- *             incomplete or wrong).
+ * @post_sfdp: called after SFDP has been parsed. Typically used to tweak
+ *             various parameters that could not be extracted by other means
+ *             (i.e. when information provided by the SFDP tables are incomplete
+ *             or wrong).
  * @late_init: used to initialize flash parameters that are not declared in the
  *             JESD216 SFDP standard, or where SFDP tables not defined at all.
  *
@@ -2760,13 +2759,12 @@  static int spi_nor_parse_sfdp(struct spi_nor *nor,
 
 /**
  * spi_nor_post_sfdp_fixups() - Updates the flash's parameters and settings
- * after SFDP has been parsed (is also called for SPI NORs that do not
- * support RDSFDP).
+ * after SFDP has been parsed.
  * @nor:	pointer to a 'struct spi_nor'
  *
  * Typically used to tweak various parameters that could not be extracted by
- * other means (i.e. when information provided by the SFDP/flash_info tables
- * are incomplete or wrong).
+ * other means (i.e. when information provided by the SFDP tables are incomplete
+ * or wrong).
  */
 static void spi_nor_post_sfdp_fixups(struct spi_nor *nor,
 				     struct spi_nor_flash_parameter *params)
@@ -2901,9 +2899,10 @@  static int spi_nor_init_params(struct spi_nor *nor,
 		} else {
 			memcpy(params, &sfdp_params, sizeof(*params));
 		}
+
+		spi_nor_post_sfdp_fixups(nor, params);
 	}
 
-	spi_nor_post_sfdp_fixups(nor, params);
 	spi_nor_late_init_fixups(nor, params);
 
 	return 0;