Skip to content

Commit

Permalink
poll: pollsetup should notify only one fd passd by caller
Browse files Browse the repository at this point in the history
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 authored and jerpelea committed Nov 21, 2023
1 parent 11b3adf commit eddd90d
Show file tree
Hide file tree
Showing 84 changed files with 373 additions and 396 deletions.
8 changes: 4 additions & 4 deletions arch/arm/src/cxd56xx/cxd56_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -3097,7 +3097,7 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds,

if (priv->has_event)
{
cxd56_gnss_pollnotify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -3108,9 +3108,9 @@ static int cxd56_gnss_poll(struct file *filep, struct pollfd *fds,

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
priv->has_event = false;
*slot = NULL;
fds->priv = NULL;
priv->has_event = false;
}

errout:
Expand Down
14 changes: 7 additions & 7 deletions arch/arm/src/sama5/sam_tsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ struct sam_tsd_s

static void sam_tsd_notify(struct sam_tsd_s *priv);
static int sam_tsd_sample(struct sam_tsd_s *priv,
struct sam_sample_s *sample);
struct sam_sample_s *sample);
static int sam_tsd_waitsample(struct sam_tsd_s *priv,
struct sam_sample_s *sample);
struct sam_sample_s *sample);
static void sam_tsd_bottomhalf(void *arg);
static int sam_tsd_schedule(struct sam_tsd_s *priv);
static void sam_tsd_expiry(wdparm_t arg);
Expand Down Expand Up @@ -1185,16 +1185,16 @@ static int sam_tsd_poll(struct file *filep, struct pollfd *fds, bool setup)

if (i >= CONFIG_SAMA5_TSD_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}

/* Should we immediately notify on any of the requested events? */

if (priv->penchange)
{
sam_tsd_notify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -1206,8 +1206,8 @@ static int sam_tsd_poll(struct file *filep, struct pollfd *fds, bool setup)

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

errout:
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/stm32/stm32_bbsram.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ struct stm32_bbsram_s
static int stm32_bbsram_open(struct file *filep);
static int stm32_bbsram_close(struct file *filep);
static off_t stm32_bbsram_seek(struct file *filep, off_t offset,
int whence);
int whence);
static ssize_t stm32_bbsram_read(struct file *filep, char *buffer,
size_t len);
size_t len);
static ssize_t stm32_bbsram_write(struct file *filep,
const char *buffer, size_t len);
const char *buffer, size_t len);
static int stm32_bbsram_ioctl(struct file *filep, int cmd,
unsigned long arg);
unsigned long arg);
static int stm32_bbsram_poll(struct file *filep,
struct pollfd *fds, bool setup);
struct pollfd *fds, bool setup);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int stm32_bbsram_unlink(struct inode *inode);
#endif
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/stm32f7/stm32_bbsram.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ struct stm32_bbsram_s
static int stm32_bbsram_open(struct file *filep);
static int stm32_bbsram_close(struct file *filep);
static off_t stm32_bbsram_seek(struct file *filep, off_t offset,
int whence);
int whence);
static ssize_t stm32_bbsram_read(struct file *filep, char *buffer,
size_t len);
size_t len);
static ssize_t stm32_bbsram_write(struct file *filep,
const char *buffer, size_t len);
const char *buffer, size_t len);
static int stm32_bbsram_ioctl(struct file *filep, int cmd,
unsigned long arg);
unsigned long arg);
static int stm32_bbsram_poll(struct file *filep,
struct pollfd *fds, bool setup);
struct pollfd *fds, bool setup);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int stm32_bbsram_unlink(struct inode *inode);
#endif
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/stm32h7/stm32_bbsram.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ struct stm32_bbsram_s
static int stm32_bbsram_open(struct file *filep);
static int stm32_bbsram_close(struct file *filep);
static off_t stm32_bbsram_seek(struct file *filep, off_t offset,
int whence);
int whence);
static ssize_t stm32_bbsram_read(struct file *filep, char *buffer,
size_t len);
size_t len);
static ssize_t stm32_bbsram_write(struct file *filep,
const char *buffer, size_t len);
const char *buffer, size_t len);
static int stm32_bbsram_ioctl(struct file *filep, int cmd,
unsigned long arg);
unsigned long arg);
static int stm32_bbsram_poll(struct file *filep,
struct pollfd *fds, bool setup);
struct pollfd *fds, bool setup);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int stm32_bbsram_unlink(struct inode *inode);
#endif
Expand Down
10 changes: 5 additions & 5 deletions boards/arm/cxd56xx/drivers/sensors/cxd5610_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static int cxd5610_gnss_post_interrupt(void);

#if CONFIG_SENSORS_CXD5610_GNSS_NSIGNALRECEIVERS != 0
static void cxd5610_gnss_signalhandler(struct cxd5610_gnss_dev_s *priv,
uint8_t sigtype);
uint8_t sigtype);
#endif

#if CONFIG_SENSORS_CXD5610_GNSS_NPOLLWAITERS != 0
Expand Down Expand Up @@ -2037,7 +2037,7 @@ static int cxd5610_gnss_poll(struct file *filep, struct pollfd *fds,

if (priv->has_event)
{
cxd5610_gnss_pollnotify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -2048,9 +2048,9 @@ static int cxd5610_gnss_poll(struct file *filep, struct pollfd *fds,

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
priv->has_event = false;
*slot = NULL;
fds->priv = NULL;
priv->has_event = false;
}

errout:
Expand Down
10 changes: 5 additions & 5 deletions boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,16 +1397,16 @@ static int tc_poll(struct file *filep, struct pollfd *fds, bool setup)
if (i >= CONFIG_TOUCHSCREEN_NPOLLWAITERS)
{
ierr("ERROR: No available slot found: %d\n", i);
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}

/* Should we immediately notify on any of the requested events? */

if (priv->penchange)
{
tc_notify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -1418,8 +1418,8 @@ static int tc_poll(struct file *filep, struct pollfd *fds, bool setup)

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

errout:
Expand Down
10 changes: 5 additions & 5 deletions boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,16 +1274,16 @@ static int tc_poll(struct file *filep, struct pollfd *fds, bool setup)
if (i >= CONFIG_TOUCHSCREEN_NPOLLWAITERS)
{
ierr("ERROR: No available slot found: %d\n", i);
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}

/* Should we immediately notify on any of the requested events? */

if (priv->penchange)
{
tc_notify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -1295,8 +1295,8 @@ static int tc_poll(struct file *filep, struct pollfd *fds, bool setup)

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

errout:
Expand Down
2 changes: 1 addition & 1 deletion boards/mips/pic32mx/sure-pic32mx/src/pic32mx_lcd1602.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static int lcd_ioctl(struct file *filep, int cmd, unsigned long arg)
****************************************************************************/

static int lcd_poll(struct file *filep, struct pollfd *fds,
bool setup)
bool setup)
{
if (setup)
{
Expand Down
10 changes: 5 additions & 5 deletions drivers/analog/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,16 @@ static int adc_poll(FAR struct file *filep, struct pollfd *fds, bool setup)

if (i >= CONFIG_ADC_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto return_with_irqdisabled;
}

/* Should we immediately notify on any of the requested events? */

if (dev->ad_recv.af_head != dev->ad_recv.af_tail)
{
poll_notify(dev->fds, CONFIG_ADC_NPOLLWAITERS, POLLIN);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -587,8 +587,8 @@ static int adc_poll(FAR struct file *filep, struct pollfd *fds, bool setup)

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

return_with_irqdisabled:
Expand Down
16 changes: 8 additions & 8 deletions drivers/analog/comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ static const struct comp_callback_s g_comp_callback =
static int comp_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
FAR struct inode *inode = filep->f_inode;
FAR struct comp_dev_s *dev = inode->i_private;
int ret = OK;
FAR struct inode *inode = filep->f_inode;
FAR struct comp_dev_s *dev = inode->i_private;
int ret = OK;
int i;

DEBUGASSERT(dev && fds);
Expand Down Expand Up @@ -123,8 +123,8 @@ static int comp_poll(FAR struct file *filep, FAR struct pollfd *fds,

if (i >= CONFIG_DEV_COMP_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}
}
Expand All @@ -137,15 +137,15 @@ static int comp_poll(FAR struct file *filep, FAR struct pollfd *fds,
#ifdef CONFIG_DEBUG_FEATURES
if (!slot)
{
ret = -EIO;
ret = -EIO;
goto errout;
}
#endif

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

errout:
Expand Down
8 changes: 4 additions & 4 deletions drivers/bch/bchdev_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ static int bch_open(FAR struct file *filep);
static int bch_close(FAR struct file *filep);
static off_t bch_seek(FAR struct file *filep, off_t offset, int whence);
static ssize_t bch_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
size_t buflen);
static ssize_t bch_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
size_t buflen);
static int bch_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
unsigned long arg);
static int bch_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
bool setup);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
static int bch_unlink(FAR struct inode *inode);
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/can/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
}
}

poll_notify(dev->cd_fds, CONFIG_CAN_NPOLLWAITERS, eventset);
poll_notify(&fds, 1, eventset);
}
else if (fds->priv != NULL)
{
Expand Down
12 changes: 6 additions & 6 deletions drivers/input/ads7843e.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ static int ads7843e_poll(FAR struct file *filep, FAR struct pollfd *fds,
inode = filep->f_inode;

DEBUGASSERT(inode->i_private);
priv = inode->i_private;
priv = inode->i_private;

/* Are we setting up the poll? Or tearing it down? */

Expand Down Expand Up @@ -1034,16 +1034,16 @@ static int ads7843e_poll(FAR struct file *filep, FAR struct pollfd *fds,

if (i >= CONFIG_ADS7843E_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}

/* Should we immediately notify on any of the requested events? */

if (priv->penchange)
{
ads7843e_notify(priv);
poll_notify(&fds, 1, POLLIN);
}
}
else if (fds->priv)
Expand All @@ -1055,8 +1055,8 @@ static int ads7843e_poll(FAR struct file *filep, FAR struct pollfd *fds,

/* Remove all memory of the poll setup */

*slot = NULL;
fds->priv = NULL;
*slot = NULL;
fds->priv = NULL;
}

errout:
Expand Down
4 changes: 2 additions & 2 deletions drivers/input/ajoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ static int ajoy_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (i >= CONFIG_INPUT_AJOYSTICK_NPOLLWAITERS)
{
ierr("ERROR: Too man poll waiters\n");
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/input/button_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ static int btn_poll(FAR struct file *filep, FAR struct pollfd *fds,
if (i >= CONFIG_INPUT_BUTTONS_NPOLLWAITERS)
{
ierr("ERROR: Too many poll waiters\n");
fds->priv = NULL;
ret = -EBUSY;
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}
}
Expand Down
Loading

0 comments on commit eddd90d

Please sign in to comment.