Skip to content

Commit

Permalink
drivers: wifi: winc1500: Rename socket functions to avoid multiple de…
Browse files Browse the repository at this point in the history
…finitions

Renamed socket functions to avoid multiple definitions in the HAL library

Signed-off-by: Andreas Ålgård <[email protected]>
  • Loading branch information
icsys-aal committed Nov 7, 2024
1 parent 4b1e145 commit 35f213e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions drivers/wifi/winc1500/wifi_winc1500.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ typedef void (*tpfAppSocketCb) (SOCKET sock, uint8 u8Msg, void *pvMsg);
typedef void (*tpfAppResolveCb) (uint8 *pu8DomainName, uint32 u32ServerIP);
NMI_API void registerSocketCallback(tpfAppSocketCb socket_cb,
tpfAppResolveCb resolve_cb);
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
NMI_API sint8 bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint8 listen(SOCKET sock, uint8 backlog);
NMI_API sint8 accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
NMI_API sint8 connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint16 recv(SOCKET sock, void *pvRecvBuf,
NMI_API SOCKET winc1500_socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags);
NMI_API sint8 winc1500_socket_bind(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint8 winc1500_socket_listen(SOCKET sock, uint8 backlog);
NMI_API sint8 winc1500_socket_accept(SOCKET sock, struct sockaddr *addr, uint8 *addrlen);
NMI_API sint8 winc1500_socket_connect(SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
NMI_API sint16 winc1500_socket_recv(SOCKET sock, void *pvRecvBuf,
uint16 u16BufLen, uint32 u32Timeoutmsec);
NMI_API sint16 send(SOCKET sock, void *pvSendBuffer,
NMI_API sint16 winc1500_socket_send(SOCKET sock, void *pvSendBuffer,
uint16 u16SendLength, uint16 u16Flags);
NMI_API sint16 sendto(SOCKET sock, void *pvSendBuffer,
NMI_API sint16 winc1500_socket_sendto(SOCKET sock, void *pvSendBuffer,
uint16 u16SendLength, uint16 flags,
struct sockaddr *pstrDestAddr, uint8 u8AddrLen);
NMI_API sint8 winc1500_close(SOCKET sock);

Check notice on line 57 in drivers/wifi/winc1500/wifi_winc1500.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/winc1500/wifi_winc1500.c:57 -NMI_API sint16 winc1500_socket_recv(SOCKET sock, void *pvRecvBuf, - uint16 u16BufLen, uint32 u32Timeoutmsec); -NMI_API sint16 winc1500_socket_send(SOCKET sock, void *pvSendBuffer, - uint16 u16SendLength, uint16 u16Flags); -NMI_API sint16 winc1500_socket_sendto(SOCKET sock, void *pvSendBuffer, - uint16 u16SendLength, uint16 flags, - struct sockaddr *pstrDestAddr, uint8 u8AddrLen); +NMI_API sint16 winc1500_socket_recv(SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, + uint32 u32Timeoutmsec); +NMI_API sint16 winc1500_socket_send(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, + uint16 u16Flags); +NMI_API sint16 winc1500_socket_sendto(SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, + uint16 flags, struct sockaddr *pstrDestAddr, uint8 u8AddrLen);
Expand Down Expand Up @@ -306,7 +306,7 @@ static int winc1500_get(sa_family_t family,
* we have checked if family is AF_INET so we can hardcode this
* for now.
*/
sock = socket(2, type, 0);
sock = winc1500_socket(2, type, 0);
if (sock < 0) {
LOG_ERR("socket error!");
return -1;
Expand Down Expand Up @@ -337,7 +337,8 @@ static int winc1500_bind(struct net_context *context,
return 0;
}

ret = bind((intptr_t)context->offload_context, (struct sockaddr *)addr, addrlen);
ret = winc1500_socket_bind((intptr_t)context->offload_context, (struct sockaddr *)addr,
addrlen);
if (ret) {

Check notice on line 342 in drivers/wifi/winc1500/wifi_winc1500.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/winc1500/wifi_winc1500.c:342 - addrlen); + addrlen);
LOG_ERR("bind error %d %s!",
ret, socket_message_to_string(ret));
Expand All @@ -362,7 +363,7 @@ static int winc1500_listen(struct net_context *context, int backlog)
SOCKET socket = (intptr_t)context->offload_context;
int ret;

ret = listen((intptr_t)context->offload_context, backlog);
ret = winc1500_socket_listen((intptr_t)context->offload_context, backlog);
if (ret) {
LOG_ERR("listen error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -395,7 +396,7 @@ static int winc1500_connect(struct net_context *context,
w1500_data.socket_data[socket].connect_user_data = user_data;
w1500_data.socket_data[socket].ret_code = 0;

ret = connect(socket, (struct sockaddr *)addr, addrlen);
ret = winc1500_socket_connect(socket, (struct sockaddr *)addr, addrlen);
if (ret) {
LOG_ERR("connect error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -425,7 +426,7 @@ static int winc1500_accept(struct net_context *context,
w1500_data.socket_data[socket].accept_cb = cb;
w1500_data.socket_data[socket].accept_user_data = user_data;

ret = accept(socket, NULL, 0);
ret = winc1500_socket_accept(socket, NULL, 0);
if (ret) {
LOG_ERR("accept error %d %s!",
ret, socket_error_string(ret));
Expand Down Expand Up @@ -467,7 +468,7 @@ static int winc1500_send(struct net_pkt *pkt,

net_buf_add(buf, net_pkt_get_len(pkt));

ret = send(socket, buf->data, buf->len, 0);
ret = winc1500_socket_send(socket, buf->data, buf->len, 0);
if (ret) {
LOG_ERR("send error %d %s!", ret, socket_error_string(ret));
goto out;
Expand Down Expand Up @@ -507,7 +508,7 @@ static int winc1500_sendto(struct net_pkt *pkt,

net_buf_add(buf, net_pkt_get_len(pkt));

ret = sendto(socket, buf->data, buf->len, 0,
ret = winc1500_socket_sendto(socket, buf->data, buf->len, 0,
(struct sockaddr *)dst_addr, addrlen);
if (ret) {

Check notice on line 513 in drivers/wifi/winc1500/wifi_winc1500.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/winc1500/wifi_winc1500.c:513 - ret = winc1500_socket_sendto(socket, buf->data, buf->len, 0, - (struct sockaddr *)dst_addr, addrlen); + ret = winc1500_socket_sendto(socket, buf->data, buf->len, 0, (struct sockaddr *)dst_addr, + addrlen);
LOG_ERR("sendto error %d %s!", ret, socket_error_string(ret));
Expand Down Expand Up @@ -571,7 +572,7 @@ static int winc1500_recv(struct net_context *context,
}


ret = recv(socket, w1500_data.socket_data[socket].pkt_buf->data,
ret = winc1500_socket_recv(socket, w1500_data.socket_data[socket].pkt_buf->data,
CONFIG_WIFI_WINC1500_MAX_PACKET_SIZE, timeout);
if (ret) {

Check notice on line 577 in drivers/wifi/winc1500/wifi_winc1500.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/winc1500/wifi_winc1500.c:577 - ret = winc1500_socket_recv(socket, w1500_data.socket_data[socket].pkt_buf->data, - CONFIG_WIFI_WINC1500_MAX_PACKET_SIZE, timeout); + CONFIG_WIFI_WINC1500_MAX_PACKET_SIZE, timeout);
LOG_ERR("recv error %d %s!",
Expand Down Expand Up @@ -816,6 +817,8 @@ static bool handle_socket_msg_recv(SOCKET sock,
}
} else if (pstrRx->pu8Buffer == NULL) {
if (pstrRx->s16BufferSize == SOCK_ERR_CONN_ABORTED) {
winc1500_close(sock);

net_pkt_unref(sd->rx_pkt);
return false;
}
Expand Down

0 comments on commit 35f213e

Please sign in to comment.