[riot-notifications] [RIOT-OS/RIOT] Driver for AT24CXXX EEPROM (#11929)

benpicco notifications at github.com
Wed Jul 31 23:51:11 CEST 2019


benpicco commented on this pull request.



> +
+#include "include/at24cxxx_params.h"
+#include "include/at24cxxx_defines.h"
+#include "at24cxxx.h"
+
+static int _read(const at24cxxx_t *dev, uint32_t pos, uint8_t *data, size_t len)
+{
+    int check;
+    uint8_t polls = AT24CXXX_MAX_POLLS;
+
+    while ((check =
+                i2c_read_regs(dev->params.i2c, dev->params.dev_addr, pos, data,
+                              len,
+                              I2C_REG16)) == -ENXIO && --polls) {
+        xtimer_usleep(AT24CXXX_POLL_DELAY_MS * US_PER_MS);
+    }

No need to squeeze everything into the while condition, I think it's much more readable this way:

```suggestion
    while ((check = i2c_read_regs(dev->params.i2c,
                                  dev->params.dev_addr,
                                  pos, data, len, I2C_REG16)) == -ENXIO) {
            if (--polls == 0) {
                break;
            }
            xtimer_usleep(AT24CXXX_POLL_DELAY_MS * US_PER_MS);
    }
```

-- 
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/11929#pullrequestreview-269302698
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190731/0b629987/attachment.htm>


More information about the notifications mailing list