This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3c3dea5d7a3079c121091b0f2e955eaaaa7fe681 Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Mon Mar 6 13:24:00 2023 +0800 net: Make si_poll callback optional Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com> --- net/bluetooth/bluetooth_sockif.c | 33 +-------------------------------- net/ieee802154/ieee802154_sockif.c | 33 +-------------------------------- net/pkt/pkt_sockif.c | 28 +--------------------------- net/socket/net_poll.c | 7 ++++++- 4 files changed, 9 insertions(+), 92 deletions(-) diff --git a/net/bluetooth/bluetooth_sockif.c b/net/bluetooth/bluetooth_sockif.c index f022b8db5f..7d1eecde75 100644 --- a/net/bluetooth/bluetooth_sockif.c +++ b/net/bluetooth/bluetooth_sockif.c @@ -59,8 +59,6 @@ static int bluetooth_getpeername(FAR struct socket *psock, FAR struct sockaddr *addr, FAR socklen_t *addrlen); static int bluetooth_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, socklen_t addrlen); -static int bluetooth_poll_local(FAR struct socket *psock, - FAR struct pollfd *fds, bool setup); static int bluetooth_close(FAR struct socket *psock); /* Protocol Specific Interfaces */ @@ -86,7 +84,7 @@ const struct sock_intf_s g_bluetooth_sockif = NULL, /* si_listen */ bluetooth_connect, /* si_connect */ NULL, /* si_accept */ - bluetooth_poll_local, /* si_poll */ + NULL, /* si_poll */ bluetooth_sendmsg, /* si_sendmsg */ bluetooth_recvmsg, /* si_recvmsg */ bluetooth_close /* si_close */ @@ -616,35 +614,6 @@ static int bluetooth_getpeername(FAR struct socket *psock, return OK; } -/**************************************************************************** - * Name: bluetooth_poll - * - * Description: - * The standard poll() operation redirects operations on socket descriptors - * to net_poll which, indiectly, calls to function. - * - * Input Parameters: - * psock - An instance of the internal socket structure. - * fds - The structure describing the events to be monitored, OR NULL if - * this is a request to stop monitoring events. - * setup - true: Setup up the poll; false: Teardown the poll - * - * Returned Value: - * 0: Success; Negated errno on failure - * - ****************************************************************************/ - -static int bluetooth_poll_local(FAR struct socket *psock, - FAR struct pollfd *fds, bool setup) -{ - /* We should need to support some kind of write ahead buffering for this - * feature. - */ - -#warning Missing logic - return -ENOSYS; -} - /**************************************************************************** * Name: bluetooth_close * diff --git a/net/ieee802154/ieee802154_sockif.c b/net/ieee802154/ieee802154_sockif.c index b8ee6d0b6a..9057989be1 100644 --- a/net/ieee802154/ieee802154_sockif.c +++ b/net/ieee802154/ieee802154_sockif.c @@ -57,8 +57,6 @@ static int ieee802154_getpeername(FAR struct socket *psock, FAR struct sockaddr *addr, FAR socklen_t *addrlen); static int ieee802154_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, socklen_t addrlen); -static int ieee802154_poll_local(FAR struct socket *psock, - FAR struct pollfd *fds, bool setup); static int ieee802154_close(FAR struct socket *psock); /**************************************************************************** @@ -76,7 +74,7 @@ const struct sock_intf_s g_ieee802154_sockif = NULL, /* si_listen */ ieee802154_connect, /* si_connect */ NULL, /* si_accept */ - ieee802154_poll_local, /* si_poll */ + NULL, /* si_poll */ ieee802154_sendmsg, /* si_sendmsg */ ieee802154_recvmsg, /* si_recvmsg */ ieee802154_close /* si_close */ @@ -490,35 +488,6 @@ static int ieee802154_getpeername(FAR struct socket *psock, return OK; } -/**************************************************************************** - * Name: ieee802154_poll - * - * Description: - * The standard poll() operation redirects operations on socket descriptors - * to net_poll which, indiectly, calls to function. - * - * Input Parameters: - * psock - An instance of the internal socket structure. - * fds - The structure describing the events to be monitored, OR NULL if - * this is a request to stop monitoring events. - * setup - true: Setup up the poll; false: Teardown the poll - * - * Returned Value: - * 0: Success; Negated errno on failure - * - ****************************************************************************/ - -static int ieee802154_poll_local(FAR struct socket *psock, - FAR struct pollfd *fds, bool setup) -{ - /* We should need to support some kind of write ahead buffering for this - * feature. - */ - -#warning Missing logic - return -ENOSYS; -} - /**************************************************************************** * Name: ieee802154_close * diff --git a/net/pkt/pkt_sockif.c b/net/pkt/pkt_sockif.c index ba79c1042a..3271669e08 100644 --- a/net/pkt/pkt_sockif.c +++ b/net/pkt/pkt_sockif.c @@ -52,8 +52,6 @@ static sockcaps_t pkt_sockcaps(FAR struct socket *psock); static void pkt_addref(FAR struct socket *psock); static int pkt_bind(FAR struct socket *psock, FAR const struct sockaddr *addr, socklen_t addrlen); -static int pkt_poll_local(FAR struct socket *psock, - FAR struct pollfd *fds, bool setup); static int pkt_close(FAR struct socket *psock); /**************************************************************************** @@ -71,7 +69,7 @@ const struct sock_intf_s g_pkt_sockif = NULL, /* si_listen */ NULL, /* si_connect */ NULL, /* si_accept */ - pkt_poll_local, /* si_poll */ + NULL, /* si_poll */ pkt_sendmsg, /* si_sendmsg */ pkt_recvmsg, /* si_recvmsg */ pkt_close /* si_close */ @@ -274,30 +272,6 @@ static int pkt_bind(FAR struct socket *psock, } } -/**************************************************************************** - * Name: pkt_poll - * - * Description: - * The standard poll() operation redirects operations on socket descriptors - * to net_poll which, indiectly, calls to function. - * - * Input Parameters: - * psock - An instance of the internal socket structure. - * fds - The structure describing the events to be monitored, OR NULL if - * this is a request to stop monitoring events. - * setup - true: Setup up the poll; false: Teardown the poll - * - * Returned Value: - * 0: Success; Negated errno on failure - * - ****************************************************************************/ - -static int pkt_poll_local(FAR struct socket *psock, FAR struct pollfd *fds, - bool setup) -{ - return -ENOSYS; -} - /**************************************************************************** * Name: pkt_close * diff --git a/net/socket/net_poll.c b/net/socket/net_poll.c index dad4519efe..09fe852f5d 100644 --- a/net/socket/net_poll.c +++ b/net/socket/net_poll.c @@ -59,6 +59,11 @@ int psock_poll(FAR struct socket *psock, FAR struct pollfd *fds, bool setup) /* Let the address family's poll() method handle the operation */ - DEBUGASSERT(psock->s_sockif != NULL && psock->s_sockif->si_poll != NULL); + DEBUGASSERT(psock->s_sockif != NULL); + if (psock->s_sockif->si_poll == NULL) + { + return -EOPNOTSUPP; + } + return psock->s_sockif->si_poll(psock, fds, setup); }