From 8ce7ff28362a350672d695dada167c7246fc2b22 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 23 Oct 2017 14:41:04 +0200 Subject: [PATCH] ds1307: return error when nothing is read or written on initialization It hints at to an unconnected devices ;-) --- drivers/ds1307/ds1307.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ds1307/ds1307.c b/drivers/ds1307/ds1307.c index c982adbd1..3141d8ae1 100644 --- a/drivers/ds1307/ds1307.c +++ b/drivers/ds1307/ds1307.c @@ -64,7 +64,7 @@ int ds1307_init(ds1307_t *dev, const ds1307_params_t *params) } /* normalize hour format */ res = i2c_read_reg(dev->i2c, DS1307_I2C_ADDRESS, DS1307_REG_HOUR, &hour); - if (res < 0) { + if (res <= 0) { /* should be 1 if device is connected */ i2c_release(dev->i2c); DEBUG("ds1307: Error reading HOUR register on init: %i\n", res); return -1; @@ -73,7 +73,7 @@ int ds1307_init(ds1307_t *dev, const ds1307_params_t *params) _convert_12_to_24(hour)); i2c_release(dev->i2c); - if (res < 0) { + if (res <= 0) { DEBUG("ds1307: Error writing HOUR register on init: %i\n", res); return -1; }