mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
fs: Remove the unused nx_poll to prefer file_poll for kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
aa31648c9f
commit
cf21319d3a
+33
-55
@@ -410,21 +410,37 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nx_poll
|
* Name: poll
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* nx_poll() is similar to the standard 'poll' interface except that is
|
* poll() waits for one of a set of file descriptors to become ready to
|
||||||
* not a cancellation point and it does not modify the errno variable.
|
* perform I/O. If none of the events requested (and no error) has
|
||||||
|
* occurred for any of the file descriptors, then poll() blocks until
|
||||||
|
* one of the events occurs.
|
||||||
*
|
*
|
||||||
* nx_poll() is an internal NuttX interface and should not be called from
|
* Input Parameters:
|
||||||
* applications.
|
* fds - List of structures describing file descriptors to be monitored
|
||||||
|
* nfds - The number of entries in the list
|
||||||
|
* timeout - Specifies an upper limit on the time for which poll() will
|
||||||
|
* block in milliseconds. A negative value of timeout means an infinite
|
||||||
|
* timeout.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero is returned on success; a negated value is returned on any failure.
|
* On success, the number of structures that have non-zero revents fields.
|
||||||
|
* A value of 0 indicates that the call timed out and no file descriptors
|
||||||
|
* were ready. On error, -1 is returned, and errno is set appropriately:
|
||||||
|
*
|
||||||
|
* EBADF - An invalid file descriptor was given in one of the sets.
|
||||||
|
* EFAULT - The fds address is invalid
|
||||||
|
* EINTR - A signal occurred before any requested event.
|
||||||
|
* EINVAL - The nfds value exceeds a system limit.
|
||||||
|
* ENOMEM - There was no space to allocate internal data structures.
|
||||||
|
* ENOSYS - One or more of the drivers supporting the file descriptor
|
||||||
|
* does not support the poll method.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
||||||
{
|
{
|
||||||
sem_t sem;
|
sem_t sem;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -433,6 +449,10 @@ int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
|||||||
|
|
||||||
DEBUGASSERT(nfds == 0 || fds != NULL);
|
DEBUGASSERT(nfds == 0 || fds != NULL);
|
||||||
|
|
||||||
|
/* poll() is a cancellation point */
|
||||||
|
|
||||||
|
enter_cancellation_point();
|
||||||
|
|
||||||
nxsem_init(&sem, 0, 0);
|
nxsem_init(&sem, 0, 0);
|
||||||
ret = poll_setup(fds, nfds, &sem);
|
ret = poll_setup(fds, nfds, &sem);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
@@ -508,57 +528,15 @@ int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nxsem_destroy(&sem);
|
nxsem_destroy(&sem);
|
||||||
return ret < 0 ? ret : count;
|
leave_cancellation_point();
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: poll
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* poll() waits for one of a set of file descriptors to become ready to
|
|
||||||
* perform I/O. If none of the events requested (and no error) has
|
|
||||||
* occurred for any of the file descriptors, then poll() blocks until
|
|
||||||
* one of the events occurs.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* fds - List of structures describing file descriptors to be monitored
|
|
||||||
* nfds - The number of entries in the list
|
|
||||||
* timeout - Specifies an upper limit on the time for which poll() will
|
|
||||||
* block in milliseconds. A negative value of timeout means an infinite
|
|
||||||
* timeout.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* On success, the number of structures that have non-zero revents fields.
|
|
||||||
* A value of 0 indicates that the call timed out and no file descriptors
|
|
||||||
* were ready. On error, -1 is returned, and errno is set appropriately:
|
|
||||||
*
|
|
||||||
* EBADF - An invalid file descriptor was given in one of the sets.
|
|
||||||
* EFAULT - The fds address is invalid
|
|
||||||
* EINTR - A signal occurred before any requested event.
|
|
||||||
* EINVAL - The nfds value exceeds a system limit.
|
|
||||||
* ENOMEM - There was no space to allocate internal data structures.
|
|
||||||
* ENOSYS - One or more of the drivers supporting the file descriptor
|
|
||||||
* does not support the poll method.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* poll() is a cancellation point */
|
|
||||||
|
|
||||||
enter_cancellation_point();
|
|
||||||
|
|
||||||
/* Let nx_poll() do all of the work */
|
|
||||||
|
|
||||||
ret = nx_poll(fds, nfds, timeout);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
ret = ERROR;
|
return ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_cancellation_point();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-29
@@ -79,21 +79,16 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
FAR fd_set *exceptfds, FAR struct timeval *timeout)
|
FAR fd_set *exceptfds, FAR struct timeval *timeout)
|
||||||
{
|
{
|
||||||
struct pollfd *pollset = NULL;
|
struct pollfd *pollset = NULL;
|
||||||
int errcode = OK;
|
|
||||||
int fd;
|
int fd;
|
||||||
int npfds;
|
int npfds;
|
||||||
int msec;
|
int msec;
|
||||||
int ndx;
|
int ndx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* select() is cancellation point */
|
|
||||||
|
|
||||||
enter_cancellation_point();
|
|
||||||
|
|
||||||
if (nfds < 0)
|
if (nfds < 0)
|
||||||
{
|
{
|
||||||
errcode = EINVAL;
|
set_errno(EINVAL);
|
||||||
goto errout;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* How many pollfd structures do we need to allocate? */
|
/* How many pollfd structures do we need to allocate? */
|
||||||
@@ -123,8 +118,8 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
|
|
||||||
if (pollset == NULL)
|
if (pollset == NULL)
|
||||||
{
|
{
|
||||||
errcode = ENOMEM;
|
set_errno(ENOMEM);
|
||||||
goto errout;
|
return ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +186,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
|
|
||||||
/* Then let poll do all of the real work. */
|
/* Then let poll do all of the real work. */
|
||||||
|
|
||||||
ret = nx_poll(pollset, npfds, msec);
|
ret = poll(pollset, npfds, msec);
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
/* poll() failed! Save the errno value */
|
|
||||||
|
|
||||||
errcode = -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now set up the return values */
|
/* Now set up the return values */
|
||||||
|
|
||||||
@@ -263,17 +252,5 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
}
|
}
|
||||||
|
|
||||||
kmm_free(pollset);
|
kmm_free(pollset);
|
||||||
|
return ret;
|
||||||
/* Did poll() fail above? */
|
|
||||||
|
|
||||||
if (ret >= 0)
|
|
||||||
{
|
|
||||||
leave_cancellation_point();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
errout:
|
|
||||||
set_errno(errcode);
|
|
||||||
leave_cancellation_point();
|
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1354,23 +1354,6 @@ int nx_fcntl(int fd, int cmd, ...);
|
|||||||
|
|
||||||
int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: nx_poll
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* nx_poll() is similar to the standard 'poll' interface except that is
|
|
||||||
* not a cancellation point and it does not modify the errno variable.
|
|
||||||
*
|
|
||||||
* nx_poll() is an internal NuttX interface and should not be called from
|
|
||||||
* applications.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero is returned on success; a negated value is returned on any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: file_fstat
|
* Name: file_fstat
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user