diff options
author | Jonas Gorski <jonas.gorski@gmail.com> | 2017-02-07 12:01:46 +0100 |
---|---|---|
committer | Jonas Gorski <jonas.gorski@gmail.com> | 2017-06-04 10:40:00 +0200 |
commit | 2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c (patch) | |
tree | 0ff5bf45a97c1f307913cff42583bbd92c7233fd /target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch | |
parent | f62e02cf20c23b55e998edf6874c1a5de3a88c6d (diff) | |
download | upstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.tar.gz upstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.tar.bz2 upstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.zip |
brcm63xx: backport upstream solution for SPI message size limits
Backport upstream solution for working around SPI controller maximum
message sizes.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Diffstat (limited to 'target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch')
-rw-r--r-- | target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch b/target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch new file mode 100644 index 0000000000..0bdcccfdf6 --- /dev/null +++ b/target/linux/brcm63xx/patches-4.4/000-4.8-06-mtd-spi-nor-check-return-value-from-write.patch @@ -0,0 +1,118 @@ +From 0bad7b9304d543dd7627f4cd564aea5d7338b950 Mon Sep 17 00:00:00 2001 +From: Michal Suchanek <hramrach@gmail.com> +Date: Thu, 5 May 2016 17:31:52 -0700 +Subject: [PATCH 06/10] mtd: spi-nor: check return value from write + +SPI NOR hardware drivers now return useful value from their write +functions so check them. + +Signed-off-by: Michal Suchanek <hramrach@gmail.com> +Signed-off-by: Brian Norris <computersforpeace@gmail.com> +Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com> +Acked-by: Michal Suchanek <hramrach@gmail.com> +Tested-by: Michal Suchanek <hramrach@gmail.com> +--- + drivers/mtd/spi-nor/spi-nor.c | 45 ++++++++++++++++++++++++++++++------------- + 1 file changed, 32 insertions(+), 13 deletions(-) + +--- a/drivers/mtd/spi-nor/spi-nor.c ++++ b/drivers/mtd/spi-nor/spi-nor.c +@@ -922,10 +922,14 @@ static int sst_write(struct mtd_info *mt + nor->program_opcode = SPINOR_OP_BP; + + /* write one byte. */ +- nor->write(nor, to, 1, retlen, buf); ++ ret = nor->write(nor, to, 1, retlen, buf); ++ if (ret < 0) ++ goto sst_write_err; ++ WARN(ret != 1, "While writing 1 byte written %i bytes\n", ++ (int)ret); + ret = spi_nor_wait_till_ready(nor); + if (ret) +- goto time_out; ++ goto sst_write_err; + } + to += actual; + +@@ -934,10 +938,14 @@ static int sst_write(struct mtd_info *mt + nor->program_opcode = SPINOR_OP_AAI_WP; + + /* write two bytes. */ +- nor->write(nor, to, 2, retlen, buf + actual); ++ ret = nor->write(nor, to, 2, retlen, buf + actual); ++ if (ret < 0) ++ goto sst_write_err; ++ WARN(ret != 2, "While writing 2 bytes written %i bytes\n", ++ (int)ret); + ret = spi_nor_wait_till_ready(nor); + if (ret) +- goto time_out; ++ goto sst_write_err; + to += 2; + nor->sst_write_second = true; + } +@@ -946,21 +954,24 @@ static int sst_write(struct mtd_info *mt + write_disable(nor); + ret = spi_nor_wait_till_ready(nor); + if (ret) +- goto time_out; ++ goto sst_write_err; + + /* Write out trailing byte if it exists. */ + if (actual != len) { + write_enable(nor); + + nor->program_opcode = SPINOR_OP_BP; +- nor->write(nor, to, 1, retlen, buf + actual); +- ++ ret = nor->write(nor, to, 1, retlen, buf + actual); ++ if (ret < 0) ++ goto sst_write_err; ++ WARN(ret != 1, "While writing 1 byte written %i bytes\n", ++ (int)ret); + ret = spi_nor_wait_till_ready(nor); + if (ret) +- goto time_out; ++ goto sst_write_err; + write_disable(nor); + } +-time_out: ++sst_write_err: + spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE); + return ret; + } +@@ -989,14 +1000,18 @@ static int spi_nor_write(struct mtd_info + + /* do all the bytes fit onto one page? */ + if (page_offset + len <= nor->page_size) { +- nor->write(nor, to, len, retlen, buf); ++ ret = nor->write(nor, to, len, retlen, buf); ++ if (ret < 0) ++ goto write_err; + } else { + /* the size of data remaining on the first page */ + page_size = nor->page_size - page_offset; +- nor->write(nor, to, page_size, retlen, buf); ++ ret = nor->write(nor, to, page_size, retlen, buf); ++ if (ret < 0) ++ goto write_err; + + /* write everything in nor->page_size chunks */ +- for (i = page_size; i < len; i += page_size) { ++ for (i = ret; i < len; ) { + page_size = len - i; + if (page_size > nor->page_size) + page_size = nor->page_size; +@@ -1007,7 +1022,11 @@ static int spi_nor_write(struct mtd_info + + write_enable(nor); + +- nor->write(nor, to + i, page_size, retlen, buf + i); ++ ret = nor->write(nor, to + i, page_size, retlen, ++ buf + i); ++ if (ret < 0) ++ goto write_err; ++ i += ret; + } + } + |