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.
This commit is contained in:
Augusto Fraga Giachero 2021-02-18 08:17:44 -03:00 committed by Xiang Xiao
parent 734c04f3af
commit 43a98662f3
1 changed files with 3 additions and 1 deletions

View File

@ -242,7 +242,9 @@ static int lpc17_40_i2c_start(struct lpc17_40_i2cdev_s *priv)
lpc17_40_i2c_timeout, (wdparm_t)priv); lpc17_40_i2c_timeout, (wdparm_t)priv);
nxsem_wait(&priv->wait); nxsem_wait(&priv->wait);
return priv->nmsg; /* Remaining messages should be zero or an error occurred */
return priv->nmsg ? -ENXIO : OK;
} }
/**************************************************************************** /****************************************************************************