From: Alex Elder Date: Fri, 17 Oct 2014 10:09:21 +0000 (-0500) Subject: greybus: add write retry support for i2c X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~2003 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d75286852bb3bd575bd8707f80ca0b362a7ae5a6;p=karo-tx-linux.git greybus: add write retry support for i2c It is expected that i2c writes may fail, and in that case the driver simply retries some number of times before actually treating it as a failure. Define a GB_OP_RETRY status, which is interpreted by the i2c driver as an indication a retry is in order. We just translate that into an EAGAIN error passed back to the i2c core. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/i2c-gb.c b/drivers/staging/greybus/i2c-gb.c index c4e47effa9f5..e1a0ed9dc6f2 100644 --- a/drivers/staging/greybus/i2c-gb.c +++ b/drivers/staging/greybus/i2c-gb.c @@ -382,9 +382,13 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev, response = operation->response_payload; if (response->status) { - gb_connection_err(connection, "transfer response %hhu", - response->status); - ret = -EIO; + if (response->status == GB_OP_RETRY) { + ret = -EAGAIN; + } else { + gb_connection_err(connection, "transfer response %hhu", + response->status); + ret = -EIO; + } } else { gb_i2c_transfer_response(msgs, msg_count, response->data); ret = msg_count; diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h index d5ec582e21a2..59aad3a38d17 100644 --- a/drivers/staging/greybus/operation.h +++ b/drivers/staging/greybus/operation.h @@ -16,7 +16,8 @@ enum gb_operation_status { GB_OP_INVALID = 1, GB_OP_NO_MEMORY = 2, GB_OP_INTERRUPTED = 3, - GB_OP_PROTOCOL_BAD = 4, + GB_OP_RETRY = 4, + GB_OP_PROTOCOL_BAD = 5, }; /*