You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/07/26 06:30:19 UTC
[incubator-nuttx] branch master updated: sensor: directly return
-ENOTSUP without the set_interval or batch
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 7837a21 sensor: directly return -ENOTSUP without the set_interval or batch
7837a21 is described below
commit 7837a21e4eb1518ccfad647430a64dd82bd0aa84
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue Jul 20 20:34:43 2021 +0800
sensor: directly return -ENOTSUP without the set_interval or batch
implementation for lowerhalf driver.
Change-Id: I7b02e0331e5f8b89b39896049a9e24ce30116f8a
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
drivers/sensors/sensor.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c
index 95a4fcc..1bc143b 100644
--- a/drivers/sensors/sensor.c
+++ b/drivers/sensors/sensor.c
@@ -371,13 +371,18 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
case SNIOC_SET_INTERVAL:
{
+ if (lower->ops->set_interval == NULL)
+ {
+ ret = -ENOTSUP;
+ break;
+ }
+
if (upper->interval == *val)
{
break;
}
- ret = lower->ops->set_interval ?
- lower->ops->set_interval(lower, val) : -ENOTSUP;
+ ret = lower->ops->set_interval(lower, val);
if (ret >= 0)
{
upper->interval = *val;
@@ -387,6 +392,12 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
case SNIOC_BATCH:
{
+ if (lower->ops->batch == NULL)
+ {
+ ret = -ENOTSUP;
+ break;
+ }
+
if (upper->interval == 0)
{
ret = -EINVAL;
@@ -398,8 +409,7 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break;
}
- ret = lower->ops->batch ?
- lower->ops->batch(lower, val) : -ENOTSUP;
+ ret = lower->ops->batch(lower, val);
if (ret >= 0)
{
upper->latency = *val;