[riot-notifications] [RIOT-OS/RIOT] drivers/at24cxxx: MTD wrapper for at24cxxx (#14110)

benpicco notifications at github.com
Tue May 26 10:37:59 CEST 2020

@benpicco commented on this pull request.

> +    assert(PARAMS(mtd));
+    int init = at24cxxx_init(DEV(mtd), PARAMS(mtd));
+    if (init != AT24CXXX_OK) {
+        return init;
+    }
+    mtd->page_size = DEV(mtd)->params.page_size;
+    mtd->pages_per_sector = 1;
+    mtd->sector_count = DEV(mtd)->params.eeprom_size /
+                        DEV(mtd)->params.page_size;
+    return 0;
+static int _mtd_at24cxxx_read(mtd_dev_t *mtd, void *dest, uint32_t addr,
+                              uint32_t size)
+    return at24cxxx_read(DEV(mtd), addr, dest, size) == AT24CXXX_OK ? 0 : -EIO;

tbh I was also hoping to get some consistency that way, e.g. that the user can expect the same error values from MTD and the device itself.

right now `mtd_read()` will return

> `-EOVERFLOW if addr or count are not valid, i.e. outside memory`

and `at24cxxx_read()` returns 

> `-ERANGE if pos + len is out of bounds`

Maybe there is a reason for that, but at a glance this looks inconsistent. 

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200526/90cf828d/attachment.htm>

More information about the notifications mailing list