From d643fb8511c5f7b9556a0daaa29b6ec2e7a46c44 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Fri, 10 Feb 2023 13:35:48 +0900 Subject: [PATCH] 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. --- arch/arm/src/cxd56xx/cxd56_gnss.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c index ee44942318e..ac101812e13 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.c +++ b/arch/arm/src/cxd56xx/cxd56_gnss.c @@ -170,6 +170,7 @@ struct cxd56_gnss_dev_s mutex_t ioctllock; sem_t apiwait; 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 */ +/**************************************************************************** + * 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 * @@ -2492,7 +2510,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata) return; } - poll_notify(priv->fds, CONFIG_CXD56_GNSS_NPOLLWAITERS, POLLIN); + cxd56_gnss_pollnotify(priv); nxmutex_unlock(&priv->devlock); @@ -3019,6 +3037,13 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds, ret = -EBUSY; goto errout; } + + /* Should we immediately notify on any of the requested events? */ + + if (priv->has_event) + { + cxd56_gnss_pollnotify(priv); + } } else if (fds->priv) { @@ -3030,6 +3055,7 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds, *slot = NULL; fds->priv = NULL; + priv->has_event = false; } errout: