Skip to content

Commit 9da0f2a

Browse files
aportjukkar
authored andcommitted
drivers: modem: use zsock_ variants of socket API
By using the Zephyr-native zsock_ family of types and functions, these drivers will be decoupled from NET_SOCKETS_POSIX_NAMES. Signed-off-by: Adam Porter <[email protected]>
1 parent 603c24d commit 9da0f2a

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

drivers/modem/modem_socket.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void modem_socket_put(struct modem_socket_config *cfg, int sock_fd)
257257
* initial implementation, but this should be improved in the future.
258258
*/
259259
int modem_socket_poll(struct modem_socket_config *cfg,
260-
struct pollfd *fds, int nfds, int msecs)
260+
struct zsock_pollfd *fds, int nfds, int msecs)
261261
{
262262
struct modem_socket *sock;
263263
int ret, i;
@@ -274,10 +274,10 @@ int modem_socket_poll(struct modem_socket_config *cfg,
274274
* Handle user check for POLLOUT events:
275275
* we consider the socket to always be writeable.
276276
*/
277-
if (fds[i].events & POLLOUT) {
278-
fds[i].revents |= POLLOUT;
277+
if (fds[i].events & ZSOCK_POLLOUT) {
278+
fds[i].revents |= ZSOCK_POLLOUT;
279279
found_count++;
280-
} else if (fds[i].events & POLLIN) {
280+
} else if (fds[i].events & ZSOCK_POLLIN) {
281281
sock->is_polled = true;
282282
}
283283
}
@@ -296,8 +296,9 @@ int modem_socket_poll(struct modem_socket_config *cfg,
296296
continue;
297297
}
298298

299-
if (fds[i].events & POLLIN && sock->packet_sizes[0] > 0U) {
300-
fds[i].revents |= POLLIN;
299+
if ((fds[i].events & ZSOCK_POLLIN) &&
300+
(sock->packet_sizes[0] > 0U)) {
301+
fds[i].revents |= ZSOCK_POLLIN;
301302
found_count++;
302303
}
303304

drivers/modem/modem_socket.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct modem_socket *modem_socket_from_id(struct modem_socket_config *cfg,
7474
struct modem_socket *modem_socket_from_newid(struct modem_socket_config *cfg);
7575
void modem_socket_put(struct modem_socket_config *cfg, int sock_fd);
7676
int modem_socket_poll(struct modem_socket_config *cfg,
77-
struct pollfd *fds, int nfds, int msecs);
77+
struct zsock_pollfd *fds, int nfds, int msecs);
7878
void modem_socket_wait_data(struct modem_socket_config *cfg,
7979
struct modem_socket *sock);
8080
void modem_socket_data_ready(struct modem_socket_config *cfg,

drivers/modem/ublox-sara-r4.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static struct modem_data mdata;
176176
static struct modem_context mctx;
177177

178178
#if defined(CONFIG_DNS_RESOLVER)
179-
static struct addrinfo result;
179+
static struct zsock_addrinfo result;
180180
static struct sockaddr result_addr;
181181
static char result_canonname[DNS_MAX_NAME_SIZE + 1];
182182
#endif
@@ -1308,7 +1308,7 @@ static int offload_connect(void *obj, const struct sockaddr *addr,
13081308
}
13091309

13101310
/* support for POLLIN only for now. */
1311-
static int offload_poll(struct pollfd *fds, int nfds, int msecs)
1311+
static int offload_poll(struct zsock_pollfd *fds, int nfds, int msecs)
13121312
{
13131313
int i;
13141314
void *obj;
@@ -1350,15 +1350,15 @@ static ssize_t offload_recvfrom(void *obj, void *buf, size_t len,
13501350
return -1;
13511351
}
13521352

1353-
if (flags & MSG_PEEK) {
1353+
if (flags & ZSOCK_MSG_PEEK) {
13541354
errno = ENOTSUP;
13551355
return -1;
13561356
}
13571357

13581358
next_packet_size = modem_socket_next_packet_size(&mdata.socket_config,
13591359
sock);
13601360
if (!next_packet_size) {
1361-
if (flags & MSG_DONTWAIT) {
1361+
if (flags & ZSOCK_MSG_DONTWAIT) {
13621362
errno = EAGAIN;
13631363
return -1;
13641364
}
@@ -1560,8 +1560,8 @@ NET_SOCKET_REGISTER(ublox_sara_r4, AF_UNSPEC, offload_is_supported,
15601560
* Later, we can add additional handling if it makes sense.
15611561
*/
15621562
static int offload_getaddrinfo(const char *node, const char *service,
1563-
const struct addrinfo *hints,
1564-
struct addrinfo **res)
1563+
const struct zsock_addrinfo *hints,
1564+
struct zsock_addrinfo **res)
15651565
{
15661566
struct modem_cmd cmd = MODEM_CMD("+UDNSRN: ", on_cmd_dns, 1U, ",");
15671567
uint32_t port = 0U;
@@ -1583,7 +1583,7 @@ static int offload_getaddrinfo(const char *node, const char *service,
15831583
if (service) {
15841584
port = ATOI(service, 0U, "port");
15851585
if (port < 1 || port > USHRT_MAX) {
1586-
return EAI_SERVICE;
1586+
return DNS_EAI_SERVICE;
15871587
}
15881588
}
15891589

@@ -1604,7 +1604,7 @@ static int offload_getaddrinfo(const char *node, const char *service,
16041604

16051605
/* user flagged node as numeric host, but we failed net_addr_pton */
16061606
if (hints && hints->ai_flags & AI_NUMERICHOST) {
1607-
return EAI_NONAME;
1607+
return DNS_EAI_NONAME;
16081608
}
16091609

16101610
snprintk(sendbuf, sizeof(sendbuf), "AT+UDNSRN=0,\"%s\"", node);
@@ -1620,11 +1620,11 @@ static int offload_getaddrinfo(const char *node, const char *service,
16201620
&net_sin(&result_addr)->sin_addr,
16211621
sendbuf, NET_IPV4_ADDR_LEN)));
16221622

1623-
*res = (struct addrinfo *)&result;
1623+
*res = (struct zsock_addrinfo *)&result;
16241624
return 0;
16251625
}
16261626

1627-
static void offload_freeaddrinfo(struct addrinfo *res)
1627+
static void offload_freeaddrinfo(struct zsock_addrinfo *res)
16281628
{
16291629
/* using static result from offload_getaddrinfo() -- no need to free */
16301630
res = NULL;

0 commit comments

Comments
 (0)