net: Make si_poll callback optional

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-03-06 13:24:00 +08:00 committed by Petro Karashchenko
parent c39be172da
commit 3c3dea5d7a
4 changed files with 9 additions and 92 deletions

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*

View file

@ -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);
}