diff --git a/arch/sim/src/up_devconsole.c b/arch/sim/src/up_devconsole.c index 7e6cdf20b2..89eb33c33e 100644 --- a/arch/sim/src/up_devconsole.c +++ b/arch/sim/src/up_devconsole.c @@ -54,7 +54,7 @@ static ssize_t devconsole_read(struct file *, char *, size_t); static ssize_t devconsole_write(struct file *, const char *, size_t); #ifndef CONFIG_DISABLE_POLL -static int devconsole_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup); +static int devconsole_poll(FAR struct file *filep, FAR struct pollfd *fds); #endif /**************************************************************************** @@ -85,7 +85,7 @@ static ssize_t devconsole_write(struct file *filp, const char *buffer, size_t le } #ifndef CONFIG_DISABLE_POLL -static int devconsole_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) +static int devconsole_poll(FAR struct file *filep, FAR struct pollfd *fds) { return OK; } diff --git a/drivers/dev_null.c b/drivers/dev_null.c index cada981fe2..a5e7d95ceb 100644 --- a/drivers/dev_null.c +++ b/drivers/dev_null.c @@ -56,7 +56,7 @@ static ssize_t devnull_read(FAR struct file *, FAR char *, size_t); static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL -static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, boolean setup); +static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds); #endif /**************************************************************************** @@ -103,9 +103,9 @@ static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, boolean setup) +static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds) { - if (setup) + if (fds) { fds->revents |= (fds->events & (POLLIN|POLLOUT)); if (fds->revents != 0) diff --git a/drivers/dev_zero.c b/drivers/dev_zero.c index 13276ca7a2..08815ace5b 100644 --- a/drivers/dev_zero.c +++ b/drivers/dev_zero.c @@ -56,7 +56,7 @@ static ssize_t devzero_read(FAR struct file *, FAR char *, size_t); static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL -static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, boolean setup); +static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds); #endif /**************************************************************************** @@ -104,9 +104,9 @@ static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, boolean setup) +static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds) { - if (setup) + if (fds) { fds->revents |= (fds->events & (POLLIN|POLLOUT)); if (fds->revents != 0) diff --git a/drivers/pipe_common.c b/drivers/pipe_common.c index 72fea8006e..cede17ae12 100644 --- a/drivers/pipe_common.c +++ b/drivers/pipe_common.c @@ -517,7 +517,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) +int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds) { FAR struct inode *inode = filep->f_inode; FAR struct pipe_dev_s *dev = inode->i_private; @@ -547,14 +547,14 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setu if (dev->d_fds[i] == filep->f_priv) { - dev->d_fds[i] = (setup ? fds : NULL); + dev->d_fds[i] = fds; break; } } if (i >= CONFIG_DEV_PIPE_NPOLLWAITERS) { - DEBUGASSERT(setup); + DEBUGASSERT(fds != NULL); return -EBUSY; } @@ -562,16 +562,13 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setu * private data. */ - filep->f_priv = NULL; /* Assume teardown */ - if (setup) + filep->f_priv = fds; + + /* Check if we should immediately notify on any of the requested events */ + + if (fds) { - /* Set the poll event structure reference in the 'struct file' private data. */ - - filep->f_priv = fds; - - /* Check if we should immediately notify on any of the requested events. First, - * Determine how many bytes are in the buffer - */ + /* Determine how many bytes are in the buffer */ if (dev->d_wrndx >= dev->d_rdndx) { diff --git a/drivers/pipe_common.h b/drivers/pipe_common.h index 0f22477662..05edd9ca29 100644 --- a/drivers/pipe_common.h +++ b/drivers/pipe_common.h @@ -123,7 +123,7 @@ EXTERN int pipecommon_close(FAR struct file *filep); EXTERN ssize_t pipecommon_read(FAR struct file *, FAR char *, size_t); EXTERN ssize_t pipecommon_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL -EXTERN int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup); +EXTERN int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds); #endif #undef EXTERN diff --git a/drivers/serial.c b/drivers/serial.c index 0effeff008..4e409fa06e 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -79,7 +79,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg); #ifndef CONFIG_DISABLE_POLL -static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup); +static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds); #endif /************************************************************************************ @@ -400,7 +400,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) +int uart_poll(FAR struct file *filep, FAR struct pollfd *fds) { FAR struct inode *inode = filep->f_inode; FAR uart_dev_t *dev = inode->i_private; @@ -430,14 +430,14 @@ int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) if (dev->fds[i] == filep->f_priv) { - dev->fds[i] = (setup ? fds : NULL); + dev->fds[i] = fds; break; } } if (i >= CONFIG_DEV_CONSOLE_NPOLLWAITERS) { - DEBUGASSERT(setup); + DEBUGASSERT(fds != NULL); return -EBUSY; } @@ -445,12 +445,13 @@ int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) * private data. */ - filep->f_priv = NULL; /* Assume teardown */ - if (setup) + filep->f_priv = fds; + + /* Check if we should immediately notify on any of the requested events */ + + if (fds) { - /* Check if we should immediately notify on any of the requested events. - * First, check if the xmit buffer is full. - */ + /* Check if the xmit buffer is full. */ eventset = 0; diff --git a/fs/fs_poll.c b/fs/fs_poll.c index 9eed46c05a..133f16f497 100644 --- a/fs/fs_poll.c +++ b/fs/fs_poll.c @@ -93,7 +93,7 @@ static void poll_semtake(FAR sem_t *sem) ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 -static int poll_fdsetup(int fd, FAR struct pollfd *fds, boolean setup) +static int poll_fdsetup(int fd, FAR struct pollfd *fds) { FAR struct filelist *list; FAR struct file *this_file; @@ -109,7 +109,7 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, boolean setup) #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS)) { - return net_poll(fds->fd, fds, setup); + return net_poll(fd, fds); } else #endif @@ -137,7 +137,7 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, boolean setup) { /* Yes, then setup the poll */ - ret = (int)inode->u.i_ops->poll(this_file, fds, setup); + ret = (int)inode->u.i_ops->poll(this_file, fds); } return ret; } @@ -168,7 +168,7 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem) /* Set up the poll */ - ret = poll_fdsetup(fds[i].fd, &fds[i], TRUE); + ret = poll_fdsetup(fds[i].fd, &fds[i]); if (ret < 0) { return ret; @@ -201,7 +201,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count) { /* Teardown the poll */ - status = poll_fdsetup(fds[i].fd, &fds[i], FALSE); + status = poll_fdsetup(fds[i].fd, NULL); if (status < 0) { ret = status; diff --git a/include/nuttx/fs.h b/include/nuttx/fs.h index 3d23706880..ced7beed1c 100644 --- a/include/nuttx/fs.h +++ b/include/nuttx/fs.h @@ -76,7 +76,7 @@ struct file_operations off_t (*seek)(FAR struct file *filp, off_t offset, int whence); int (*ioctl)(FAR struct file *filp, int cmd, unsigned long arg); #ifndef CONFIG_DISABLE_POLL - int (*poll)(FAR struct file *filp, struct pollfd *fds, boolean setup); + int (*poll)(FAR struct file *filp, struct pollfd *fds); #endif /* The two structures need not be common after this point */