mirror of
https://github.com/apache/nuttx.git
synced 2026-09-02 07:03:04 +00:00
poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
11b3adf17f
commit
eddd90de78
84 changed files with 373 additions and 396 deletions
|
|
@ -67,7 +67,7 @@ struct lirc_fh_s
|
|||
struct list_node node; /* list of open file handles */
|
||||
FAR struct lirc_lowerhalf_s *lower; /* the pointer to lirc_lowerhalf_s */
|
||||
struct circbuf_s buffer; /* buffer for incoming IR */
|
||||
FAR struct pollfd *fd; /* poll structures of threads waiting for driver events */
|
||||
FAR struct pollfd *fds; /* poll structures of threads waiting for driver events */
|
||||
sem_t waitsem; /* sem of wait buffer for ready */
|
||||
int carrier_low; /* when setting the carrier range, first the low end must be
|
||||
* set with an ioctl and then the high end with another ioctl
|
||||
|
|
@ -85,7 +85,7 @@ 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);
|
||||
static int lirc_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
bool setup);
|
||||
static ssize_t lirc_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t lirc_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
|
@ -216,21 +216,21 @@ static int lirc_poll(FAR struct file *filep,
|
|||
flags = enter_critical_section();
|
||||
if (setup)
|
||||
{
|
||||
if (fh->fd)
|
||||
if (fh->fds)
|
||||
{
|
||||
ret = -EBUSY;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
fh->fd = fds;
|
||||
fds->priv = &fh->fd;
|
||||
fh->fds = fds;
|
||||
fds->priv = &fh->fds;
|
||||
|
||||
if (!circbuf_is_empty(&fh->buffer))
|
||||
{
|
||||
eventset |= POLLIN | POLLRDNORM;
|
||||
}
|
||||
|
||||
poll_notify(&fh->fd, 1, eventset);
|
||||
poll_notify(&fds, 1, eventset);
|
||||
}
|
||||
else if (fds->priv != NULL)
|
||||
{
|
||||
|
|
@ -914,7 +914,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)
|
||||
{
|
||||
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
|
||||
poll_notify(&fh->fds, 1, POLLIN | POLLRDNORM);
|
||||
nxsem_get_value(&fh->waitsem, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
|
|
@ -944,7 +944,7 @@ void lirc_raw_event(FAR struct lirc_lowerhalf_s *lower,
|
|||
|
||||
if (circbuf_write(&fh->buffer, &sample, sizeof(unsigned int)) > 0)
|
||||
{
|
||||
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
|
||||
poll_notify(&fh->fds, 1, POLLIN | POLLRDNORM);
|
||||
nxsem_get_value(&fh->waitsem, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
|
|
@ -988,7 +988,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)
|
||||
{
|
||||
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
|
||||
poll_notify(&fh->fds, 1, POLLIN | POLLRDNORM);
|
||||
nxsem_get_value(&fh->waitsem, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
|
|
@ -1034,7 +1034,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)
|
||||
{
|
||||
poll_notify(&fh->fd, 1, POLLIN | POLLRDNORM);
|
||||
poll_notify(&fh->fds, 1, POLLIN | POLLRDNORM);
|
||||
nxsem_get_value(&fh->waitsem, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue