aboutsummaryrefslogtreecommitdiff
path: root/module/i2c
diff options
context:
space:
mode:
authorRonald Cron <ronald.cron@arm.com>2019-12-03 14:52:51 +0100
committerjimqui01 <54316584+jimqui01@users.noreply.github.com>2020-01-24 11:12:09 +0000
commitcd2b5c999ed50843c2235af1b6d11b078fdd1679 (patch)
tree83cb0797b6e1f2247b53fac81f3e0b9638720823 /module/i2c
parenteb93c8fa15877061ab393274e00eb6ec52d92617 (diff)
i2c: Introduce PANIC state
When processing an event for an I2C device, if an unrecoverable error occurs, the I2C HAL internal state of the I2C device is set to the PANIC state. The possible type of unrecoverable errors are: unexpected event, invalid event, call to framework returned in error. Driver errors are not considered as unrecoverable. It is not possible to exit the PANIC state. Once in PANIC state, all requests returns with the FWK_E_PANIC error code. Change-Id: I8d1a6b62cc1ab413e8a43e6641604133bb5dfbd8 Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Diffstat (limited to 'module/i2c')
-rw-r--r--module/i2c/src/mod_i2c.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/module/i2c/src/mod_i2c.c b/module/i2c/src/mod_i2c.c
index b310c008..27b30b55 100644
--- a/module/i2c/src/mod_i2c.c
+++ b/module/i2c/src/mod_i2c.c
@@ -20,6 +20,7 @@ enum mod_i2c_dev_state {
MOD_I2C_DEV_TX,
MOD_I2C_DEV_RX,
MOD_I2C_DEV_TX_RX,
+ MOD_I2C_DEV_PANIC,
};
struct mod_i2c_dev_ctx {
@@ -67,8 +68,10 @@ static int create_i2c_request(fwk_id_t dev_id,
return FWK_E_PARAM;
/* Check whether an I2C request is already on-going */
- if (ctx->state != MOD_I2C_DEV_IDLE)
- return FWK_E_BUSY;
+ if (ctx->state != MOD_I2C_DEV_IDLE) {
+ return (ctx->state == MOD_I2C_DEV_PANIC) ?
+ FWK_E_PANIC : FWK_E_BUSY;
+ }
/* Create the request */
event = (struct fwk_event) {
@@ -353,6 +356,13 @@ static int mod_i2c_process_event(const struct fwk_event *event,
is_request = fwk_id_get_event_idx(event->id) < MOD_I2C_EVENT_IDX_COUNT;
if (is_request) {
+ if (ctx->state == MOD_I2C_DEV_PANIC) {
+ event_param = (struct mod_i2c_event_param *)resp_event->params;
+ event_param->status = FWK_E_PANIC;
+
+ return FWK_SUCCESS;
+ }
+
request = (struct mod_i2c_request *)event->params;
ctx->request = *request;
@@ -407,6 +417,9 @@ static int mod_i2c_process_event(const struct fwk_event *event,
break;
}
+ if (status != FWK_SUCCESS)
+ ctx->state = MOD_I2C_DEV_PANIC;
+
return status;
}