drivers: modem: socket: add modem_socket_next_packet_size
Let's hide the internals of sock->packet_sizes[] by adding a function which returns the size of the next waiting packet. Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
parent
e23ada9d4a
commit
25ce3bf3eb
|
@ -19,6 +19,24 @@
|
||||||
* Packet Size Support Functions
|
* Packet Size Support Functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
u16_t modem_socket_next_packet_size(struct modem_socket_config *cfg,
|
||||||
|
struct modem_socket *sock)
|
||||||
|
{
|
||||||
|
u16_t total = 0U;
|
||||||
|
|
||||||
|
k_sem_take(&cfg->sem_lock, K_FOREVER);
|
||||||
|
|
||||||
|
if (!sock || !sock->packet_count) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
total = sock->packet_sizes[0];
|
||||||
|
|
||||||
|
exit:
|
||||||
|
k_sem_give(&cfg->sem_lock);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
static u16_t modem_socket_packet_get_total(struct modem_socket *sock)
|
static u16_t modem_socket_packet_get_total(struct modem_socket *sock)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -59,7 +59,9 @@ struct modem_socket_config {
|
||||||
const struct socket_op_vtable *vtable;
|
const struct socket_op_vtable *vtable;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* return total size of remaining packets */
|
/* return size of the first packet */
|
||||||
|
u16_t modem_socket_next_packet_size(struct modem_socket_config *cfg,
|
||||||
|
struct modem_socket *sock);
|
||||||
int modem_socket_packet_size_update(struct modem_socket_config *cfg,
|
int modem_socket_packet_size_update(struct modem_socket_config *cfg,
|
||||||
struct modem_socket *sock, int new_total);
|
struct modem_socket *sock, int new_total);
|
||||||
int modem_socket_get(struct modem_socket_config *cfg, int family, int type,
|
int modem_socket_get(struct modem_socket_config *cfg, int family, int type,
|
||||||
|
|
Loading…
Reference in a new issue