diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c index 95a4fcc441..1bc143b929 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;