diff --git a/drivers/sensors/bmg160.c b/drivers/sensors/bmg160.c index b27fbd8777..03ad72a5d0 100644 --- a/drivers/sensors/bmg160.c +++ b/drivers/sensors/bmg160.c @@ -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 */ diff --git a/drivers/sensors/lis3dsh.c b/drivers/sensors/lis3dsh.c index a9aa3aa9db..243f89874d 100644 --- a/drivers/sensors/lis3dsh.c +++ b/drivers/sensors/lis3dsh.c @@ -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 */ diff --git a/drivers/sensors/lis3mdl.c b/drivers/sensors/lis3mdl.c index bec3f14cd2..cdb04e776e 100644 --- a/drivers/sensors/lis3mdl.c +++ b/drivers/sensors/lis3mdl.c @@ -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 */ diff --git a/drivers/sensors/mlx90393.c b/drivers/sensors/mlx90393.c index 1eb9aac641..93a53ef871 100644 --- a/drivers/sensors/mlx90393.c +++ b/drivers/sensors/mlx90393.c @@ -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;