mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
drivers/sensors: sensor bug fix.
fix cross-core flush failed when physical driver without flush interface Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com> Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
@@ -1027,6 +1027,7 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = -ENOTSUP;
|
||||
if (lower->ops->flush != NULL)
|
||||
{
|
||||
/* Lower half driver will do flush in asynchronous mode,
|
||||
@@ -1040,12 +1041,25 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
user->flushing = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (ret == -ENOTSUP)
|
||||
{
|
||||
/* If flush is not supported, complete immediately */
|
||||
|
||||
user->flushing = false;
|
||||
user->event |= SENSOR_EVENT_FLUSH_COMPLETE;
|
||||
sensor_pollnotify_one(user, POLLPRI, user->role);
|
||||
|
||||
/* If caller isn't from remote core, convert ENOTSUP
|
||||
* to zero return, indicating the flush is completed.
|
||||
* If it's from remote core, need to inform the remote
|
||||
* core the flush is not supported for driver.
|
||||
*/
|
||||
|
||||
if ((filep->f_oflags & SENSOR_REMOTE) == 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
nxrmutex_unlock(&upper->lock);
|
||||
|
||||
@@ -781,6 +781,17 @@ static int sensor_rpmsg_flush(FAR struct sensor_lowerhalf_s *lower,
|
||||
{
|
||||
ret = drv->ops->flush(drv, filep);
|
||||
}
|
||||
else if ((filep->f_oflags & SENSOR_REMOTE) ||
|
||||
dev->nadvertisers > 0)
|
||||
{
|
||||
/* If the driver (drv) does not support the flush operation,
|
||||
* and the caller is a remote invocation or the current device
|
||||
* is an advertiser, then you can still consider the flush
|
||||
* operation as unsupported and therefore return ENOTSUP
|
||||
*/
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
else if (!(filep->f_oflags & SENSOR_REMOTE))
|
||||
{
|
||||
ret = sensor_rpmsg_ioctl(dev, SNIOC_FLUSH, 0, 0, true);
|
||||
|
||||
Reference in New Issue
Block a user