aboutsummaryrefslogtreecommitdiff
path: root/spiflash_n25q128.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-02-20 19:51:03 -0500
committerPaul Selkirk <paul@psgd.org>2017-02-20 19:52:19 -0500
commit0c298a1c2d0ab40760bf38b27fec43d8b8f3afb5 (patch)
treed86ff70d09a6e422e005da8c2e780b3929ac79c0 /spiflash_n25q128.c
parente9011a1ae42333fdcbebf9b85ced6ea942f3547c (diff)
Move dangerous auto_erase functionality to where it's actually used.
Diffstat (limited to 'spiflash_n25q128.c')
-rw-r--r--spiflash_n25q128.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/spiflash_n25q128.c b/spiflash_n25q128.c
index 35a2fcf..133ecb4 100644
--- a/spiflash_n25q128.c
+++ b/spiflash_n25q128.c
@@ -360,8 +360,10 @@ static int _n25q128_get_wel_flag(struct spiflash_ctx *ctx)
}
-/* This function performs erasure if needed, and then writing of a number of pages to the flash memory */
-int n25q128_write_data(struct spiflash_ctx *ctx, uint32_t offset, const uint8_t *buf, const uint32_t len, const int auto_erase)
+/* This function writes of a number of pages to the flash memory.
+ * The caller is responsible for ensuring that the pages have been erased.
+ */
+int n25q128_write_data(struct spiflash_ctx *ctx, uint32_t offset, const uint8_t *buf, const uint32_t len)
{
uint32_t page;
@@ -369,21 +371,6 @@ int n25q128_write_data(struct spiflash_ctx *ctx, uint32_t offset, const uint8_t
if ((offset % N25Q128_PAGE_SIZE) != 0) return -1;
if ((len % N25Q128_PAGE_SIZE) != 0) return -2;
- if (auto_erase && (offset % N25Q128_SECTOR_SIZE) == 0) {
- /*
- * first page in sector, need to erase sector
- *
- * So why do we only do this when the buffer starts on the
- * sector, as opposed to performing this check for every page?
- * Also, might be better to do this by subsectors rather than
- * sectors.
- */
-
- if (! n25q128_erase_sector(ctx, offset / N25Q128_SECTOR_SIZE)) {
- return -4;
- }
- }
-
for (page = 0; page < len / N25Q128_PAGE_SIZE; page++) {
if (! n25q128_write_page(ctx, offset / N25Q128_PAGE_SIZE, buf)) {
return -6;