From 6ea54db33489d10b873137d4239294225aa81fa6 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Wed, 2 Sep 2020 10:54:36 +0200 Subject: [PATCH] drivers: wifi: eswifi: fix socket poll - Fix return value, must be number structures with events - set revents flag Signed-off-by: Loic Poulain --- drivers/wifi/eswifi/eswifi_socket_offload.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/wifi/eswifi/eswifi_socket_offload.c b/drivers/wifi/eswifi/eswifi_socket_offload.c index 3afbaf1278a..0bc8c259f92 100644 --- a/drivers/wifi/eswifi/eswifi_socket_offload.c +++ b/drivers/wifi/eswifi/eswifi_socket_offload.c @@ -424,7 +424,7 @@ static int eswifi_socket_poll(struct zsock_pollfd *fds, int nfds, int msecs) int sock, ret; void *obj; - if (nfds > 1) { + if (nfds != 1) { errno = EINVAL; return -1; } @@ -445,6 +445,11 @@ static int eswifi_socket_poll(struct zsock_pollfd *fds, int nfds, int msecs) return -1; } + if (!(fds[0].events & POLLIN)) { + errno = ENOTSUP; + return -1; + } + eswifi_lock(eswifi); socket = &eswifi->socket[sock]; eswifi_unlock(eswifi); @@ -453,8 +458,16 @@ static int eswifi_socket_poll(struct zsock_pollfd *fds, int nfds, int msecs) return -1; } - ret = k_sem_take(&socket->read_sem, K_MSEC(msecs)); - return ret; + ret = k_sem_take(&socket->read_sem, K_MSEC(msecs*10)); + if (ret) { + errno = ETIMEDOUT; + return -1; + } + + fds[0].revents = POLLIN; + + /* Report one event */ + return 1; } static int eswifi_socket_bind(void *obj, const struct sockaddr *addr,