Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: spi-nor: sst: Fix write enable before AAI sequence

When writing to SST flash starting at an odd address, a single byte is
first programmed using the byte program (BP) command. After this
operation completes, the flash hardware automatically clears the Write
Enable Latch (WEL) bit.

If an AAI (Auto Address Increment) word program sequence follows, it
requires WEL to be set. Without re-enabling writes, the AAI sequence
fails.

Add spi_nor_write_enable() after the odd-address byte program when more
data needs to be written. Use a local boolean for clarity.

Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
Tested-by: Hendrik Donner <hd@os-cillation.de>
Reviewed-by: Hendrik Donner <hd@os-cillation.de>
Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>

authored by

Sanjaikumar V S and committed by
Pratyush Yadav (Google)
a0f64241 5eb13017

+13
+13
drivers/mtd/spi-nor/sst.c
··· 203 203 204 204 /* Start write from odd address. */ 205 205 if (to % 2) { 206 + bool needs_write_enable = (len > 1); 207 + 206 208 /* write one byte. */ 207 209 ret = sst_nor_write_data(nor, to, 1, buf); 208 210 if (ret < 0) ··· 212 210 213 211 to++; 214 212 actual++; 213 + 214 + /* 215 + * Byte program clears the write enable latch. If more 216 + * data needs to be written using the AAI sequence, 217 + * re-enable writes. 218 + */ 219 + if (needs_write_enable) { 220 + ret = spi_nor_write_enable(nor); 221 + if (ret) 222 + goto out; 223 + } 215 224 } 216 225 217 226 /* Write out most of the data here. */