[Skiboot] [PATCH 1/4] core/i2c: Add request state tracking
Oliver O'Halloran
oohall at gmail.com
Tue Mar 26 19:18:16 AEDT 2019
Allow the submitter to track the state of an I2C request by adding
a state field to the request. This avoids the need to use a stub
completion callback in some cases.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
hw/p8-i2c.c | 1 +
include/i2c.h | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index a45769c0edb8..599614cf40e9 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -441,6 +441,7 @@ static void p8_i2c_complete_request(struct p8_i2c_master *master,
list_del(&req->link);
master->state = state_idle;
req->result = ret;
+ req->req_state = i2c_req_done;
/* Schedule re-enabling of sensor cache */
if (master->occ_cache_dis)
diff --git a/include/i2c.h b/include/i2c.h
index a06cca0dd31c..484176f93508 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -57,6 +57,12 @@ struct i2c_request {
uint32_t offset; /* Internal device offset */
uint32_t rw_len; /* Length of the data request */
void *rw_buf; /* Data request buffer */
+ enum i2c_request_state {
+ i2c_req_new, /* un-initialised */
+ i2c_req_queued, /* waiting in the queue */
+ i2c_req_done, /* request has been completed */
+ } req_state;
+
void (*completion)( /* Completion callback */
int rc, struct i2c_request *req);
void *user_data; /* Client data */
@@ -68,9 +74,13 @@ struct i2c_request {
extern void i2c_add_bus(struct i2c_bus *bus);
extern struct i2c_bus *i2c_find_bus_by_id(uint32_t opal_id);
-static inline int i2c_queue_req(struct i2c_request *req)
+static inline int64_t i2c_queue_req(struct i2c_request *req)
{
- return req->bus->queue_req(req);
+ int64_t ret = req->bus->queue_req(req);
+
+ if (!ret)
+ req->req_state = i2c_req_queued;
+ return ret;
}
static inline uint64_t i2c_run_req(struct i2c_request *req)
--
2.20.1
More information about the Skiboot
mailing list