diff mbox series

[v5,05/10] mtd: spi-nor-core: Add the ->ready() hook

Message ID f0cdec6ad5cb31c742762f2376bf1a481480db41.1613622392.git.Takahiro.Kuwano@infineon.com
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t | expand

Commit Message

Takahiro Kuwano Feb. 19, 2021, 1:55 a.m. UTC
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>

For dual/quad die package devices from Spansion/Cypress, the device's
status needs to be checked by reading status registers in all dies, by
using Read Any Register command. To support this, a Flash specific hook
that can overwrite the legacy status check is needed.

The change in spi-nor.h depends on:
https://patchwork.ozlabs.org/project/uboot/patch/20210205041119.145784-4-seanga2@gmail.com/ 

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
Changes in v5:
  - Move spansion_sr_ready() to different patch
  - Move original code in spi_nor_ready() to newly created
    spi_nor_default_ready()

 drivers/mtd/spi/spi-nor-core.c | 10 +++++++++-
 include/linux/mtd/spi-nor.h    |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Pratyush Yadav Feb. 19, 2021, 9:57 a.m. UTC | #1
On 19/02/21 10:55AM, tkuw584924@gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
> 
> For dual/quad die package devices from Spansion/Cypress, the device's
> status needs to be checked by reading status registers in all dies, by
> using Read Any Register command. To support this, a Flash specific hook
> that can overwrite the legacy status check is needed.
> 
> The change in spi-nor.h depends on:
> https://patchwork.ozlabs.org/project/uboot/patch/20210205041119.145784-4-seanga2@gmail.com/ 

This line should not be a part of the commit message. This is "metadata" 
that says how the patch should be applied. One it is applied this has no 
use in the Git history. So it should go below the 3 dashed lines, like 
the changelog.

Other than this,

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Takahiro Kuwano March 8, 2021, 6:53 a.m. UTC | #2
On 2/19/2021 6:57 PM, Pratyush Yadav wrote:
> On 19/02/21 10:55AM, tkuw584924@gmail.com wrote:
>> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>>
>> For dual/quad die package devices from Spansion/Cypress, the device's
>> status needs to be checked by reading status registers in all dies, by
>> using Read Any Register command. To support this, a Flash specific hook
>> that can overwrite the legacy status check is needed.
>>
>> The change in spi-nor.h depends on:
>> https://patchwork.ozlabs.org/project/uboot/patch/20210205041119.145784-4-seanga2@gmail.com/ 
> 
> This line should not be a part of the commit message. This is "metadata" 
> that says how the patch should be applied. One it is applied this has no 
> use in the Git history. So it should go below the 3 dashed lines, like 
> the changelog.
> 
> Other than this,
> 
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
> 
I will make it goes below the "---" line. Thank you.
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 87c9fce408..821617bc0d 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -566,7 +566,7 @@  static int spi_nor_fsr_ready(struct spi_nor *nor)
 	return fsr & FSR_READY;
 }
 
-static int spi_nor_ready(struct spi_nor *nor)
+static int spi_nor_default_ready(struct spi_nor *nor)
 {
 	int sr, fsr;
 
@@ -579,6 +579,14 @@  static int spi_nor_ready(struct spi_nor *nor)
 	return sr && fsr;
 }
 
+static int spi_nor_ready(struct spi_nor *nor)
+{
+	if (nor->ready)
+		return nor->ready(nor);
+
+	return spi_nor_default_ready(nor);
+}
+
 /*
  * Service routine to read status register until ready, or timeout occurs.
  * Returns non-zero if error.
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index d79f8b37ef..2f2ad20e8e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -435,6 +435,7 @@  struct flash_info;
  * @flash_is_locked:	[FLASH-SPECIFIC] check if a region of the SPI NOR is
  *			completely locked
  * @quad_enable:	[FLASH-SPECIFIC] enables SPI NOR quad mode
+ * @ready:		[FLASH-SPECIFIC] check if the flash is ready
  * @priv:		the private data
  */
 struct spi_nor {
@@ -480,6 +481,7 @@  struct spi_nor {
 	int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
 	int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
 	int (*quad_enable)(struct spi_nor *nor);
+	int (*ready)(struct spi_nor *nor);
 
 	void *priv;
 /* Compatibility for spi_flash, remove once sf layer is merged with mtd */