driver/sensor: Fetch(with O_NONBLOCK) will directly return.

when sensor is disable.

Change-Id: I02c02aa447ee0b0d681082b4209ecd36e10f2547
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-02-07 17:13:31 +08:00 committed by Alan Carvalho de Assis
parent 54ea96da6b
commit 46ea549630

View File

@ -273,6 +273,11 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
return ret;
}
}
else if (!upper->enabled)
{
ret = -EAGAIN;
goto out;
}
ret = lower->ops->fetch(lower, buffer, len);
}
@ -289,7 +294,7 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
if (filep->f_oflags & O_NONBLOCK)
{
ret = -EAGAIN;
goto again;
goto out;
}
else
{
@ -324,7 +329,7 @@ static ssize_t sensor_read(FAR struct file *filep, FAR char *buffer,
}
}
again:
out:
nxsem_post(&upper->exclsem);
return ret;
}