rtc: rv8803: broaden workaround
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Tue, 7 Jun 2016 18:44:05 +0000 (20:44 +0200)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Sat, 25 Jun 2016 23:26:16 +0000 (01:26 +0200)
The previous workaround may still fail as there are actually 4 retries to
be done to ensure the communication succeed. Also, some I2C adapter drivers
may return -EIO instead of -ENXIO.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-rv8803.c

index f623038..022ef26 100644 (file)
@@ -68,7 +68,7 @@ static irqreturn_t rv8803_handle_irq(int irq, void *dev_id)
        do {
                flags = i2c_smbus_read_byte_data(client, RV8803_FLAG);
                try++;
-       } while ((flags == -ENXIO) && (try < 3));
+       } while (((flags == -ENXIO) || (flags == -EIO)) && (try < 4));
        if (flags <= 0) {
                mutex_unlock(&rv8803->flags_lock);
                return IRQ_NONE;
@@ -452,7 +452,7 @@ static int rv8803_probe(struct i2c_client *client,
        do {
                flags = i2c_smbus_read_byte_data(client, RV8803_FLAG);
                try++;
-       } while ((flags == -ENXIO) && (try < 3));
+       } while (((flags == -ENXIO) || (flags == -EIO)) && (try < 4));
 
        if (flags < 0)
                return flags;
@@ -493,7 +493,7 @@ static int rv8803_probe(struct i2c_client *client,
                err = i2c_smbus_write_byte_data(rv8803->client, RV8803_EXT,
                                                RV8803_EXT_WADA);
                try++;
-       } while ((err == -ENXIO) && (try < 3));
+       } while (((err == -ENXIO) || (flags == -EIO)) && (try < 4));
        if (err)
                return err;