aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/p8-i2c.c12
-rw-r--r--include/i2c.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index ec2f7fc..d029854 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -1303,8 +1303,16 @@ static void p8_i2c_check_work(struct p8_i2c_master *master)
while (master->state == state_idle && !list_empty(&master->req_list)) {
req = list_top(&master->req_list, struct i2c_request, link);
rc = p8_i2c_start_request(master, req);
- if (rc && rc != OPAL_BUSY)
- p8_i2c_complete_request(master, req, rc);
+ if (rc) {
+ /*
+ * If it didn't work the first three times then
+ * odds are it's not going to work on the 4th.
+ */
+ if (rc && req->retries > 3)
+ p8_i2c_complete_request(master, req, rc);
+ else
+ req->retries++;
+ }
}
}
diff --git a/include/i2c.h b/include/i2c.h
index 669c30a..28c7628 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -64,6 +64,7 @@ struct i2c_request {
void (*completion)( /* Completion callback */
int rc, struct i2c_request *req);
void *user_data; /* Client data */
+ int retries;
};
/* Generic i2c */