From 04e190ab870b56131ff5a6bb63e41b1fd1f1790f Mon Sep 17 00:00:00 2001 From: Jose Alberto Meza Date: Mon, 23 Mar 2020 15:23:48 -0700 Subject: [PATCH] drivers: peci: xec: Re-add error recovery handling Using temp variable to avoid coverity issue without breakin error recovery. Signed-off-by: Jose Alberto Meza --- drivers/peci/peci_mchp_xec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/peci/peci_mchp_xec.c b/drivers/peci/peci_mchp_xec.c index e6cc1aab2da..9925844e892 100644 --- a/drivers/peci/peci_mchp_xec.c +++ b/drivers/peci/peci_mchp_xec.c @@ -242,6 +242,7 @@ static int peci_xec_transfer(struct device *dev, struct peci_msg *msg) ARG_UNUSED(dev); int ret; PECI_Type *base = peci_xec_config.base; + u8_t err_val = base->ERROR; ret = peci_xec_write(dev, msg); if (ret) { @@ -264,7 +265,7 @@ static int peci_xec_transfer(struct device *dev, struct peci_msg *msg) } /* Check for error conditions and perform bus recovery if necessary */ - if (base->ERROR) { + if (err_val) { if (base->ERROR & MCHP_PECI_ERR_RDOV) { LOG_WRN("Read buffer is not empty\n"); } @@ -281,6 +282,11 @@ static int peci_xec_transfer(struct device *dev, struct peci_msg *msg) return -EIO; } + /* ERROR is a clear-on-write register, need to clear errors occurred + * at the end of a transaction. + */ + base->ERROR = err_val; + return 0; }