[riot-notifications] [RIOT-OS/RIOT] driver/mtd_spi_nor: fix erase with unaligned addresses (#8400)

Sebastian Meiling notifications at github.com
Tue Feb 6 09:55:00 CET 2018


smlng requested changes on this pull request.

minor nits, otherwise looks good

>          return -EOVERFLOW;
     }
-    else {
-        for (size_t i = 0; i < size / sector_size; i++) {
+
+    while (size) {
+        be_uint32_t addr_be = byteorder_htonl(addr);
+        /* write enable */
+        mtd_spi_cmd(dev, dev->opcode->wren);
+
+        if (size == total_size) {
+            mtd_spi_cmd(dev, dev->opcode->chip_erase);
+            size -= total_size;
+        }
+        else if ((dev->flag & SPI_NOR_F_SECT_32K) && (size >= 32768) && ((addr & 0x7FFF) == 0)) {
+            /* 32 KiO sectors can be erased with sector erase command */

from the command below I'd infer it should be /sector/block/, right?

>          return -EOVERFLOW;
     }
-    else {
-        for (size_t i = 0; i < size / sector_size; i++) {
+
+    while (size) {
+        be_uint32_t addr_be = byteorder_htonl(addr);
+        /* write enable */
+        mtd_spi_cmd(dev, dev->opcode->wren);
+
+        if (size == total_size) {
+            mtd_spi_cmd(dev, dev->opcode->chip_erase);

you could move this special case above the loop, to avoid some unneeded ops, but I'm okay with leaving this in the _loop_

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/8400#pullrequestreview-94260996
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20180206/cc7da384/attachment.html>


More information about the notifications mailing list