poll: add poll_notify() api and call it in all drivers

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
wangbowen6
2022-09-19 11:08:57 +08:00
committed by Xiang Xiao
parent 74842880f9
commit 344c8be049
83 changed files with 289 additions and 1441 deletions
+1 -11
View File
@@ -433,7 +433,6 @@ static void cxd56_geofence_sighandler(uint32_t data, void *userdata)
{
struct cxd56_geofence_dev_s *priv =
(struct cxd56_geofence_dev_s *)userdata;
int i;
int ret;
ret = nxsem_wait(&priv->devsem);
@@ -442,16 +441,7 @@ static void cxd56_geofence_sighandler(uint32_t data, void *userdata)
return;
}
for (i = 0; i < CONFIG_GEOFENCE_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
gnssinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_GEOFENCE_NPOLLWAITERS, POLLIN);
nxsem_post(&priv->devsem);
}
+1 -11
View File
@@ -2318,7 +2318,6 @@ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata)
{
struct cxd56_gnss_dev_s *priv =
(struct cxd56_gnss_dev_s *)userdata;
int i;
int ret;
int dtype = CXD56_CPU1_GET_DATA(data);
@@ -2385,16 +2384,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata)
return;
}
for (i = 0; i < CONFIG_CXD56_GNSS_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
gnssinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_CXD56_GNSS_NPOLLWAITERS, POLLIN);
nxsem_post(&priv->devsem);
+1 -12
View File
@@ -257,24 +257,13 @@ static struct sam_tsd_s g_tsd;
static void sam_tsd_notify(struct sam_tsd_s *priv)
{
int i;
/* If there are threads waiting on poll() for touchscreen data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_SAMA5_TSD_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_SAMA5_TSD_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+1 -5
View File
@@ -544,11 +544,7 @@ static int stm32_bbsram_poll(struct file *filep, struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -544,11 +544,7 @@ static int stm32_bbsram_poll(struct file *filep, struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -591,11 +591,7 @@ static int stm32_bbsram_poll(struct file *filep, struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -488,11 +488,7 @@ static int rx65n_sbram_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
@@ -1168,11 +1168,7 @@ static int slcd_poll(struct file *filep, struct pollfd *fds,
{
/* Data is always available to be read / Data can always be written */
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <sched.h>
#include <assert.h>
#include <errno.h>
@@ -575,8 +576,6 @@ static inline bool tc_valid_sample(uint16_t sample)
static void tc_notify(struct tc_dev_s *priv)
{
int i;
/* If no threads have the driver open, then just dump the state */
#ifdef CONFIG_TOUCHSCREEN_REFCNT
@@ -595,16 +594,7 @@ static void tc_notify(struct tc_dev_s *priv)
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_TOUCHSCREEN_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_TOUCHSCREEN_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
@@ -1502,11 +1502,7 @@ static int slcd_poll(struct file *filep, struct pollfd *fds,
{
/* Data is always available to be read / Data can always be written */
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <sched.h>
#include <assert.h>
#include <errno.h>
@@ -475,8 +476,6 @@ static inline bool tc_valid_sample(uint16_t sample)
static void tc_notify(struct tc_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for touchscreen data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do.
@@ -484,16 +483,7 @@ static void tc_notify(struct tc_dev_s *priv)
* all.
*/
for (i = 0; i < CONFIG_TOUCHSCREEN_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_TOUCHSCREEN_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
@@ -1024,11 +1024,7 @@ static int lcd_poll(struct file *filep, struct pollfd *fds,
{
/* Data is always available to be read */
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+2 -21
View File
@@ -496,25 +496,6 @@ static int adc_receive(FAR struct adc_dev_s *dev, uint8_t ch, int32_t data)
return errcode;
}
/****************************************************************************
* Name: adc_pollnotify
****************************************************************************/
static void adc_pollnotify(FAR struct adc_dev_s *dev, uint32_t type)
{
int i;
for (i = 0; i < CONFIG_ADC_NPOLLWAITERS; i++)
{
struct pollfd *fds = dev->fds[i];
if (fds)
{
fds->revents |= type;
nxsem_post(fds->sem);
}
}
}
/****************************************************************************
* Name: adc_notify
****************************************************************************/
@@ -527,7 +508,7 @@ static void adc_notify(FAR struct adc_dev_s *dev)
* then wake them up now.
*/
adc_pollnotify(dev, POLLIN);
poll_notify(dev->fds, CONFIG_ADC_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
@@ -596,7 +577,7 @@ static int adc_poll(FAR struct file *filep, struct pollfd *fds, bool setup)
if (dev->ad_recv.af_head != dev->ad_recv.af_tail)
{
adc_pollnotify(dev, POLLIN);
poll_notify(dev->fds, CONFIG_ADC_NPOLLWAITERS, POLLIN);
}
}
else if (fds->priv)
+1 -43
View File
@@ -80,48 +80,6 @@ static const struct comp_callback_s g_comp_callback =
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: comp_pollnotify
*
* Description:
* This function is called to notify any waiters of poll-reated events.
*
****************************************************************************/
static void comp_pollnotify(FAR struct comp_dev_s *dev,
pollevent_t eventset)
{
int i;
if (eventset & POLLERR)
{
eventset &= ~(POLLOUT | POLLIN);
}
for (i = 0; i < CONFIG_DEV_COMP_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = dev->d_fds[i];
if (fds)
{
fds->revents |= eventset & (fds->events | POLLERR | POLLHUP);
if ((fds->revents & (POLLOUT | POLLHUP)) == (POLLOUT | POLLHUP))
{
/* POLLOUT and POLLHUP are mutually exclusive. */
fds->revents &= ~POLLOUT;
}
if (fds->revents != 0)
{
ainfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
}
/****************************************************************************
* Name: comp_semtake
****************************************************************************/
@@ -220,7 +178,7 @@ static int comp_notify(FAR struct comp_dev_s *dev, uint8_t val)
dev->val = val;
comp_pollnotify(dev, POLLIN);
poll_notify(dev->d_fds, CONFIG_DEV_COMP_NPOLLWAITERS, POLLIN);
nxsem_post(&dev->ad_readsem);
return 0;
+1 -5
View File
@@ -97,11 +97,7 @@ static int bch_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+5 -37
View File
@@ -100,11 +100,6 @@
static int can_takesem(FAR sem_t *sem);
/* Poll helpers */
static void can_pollnotify(FAR struct can_dev_s *dev,
pollevent_t eventset);
/* CAN helpers */
static uint8_t can_dlc2bytes(uint8_t dlc);
@@ -169,30 +164,6 @@ static int can_takesem(FAR sem_t *sem)
#define can_givesem(sem) nxsem_post(sem)
/****************************************************************************
* Name: can_pollnotify
****************************************************************************/
static void can_pollnotify(FAR struct can_dev_s *dev, pollevent_t eventset)
{
FAR struct pollfd *fds;
int i;
for (i = 0; i < CONFIG_CAN_NPOLLWAITERS; i++)
{
fds = dev->cd_fds[i];
if (fds != NULL)
{
fds->revents |= fds->events & eventset;
if (fds->revents != 0)
{
caninfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
}
/****************************************************************************
* Name: can_dlc2bytes
*
@@ -1154,7 +1125,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (ndx != dev->cd_xmit.tx_head)
{
eventset |= fds->events & POLLOUT;
eventset |= POLLOUT;
}
can_givesem(&dev->cd_xmit.tx_sem);
@@ -1174,7 +1145,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
/* No need to wait, just notify the application immediately */
eventset |= fds->events & POLLIN;
eventset |= POLLIN;
}
else
{
@@ -1182,10 +1153,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
}
}
if (eventset != 0)
{
can_pollnotify(dev, eventset);
}
poll_notify(dev->cd_fds, CONFIG_CAN_NPOLLWAITERS, eventset);
}
else if (fds->priv != NULL)
{
@@ -1401,7 +1369,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct can_hdr_s *hdr,
* cd_recv buffer
*/
can_pollnotify(dev, POLLIN);
poll_notify(dev->cd_fds, CONFIG_CAN_NPOLLWAITERS, POLLIN);
sval = 0;
if (nxsem_get_value(&fifo->rx_sem, &sval) < 0)
@@ -1546,7 +1514,7 @@ int can_txdone(FAR struct can_dev_s *dev)
* buffer
*/
can_pollnotify(dev, POLLOUT);
poll_notify(dev->cd_fds, CONFIG_CAN_NPOLLWAITERS, POLLOUT);
/* Are there any threads waiting for space in the TX FIFO? */
+1 -5
View File
@@ -292,11 +292,7 @@ static int devurand_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -12
View File
@@ -279,24 +279,13 @@ static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv,
static void ads7843e_notify(FAR struct ads7843e_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for ADS7843E data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_ADS7843E_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_ADS7843E_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+3 -20
View File
@@ -223,7 +223,6 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
ajoy_buttonset_t press;
ajoy_buttonset_t release;
irqstate_t flags;
int i;
DEBUGASSERT(priv);
lower = priv->au_lower;
@@ -265,19 +264,8 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
/* Yes.. Notify all waiters */
for (i = 0; i < CONFIG_INPUT_AJOYSTICK_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = opriv->ao_fds[i];
if (fds)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
poll_notify(opriv->ao_fds, CONFIG_INPUT_AJOYSTICK_NPOLLWAITERS,
POLLIN);
}
/* Have any signal events occurred? */
@@ -635,12 +623,7 @@ static int ajoy_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (opriv->ao_pollpending)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN);
}
break;
+3 -20
View File
@@ -230,7 +230,6 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
btn_buttonset_t change;
btn_buttonset_t press;
btn_buttonset_t release;
int i;
DEBUGASSERT(priv && priv->bu_lower);
lower = priv->bu_lower;
@@ -267,19 +266,8 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
{
/* Yes.. Notify all waiters */
for (i = 0; i < CONFIG_INPUT_BUTTONS_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = opriv->bo_fds[i];
if (fds)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
poll_notify(opriv->bo_fds, CONFIG_INPUT_BUTTONS_NPOLLWAITERS,
POLLIN);
}
/* Have any signal events occurred? */
@@ -687,12 +675,7 @@ static int btn_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (opriv->bo_pending)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN);
}
break;
+4 -21
View File
@@ -981,25 +981,6 @@ static int mbr3108_close(FAR struct file *filep)
return 0;
}
static void mbr3108_poll_notify(FAR struct mbr3108_dev_s *priv)
{
int i;
DEBUGASSERT(priv != NULL);
for (i = 0; i < CONFIG_INPUT_CYPRESS_MBR3108_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
mbr3108_dbg("Report events: %08" PRIx32 "\n", fds->revents);
fds->revents |= POLLIN;
nxsem_post(fds->sem);
}
}
}
static int mbr3108_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
@@ -1059,7 +1040,9 @@ static int mbr3108_poll(FAR struct file *filep, FAR struct pollfd *fds,
pending = priv->int_pending;
if (pending)
{
mbr3108_poll_notify(priv);
poll_notify(priv->fds,
CONFIG_INPUT_CYPRESS_MBR3108_NPOLLWAITERS,
POLLIN);
}
}
}
@@ -1092,7 +1075,7 @@ static int mbr3108_isr_handler(int irq, FAR void *context, FAR void *arg)
priv->int_pending = true;
leave_critical_section(flags);
mbr3108_poll_notify(priv);
poll_notify(priv->fds, CONFIG_INPUT_CYPRESS_MBR3108_NPOLLWAITERS, POLLIN);
return 0;
}
+3 -20
View File
@@ -223,7 +223,6 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
djoy_buttonset_t press;
djoy_buttonset_t release;
irqstate_t flags;
int i;
DEBUGASSERT(priv);
lower = priv->du_lower;
@@ -265,19 +264,8 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
/* Yes.. Notify all waiters */
for (i = 0; i < CONFIG_INPUT_DJOYSTICK_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = opriv->do_fds[i];
if (fds)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
poll_notify(opriv->do_fds, CONFIG_INPUT_DJOYSTICK_NPOLLWAITERS,
POLLIN);
}
/* Have any signal events occurred? */
@@ -629,12 +617,7 @@ static int djoy_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (opriv->do_pollpending)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN);
}
break;
+1 -12
View File
@@ -201,24 +201,13 @@ static const uint8_t g_event_map[4] =
static void ft5x06_notify(FAR struct ft5x06_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for FT5x06 data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_FT5X06_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_FT5X06_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+2 -27
View File
@@ -75,7 +75,6 @@ static ssize_t keyboard_write(FAR struct file *filep, FAR const char *buffer,
size_t len);
static int keyboard_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
static void keyboard_notify(FAR struct keyboard_opriv_s *buffer);
/****************************************************************************
* Private Data
@@ -99,30 +98,6 @@ static const struct file_operations g_keyboard_fops =
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: keyboard_notify
****************************************************************************/
static void keyboard_notify(FAR struct keyboard_opriv_s *opriv)
{
FAR struct pollfd *fds = opriv->fds;
if (fds != NULL)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
/* report event log */
int semcount;
nxsem_get_value(fds->sem, &semcount);
if (semcount < 1)
{
nxsem_post(fds->sem);
}
}
}
}
/****************************************************************************
* Name: keyboard_open
****************************************************************************/
@@ -301,7 +276,7 @@ static int keyboard_poll(FAR struct file *filep,
if (!circbuf_is_empty(&opriv->circ))
{
keyboard_notify(opriv);
poll_notify(&opriv->fds, 1, POLLIN);
}
}
else
@@ -437,7 +412,7 @@ void keyboard_event(FAR struct keyboard_lowerhalf_s *lower, uint32_t keycode,
nxsem_post(&opriv->waitsem);
}
keyboard_notify(opriv);
poll_notify(&opriv->fds, 1, POLLIN);
nxsem_post(&opriv->locksem);
}
}
+1 -12
View File
@@ -236,24 +236,13 @@ static uint16_t max11802_sendcmd(FAR struct max11802_dev_s *priv,
static void max11802_notify(FAR struct max11802_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for MAX11802 data to become
* available, then wake them up now. NOTE: we wake up all waiting
* threads because we do not know that they are going to do. If they
* all try to read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_MAX11802_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_MAX11802_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+1 -12
View File
@@ -584,24 +584,13 @@ static int mxt_flushmsgs(FAR struct mxt_dev_s *priv)
static void mxt_notify(FAR struct mxt_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for maXTouch data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_MXT_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_MXT_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+1 -24
View File
@@ -440,29 +440,6 @@ static int spq10kbd_interrupt(int irq, FAR void *context, FAR void *arg)
return OK;
}
/****************************************************************************
* Name: spq10kbd_pollnotify
****************************************************************************/
static void spq10kbd_pollnotify(FAR struct spq10kbd_dev_s *priv)
{
int i;
for (i = 0; i < CONFIG_SPQ10KBD_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= (fds->events & POLLIN);
if (fds->revents != 0)
{
uinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
}
/****************************************************************************
* Name: spq10kbd_open
*
@@ -676,7 +653,7 @@ static int spq10kbd_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (priv->headndx != priv->tailndx)
{
spq10kbd_pollnotify(priv);
poll_notify(priv->fds, CONFIG_SPQ10KBD_NPOLLWAITERS, POLLIN);
}
}
else
+1 -12
View File
@@ -145,24 +145,13 @@ static const struct file_operations g_stmpe811fops =
static void stmpe811_notify(FAR struct stmpe811_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for STMPE811 data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_STMPE811_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_STMPE811_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+3 -31
View File
@@ -66,8 +66,6 @@ struct touch_upperhalf_s
* Private Function Prototypes
****************************************************************************/
static void touch_notify(FAR struct touch_openpriv_s *openpriv,
pollevent_t eventset);
static int touch_open(FAR struct file *filep);
static int touch_close(FAR struct file *filep);
static ssize_t touch_read(FAR struct file *filep, FAR char *buffer,
@@ -101,29 +99,6 @@ static const struct file_operations g_touch_fops =
* Private Functions
****************************************************************************/
static void touch_notify(FAR struct touch_openpriv_s *openpriv,
pollevent_t eventset)
{
FAR struct pollfd *fd = openpriv->fds;
fd = openpriv->fds;
if (fd)
{
fd->revents |= (fd->events & eventset);
if (fd->revents != 0)
{
/* report event log */
int semcount;
nxsem_get_value(fd->sem, &semcount);
if (semcount < 1)
{
nxsem_post(fd->sem);
}
}
}
}
/****************************************************************************
* Name: touch_open
****************************************************************************/
@@ -323,13 +298,10 @@ static int touch_poll(FAR struct file *filep, struct pollfd *fds, bool setup)
if (!circbuf_is_empty(&openpriv->circbuf))
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
if (eventset)
{
touch_notify(openpriv, POLLIN);
}
poll_notify(&openpriv->fds, 1, eventset);
}
else if (fds->priv)
{
@@ -368,7 +340,7 @@ void touch_event(FAR void *priv, FAR const struct touch_sample_s *sample)
nxsem_post(&openpriv->waitsem);
}
touch_notify(openpriv, POLLIN);
poll_notify(&openpriv->fds, 1, POLLIN);
}
nxsem_post(&upper->exclsem);
+1 -12
View File
@@ -237,24 +237,13 @@ static struct tsc2007_dev_s *g_tsc2007list;
static void tsc2007_notify(FAR struct tsc2007_dev_s *priv)
{
int i;
/* If there are threads waiting on poll() for TSC2007 data to become
* available, then wake them up now. NOTE: we wake up all waiting
* threads because we do not know that they are going to do. If they
* all try to read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_TSC2007_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
iinfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
poll_notify(priv->fds, CONFIG_TSC2007_NPOLLWAITERS, POLLIN);
/* If there are threads waiting for read data, then signal one of them
* that the read data is available.
+3 -57
View File
@@ -136,71 +136,17 @@ int ipcc_poll(FAR struct file *filep, FAR struct pollfd *fds,
#ifdef CONFIG_IPCC_BUFFERED
if (circbuf_used(&priv->ipcc->rxbuf) > 0)
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
if (circbuf_space(&priv->ipcc->txbuf) > 0)
{
eventset |= (fds->events & POLLOUT);
eventset |= POLLOUT;
}
#endif
if (eventset)
{
ipcc_pollnotify(priv, eventset);
}
poll_notify(priv->fds, CONFIG_IPCC_NPOLLWAITERS, eventset);
nxsem_post(&priv->exclsem);
return OK;
}
/****************************************************************************
* Name: ipcc_pollnotify
*
* Description:
* Wakes up all sleeping threads waiting for event associated with ipcc
* driver.
*
* Input Parameters:
* ipcc - driver instance to check for poll events
* eventset - list of events to check for activity
*
* Returned Value:
* None
*
* Assumptions/Limitations:
* This function may be called from interrupt handler.
*
****************************************************************************/
void ipcc_pollnotify(FAR struct ipcc_driver_s *priv, pollevent_t eventset)
{
struct pollfd *fds;
int semcount;
int i;
for (i = 0; i < CONFIG_IPCC_NPOLLWAITERS; i++)
{
if ((fds = priv->fds[i]) == NULL)
{
/* Slot empty, move to next one */
continue;
}
if ((fds->revents |= fds->events & eventset) == 0)
{
/* No event */
continue;
}
finfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_get_value(fds->sem, &semcount);
if (semcount < 1)
{
nxsem_post(fds->sem);
}
}
}
+1 -5
View File
@@ -1558,11 +1558,7 @@ static int pcf8574_lcd_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
/* Data is always available to be read */
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -1180,11 +1180,7 @@ static int tda19988_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
nxsem_post(&priv->exclsem);
+1 -5
View File
@@ -105,11 +105,7 @@ static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -104,11 +104,7 @@ static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -260,11 +260,7 @@ static int ubxmdm_poll(FAR struct file * filep,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -1713,11 +1713,7 @@ static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
if (setup)
{
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -1985,11 +1985,7 @@ static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
if (setup)
{
fds->revents |= fds->events & (POLLIN | POLLOUT);
if (fds->revents != 0)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLIN | POLLOUT);
}
return OK;
+1 -5
View File
@@ -1247,11 +1247,7 @@ static int telnet_poll(FAR struct file *filep, FAR struct pollfd *fds,
{
/* Yes.. then signal the poll logic */
fds->revents |= (POLLRDNORM & fds->events);
if (fds->revents)
{
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, POLLRDNORM);
}
/* Then let psock_poll() do the heavy lifting */
+4 -13
View File
@@ -295,13 +295,7 @@ static void tun_pollnotify(FAR struct tun_device_s *priv,
return;
}
eventset &= fds->events;
if (eventset != 0)
{
fds->revents |= eventset;
nxsem_post(fds->sem);
}
poll_notify(&fds, 1, eventset);
}
/****************************************************************************
@@ -1261,7 +1255,7 @@ int tun_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
if (priv->write_d_len == 0)
{
eventset |= (fds->events & POLLOUT);
eventset |= POLLOUT;
}
/* The write buffer sometimes could be used for TX.
@@ -1270,13 +1264,10 @@ int tun_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
if (priv->read_d_len != 0 || priv->write_d_len != 0)
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
if (eventset)
{
tun_pollnotify(priv, eventset);
}
tun_pollnotify(priv, eventset);
}
else
{
+7 -47
View File
@@ -73,44 +73,6 @@ static int pipecommon_semtake(FAR sem_t *sem)
return nxsem_wait_uninterruptible(sem);
}
/****************************************************************************
* Name: pipecommon_pollnotify
****************************************************************************/
static void pipecommon_pollnotify(FAR struct pipe_dev_s *dev,
pollevent_t eventset)
{
int i;
if (eventset & POLLERR)
{
eventset &= ~(POLLOUT | POLLIN);
}
for (i = 0; i < CONFIG_DEV_PIPE_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = dev->d_fds[i];
if (fds)
{
fds->revents |= eventset & (fds->events | POLLERR | POLLHUP);
if ((fds->revents & (POLLOUT | POLLHUP)) == (POLLOUT | POLLHUP))
{
/* POLLOUT and POLLHUP are mutually exclusive. */
fds->revents &= ~POLLOUT;
}
if (fds->revents != 0)
{
finfo("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -321,7 +283,7 @@ int pipecommon_close(FAR struct file *filep)
{
/* Inform poll readers that other end closed. */
pipecommon_pollnotify(dev, POLLHUP);
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, POLLHUP);
while (nxsem_get_value(&dev->d_rdsem, &sval) == 0 && sval <= 0)
{
@@ -342,7 +304,8 @@ int pipecommon_close(FAR struct file *filep)
{
/* Inform poll writers that other end closed. */
pipecommon_pollnotify(dev, POLLERR);
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS,
POLLERR);
while (nxsem_get_value(&dev->d_wrsem, &sval) == 0
&& sval <= 0)
{
@@ -477,7 +440,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len)
/* Notify all poll/select waiters that they can write to the FIFO */
pipecommon_pollnotify(dev, POLLOUT);
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, POLLOUT);
/* Notify all waiting writers that bytes have been removed from the
* buffer.
@@ -588,7 +551,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer,
* FIFO.
*/
pipecommon_pollnotify(dev, POLLIN);
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, POLLIN);
/* Yes.. Notify all of the waiting readers that more data is
* available.
@@ -617,7 +580,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer,
* FIFO.
*/
pipecommon_pollnotify(dev, POLLIN);
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, POLLIN);
/* Yes.. Notify all of the waiting readers that more data is
* available.
@@ -761,10 +724,7 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds,
eventset |= POLLERR;
}
if (eventset)
{
pipecommon_pollnotify(dev, eventset);
}
poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, eventset);
}
else
{
+1 -6
View File
@@ -122,12 +122,7 @@ static int battery_charger_notify(FAR struct battery_charger_priv_s *priv,
priv->mask |= mask;
if (priv->mask)
{
fd->revents |= POLLIN;
nxsem_get_value(fd->sem, &semcnt);
if (semcnt < 1)
{
nxsem_post(fd->sem);
}
poll_notify(&fd, 1, POLLIN);
nxsem_get_value(&priv->wait, &semcnt);
if (semcnt < 1)
+1 -6
View File
@@ -124,12 +124,7 @@ static int battery_gauge_notify(FAR struct battery_gauge_priv_s *priv,
priv->mask |= mask;
if (priv->mask)
{
fd->revents |= POLLIN;
nxsem_get_value(fd->sem, &semcnt);
if (semcnt < 1)
{
nxsem_post(fd->sem);
}
poll_notify(&fd, 1, POLLIN);
nxsem_get_value(&priv->wait, &semcnt);
if (semcnt < 1)
+1 -6
View File
@@ -123,12 +123,7 @@ static int battery_monitor_notify(FAR struct battery_monitor_priv_s *priv,
priv->mask |= mask;
if (priv->mask)
{
fd->revents |= POLLIN;
nxsem_get_value(fd->sem, &semcnt);
if (semcnt < 1)
{
nxsem_post(fd->sem);
}
poll_notify(&fd, 1, POLLIN);
nxsem_get_value(&priv->wait, &semcnt);
if (semcnt < 1)
+6 -32
View File
@@ -80,7 +80,6 @@ struct lirc_fh_s
* Private Function Prototypes
****************************************************************************/
static void lirc_pollnotify(FAR struct lirc_fh_s *fh, pollevent_t eventset);
static int lirc_open(FAR struct file *filep);
static int lirc_close(FAR struct file *filep);
static int lirc_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
@@ -113,28 +112,6 @@ static const struct file_operations g_lirc_fops =
* Private Functions
****************************************************************************/
static void lirc_pollnotify(FAR struct lirc_fh_s *fh,
pollevent_t eventset)
{
int semcount;
if (fh->fd)
{
fh->fd->revents |= (fh->fd->events & eventset);
if (fh->fd->revents != 0)
{
rcinfo("Report events: %08" PRIx32 "\n", fh->fd->revents);
nxsem_get_value(fh->fd->sem, &semcount);
if (semcount < 1)
{
nxsem_post(fh->fd->sem);
}
}
}
}
static int lirc_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
@@ -251,13 +228,10 @@ static int lirc_poll(FAR struct file *filep,
if (!circbuf_is_empty(&fh->buffer))
{
eventset = (fds->events & (POLLIN | POLLRDNORM));
eventset |= POLLIN | POLLRDNORM;
}
if (eventset)
{
lirc_pollnotify(fh, eventset);
}
poll_notify(&fh->fd, 1, eventset);
}
else if (fds->priv != NULL)
{
@@ -941,7 +915,7 @@ void lirc_raw_event(FAR struct lirc_lowerhalf_s *lower,
fh = (FAR struct lirc_fh_s *)node;
if (circbuf_write(&fh->buffer, &gap, sizeof(int)) > 0)
{
lirc_pollnotify(fh, POLLIN | POLLRDNORM);
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
nxsem_get_value(&fh->waitsem, &semcount);
if (semcount < 1)
{
@@ -971,7 +945,7 @@ void lirc_raw_event(FAR struct lirc_lowerhalf_s *lower,
if (circbuf_write(&fh->buffer, &sample, sizeof(unsigned int)) > 0)
{
lirc_pollnotify(fh, POLLIN | POLLRDNORM);
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
nxsem_get_value(&fh->waitsem, &semcount);
if (semcount < 1)
{
@@ -1015,7 +989,7 @@ void lirc_scancode_event(FAR struct lirc_lowerhalf_s *lower,
fh = (FAR struct lirc_fh_s *)node;
if (circbuf_write(&fh->buffer, lsc, sizeof(*lsc)) > 0)
{
lirc_pollnotify(fh, POLLIN | POLLRDNORM);
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
nxsem_get_value(&fh->waitsem, &semcount);
if (semcount < 1)
{
@@ -1061,7 +1035,7 @@ void lirc_sample_event(FAR struct lirc_lowerhalf_s *lower,
fh = (FAR struct lirc_fh_s *)node;
if (circbuf_write(&fh->buffer, &sample, sizeof(unsigned int)) > 0)
{
lirc_pollnotify(fh, POLLIN | POLLRDNORM);
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
nxsem_get_value(&fh->waitsem, &semcount);
if (semcount < 1)
{
+2 -26
View File
@@ -271,30 +271,6 @@ static bool hcsr04_sample(FAR struct hcsr04_dev_s *priv)
return (done == 0);
}
static void hcsr04_notify(FAR struct hcsr04_dev_s *priv)
{
DEBUGASSERT(priv != NULL);
int i;
/* If there are threads waiting on poll() for data to become available,
* then wake them up now. NOTE: we wake up all waiting threads because we
* do not know that they are going to do. If they all try to read the
* data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_HCSR04_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
hcsr04_dbg("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
static int hcsr04_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
@@ -356,7 +332,7 @@ static int hcsr04_poll(FAR struct file *filep, FAR struct pollfd *fds,
flags = enter_critical_section();
if (hcsr04_sample(priv))
{
hcsr04_notify(priv);
poll_notify(priv->fds, CONFIG_HCSR04_NPOLLWAITERS, POLLIN);
}
leave_critical_section(flags);
@@ -415,7 +391,7 @@ static int hcsr04_int_handler(int irq, FAR void *context, FAR void *arg)
}
hcsr04_dbg("HC-SR04 interrupt\n");
hcsr04_notify(priv);
poll_notify(priv->fds, CONFIG_HCSR04_NPOLLWAITERS, POLLIN);
return OK;
}
+2 -26
View File
@@ -1054,30 +1054,6 @@ static bool hts221_sample(FAR struct hts221_dev_s *priv)
return status.is_humid_ready || status.is_temp_ready;
}
static void hts221_notify(FAR struct hts221_dev_s *priv)
{
DEBUGASSERT(priv != NULL);
int i;
/* If there are threads waiting on poll() for data to become available,
* then wake them up now. NOTE: we wake up all waiting threads because we
* do not know that they are going to do. If they all try to read the
* data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_HTS221_NPOLLWAITERS; i++)
{
FAR struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
hts221_dbg("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
static int hts221_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
@@ -1139,7 +1115,7 @@ static int hts221_poll(FAR struct file *filep, FAR struct pollfd *fds,
flags = enter_critical_section();
if (priv->int_pending || hts221_sample(priv))
{
hts221_notify(priv);
poll_notify(priv->fds, CONFIG_HTS221_NPOLLWAITERS, POLLIN);
}
leave_critical_section(flags);
@@ -1170,7 +1146,7 @@ static int hts221_int_handler(int irq, FAR void *context, FAR void *arg)
priv->int_pending = true;
hts221_dbg("Hts221 interrupt\n");
hts221_notify(priv);
poll_notify(priv->fds, CONFIG_HTS221_NPOLLWAITERS, POLLIN);
return OK;
}
+3 -28
View File
@@ -118,7 +118,6 @@ static int lis2dh_powerdown(FAR struct lis2dh_dev_s *dev);
static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev);
static int lis2dh_poll(FAR struct file *filep,
FAR struct pollfd *fds, bool setup);
static void lis2dh_notify(FAR struct lis2dh_dev_s *priv);
static int lis2dh_int_handler(int irq, FAR void *context,
FAR void *arg);
static int lis2dh_setup(FAR struct lis2dh_dev_s *dev,
@@ -439,7 +438,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
priv->int_pending = true;
#endif
lis2dh_notify(priv);
poll_notify(priv->fds, CONFIG_LIS2DH_NPOLLWAITERS, POLLIN);
leave_critical_section(flags);
}
else if (fifo_mode != LIS2DH_STREAM_MODE && priv->fifo_stopped)
@@ -715,7 +714,7 @@ static int lis2dh_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (priv->int_pending)
{
lis2dh_notify(priv);
poll_notify(priv->fds, CONFIG_LIS2DH_NPOLLWAITERS, POLLIN);
}
}
else if (fds->priv)
@@ -736,30 +735,6 @@ out:
return ret;
}
static void lis2dh_notify(FAR struct lis2dh_dev_s *priv)
{
DEBUGASSERT(priv != NULL);
int i;
/* If there are threads waiting on poll() for LIS2DH data to become
* available, then wake them up now. NOTE: we wake up all waiting threads
* because we do not know that they are going to do. If they all try to
* read the data, then some make end up blocking after all.
*/
for (i = 0; i < CONFIG_LIS2DH_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
lis2dh_dbg("lis2dh: Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
}
}
}
/****************************************************************************
* Name: lis2dh_callback
*
@@ -783,7 +758,7 @@ static int lis2dh_int_handler(int irq, FAR void *context, FAR void *arg)
priv->int_pending = true;
#endif
lis2dh_notify(priv);
poll_notify(priv->fds, CONFIG_LIS2DH_NPOLLWAITERS, POLLIN);
leave_critical_section(flags);
return OK;
+1 -3
View File
@@ -769,9 +769,7 @@ static void max44009_notify(FAR struct max44009_dev_s *priv)
FAR struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
max44009_dbg("Report events: %08" PRIx32 "\n", fds->revents);
nxsem_post(fds->sem);
poll_notify(&fds, 1, POLLIN);
priv->int_pending = false;
}
}
+6 -25
View File
@@ -488,28 +488,12 @@ static ssize_t sensor_do_samples(FAR struct sensor_upperhalf_s *upper,
static void sensor_pollnotify_one(FAR struct sensor_user_s *user,
pollevent_t eventset)
{
int semcount;
if (eventset == POLLPRI)
{
user->changed = true;
}
if (!user->fds)
{
return;
}
user->fds->revents |= (user->fds->events & eventset);
if (user->fds->revents != 0)
{
sninfo("Report events: %08" PRIx32 "\n", user->fds->revents);
nxsem_get_value(user->fds->sem, &semcount);
if (semcount < 1)
{
nxsem_post(user->fds->sem);
}
}
poll_notify(&user->fds, 1, eventset);
}
static void sensor_pollnotify(FAR struct sensor_upperhalf_s *upper,
@@ -899,31 +883,28 @@ static int sensor_poll(FAR struct file *filep,
if (filep->f_oflags & O_NONBLOCK)
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
else
{
nxsem_get_value(&user->buffersem, &semcount);
if (semcount > 0)
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
}
}
else if (sensor_is_updated(upper, user))
{
eventset |= (fds->events & POLLIN);
eventset |= POLLIN;
}
if (user->changed)
{
eventset |= (fds->events & POLLPRI);
eventset |= POLLPRI;
}
if (eventset)
{
sensor_pollnotify_one(user, eventset);
}
sensor_pollnotify_one(user, eventset);
}
else
{

Some files were not shown because too many files have changed in this diff Show More