[riot-notifications] [RIOT-OS/RIOT] mtd: fix mtd_write_page() across sector boundaries (#16848)

benpicco notifications at github.com
Tue Sep 21 10:18:09 CEST 2021


@benpicco commented on this pull request.



> +}
+
+int mtd_write_page(mtd_dev_t *mtd, const void *data, uint32_t page,
+                   uint32_t offset, uint32_t len)
+{
+    if (!mtd || !mtd->driver) {
+        return -ENODEV;
+    }
+
+    if (mtd->work_area == NULL) {
+        return mtd_write_page_raw(mtd, data, page, offset, len);
+    }
+
+    uint32_t sector = page / mtd->pages_per_sector;
+    const uint32_t sector_page = sector * mtd->pages_per_sector;
+    const char *_src = data;

I did that elsewhere when the function itself have a `src` parameter, but that's not the case here - can remove it.

-- 
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/16848#discussion_r712808782
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210921/4585ece3/attachment.htm>


More information about the notifications mailing list