This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 43a9866  lpc17xx_40xx/lpc17_40_i2c.c: Propagate I2C I/O errors
43a9866 is described below

commit 43a98662f3a794f51305a26475c102e10fd09f50
Author: Augusto Fraga Giachero <a...@augustofg.net>
AuthorDate: Thu Feb 18 08:17:44 2021 -0300

    lpc17xx_40xx/lpc17_40_i2c.c: Propagate I2C I/O errors
    
    Check if all messages were transferred, if not, return -ENXIO.
    
    This is particularly useful when the slave returns an unexpected NAK,
    the application code should catch the error to avoid failing silently.
---
 arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.c 
b/arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.c
index 03223fe..0c1547c 100644
--- a/arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.c
+++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.c
@@ -242,7 +242,9 @@ static int lpc17_40_i2c_start(struct lpc17_40_i2cdev_s 
*priv)
            lpc17_40_i2c_timeout, (wdparm_t)priv);
   nxsem_wait(&priv->wait);
 
-  return priv->nmsg;
+  /* Remaining messages should be zero or an error occurred */
+
+  return priv->nmsg ? -ENXIO : OK;
 }
 
 /****************************************************************************

Reply via email to