maXTouch: Fix test of I2C_TRANSFER return value
This commit is contained in:
parent
b4d3cebc2f
commit
4afc23d16d
@ -1027,6 +1027,9 @@ static int twi_registercallback(FAR struct i2c_dev_s *dev,
|
|||||||
* Receive a block of data on I2C using the previously selected I2C
|
* Receive a block of data on I2C using the previously selected I2C
|
||||||
* frequency and slave address.
|
* frequency and slave address.
|
||||||
*
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Returns zero on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_I2C_TRANSFER
|
#ifdef CONFIG_I2C_TRANSFER
|
||||||
|
@ -291,20 +291,8 @@ static int mxt_getreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||||
if (ret == 2)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ret = OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The return value was an error or some number of messages other than 2 */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ret >= 0)
|
|
||||||
{
|
|
||||||
ret = -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
idbg("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
idbg("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,20 +332,8 @@ static int mxt_putreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||||
if (ret == 2)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ret = OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The return value was an error or some number of messages other than 2 */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ret >= 0)
|
|
||||||
{
|
|
||||||
ret = -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
idbg("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
idbg("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +363,7 @@ static FAR struct mxt_object_s *mxt_object(FAR struct mxt_dev_s *priv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
idbg("ERROR: Invalid object type\n");
|
idbg("ERROR: Invalid object type: %d\n", type);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user