arch: cxd56xx: Fix gnss poll when an event has already occurred

Fix an issue that poll with timeout=0 cannot detect events that have
already occurred.
This commit is contained in:
SPRESENSE 2023-02-10 13:35:48 +09:00 committed by Xiang Xiao
parent 1877be8ce9
commit d643fb8511

View File

@ -170,6 +170,7 @@ struct cxd56_gnss_dev_s
mutex_t ioctllock; mutex_t ioctllock;
sem_t apiwait; sem_t apiwait;
int apiret; int apiret;
bool has_event;
}; };
/**************************************************************************** /****************************************************************************
@ -2178,6 +2179,23 @@ static int cxd56_gnss_get_1pps_output(struct file *filep,
* CXD56_GNSS signal handler and utils * CXD56_GNSS signal handler and utils
*/ */
/****************************************************************************
* Name: cxd56_gnss_pollnotify
*
* Description:
* Notify POLLIN event for poll
*
* Input Parameters:
* dev - Gnss device structure pointer
*
****************************************************************************/
static void cxd56_gnss_pollnotify(struct cxd56_gnss_dev_s *dev)
{
poll_notify(dev->fds, CONFIG_CXD56_GNSS_NPOLLWAITERS, POLLIN);
dev->has_event = true;
}
/**************************************************************************** /****************************************************************************
* Name: cxd56_gnss_wait_notify * Name: cxd56_gnss_wait_notify
* *
@ -2492,7 +2510,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata)
return; return;
} }
poll_notify(priv->fds, CONFIG_CXD56_GNSS_NPOLLWAITERS, POLLIN); cxd56_gnss_pollnotify(priv);
nxmutex_unlock(&priv->devlock); nxmutex_unlock(&priv->devlock);
@ -3019,6 +3037,13 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds,
ret = -EBUSY; ret = -EBUSY;
goto errout; goto errout;
} }
/* Should we immediately notify on any of the requested events? */
if (priv->has_event)
{
cxd56_gnss_pollnotify(priv);
}
} }
else if (fds->priv) else if (fds->priv)
{ {
@ -3030,6 +3055,7 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds,
*slot = NULL; *slot = NULL;
fds->priv = NULL; fds->priv = NULL;
priv->has_event = false;
} }
errout: errout: