Fix some driver return values. If sem_wait fails, the errcode is in errno, not the return value.

This commit is contained in:
Gregory Nutt 2016-08-25 07:15:59 -06:00
parent a626ba5b70
commit c51b642f81
4 changed files with 12 additions and 8 deletions

View File

@ -455,8 +455,9 @@ static ssize_t bmg160_read(FAR struct file *filep, FAR char *buffer,
ret = sem_wait(&priv->datasem);
if (ret < 0)
{
snerr("ERROR: Could not aquire priv->datasem: %d\n", ret);
return ret;
int errcode = errno;
snerr("ERROR: Could not aquire priv->datasem: %d\n", errcode);
return -errcode;
}
/* Copy the sensor data into the buffer */

View File

@ -451,8 +451,9 @@ static ssize_t lis3dsh_read(FAR struct file *filep, FAR char *buffer,
ret = sem_wait(&priv->datasem);
if (ret < 0)
{
snerr("ERROR: Could not aquire priv->datasem: %d\n", ret);
return ret;
int errcode = errno;
snerr("ERROR: Could not aquire priv->datasem: %d\n", errcode);
return -errcode;
}
/* Copy the sensor data into the buffer */

View File

@ -494,8 +494,9 @@ static ssize_t lis3mdl_read(FAR struct file *filep, FAR char *buffer,
ret = sem_wait(&priv->datasem);
if (ret < 0)
{
snerr("ERROR: Could not aquire priv->datasem: %d\n", ret);
return ret;
int errcode = errno;
snerr("ERROR: Could not aquire priv->datasem: %d\n", errcode);
return -errcode;
}
/* Copy the sensor data into the buffer */

View File

@ -486,8 +486,9 @@ static ssize_t mlx90393_read(FAR struct file *filep, FAR char *buffer,
ret = sem_wait(&priv->datasem);
if (ret < 0)
{
snerr("ERROR: Could not aquire priv->datasem: %d\n", ret);
return ret;
int errcode = errno;
snerr("ERROR: Could not aquire priv->datasem: %d\n", errcode);
return -errcode;
}
data = (FAR struct mlx90393_sensor_data_s *)buffer;