drivers/nble: Convert RPC serialization code to use net_buf
Using net_buf helps us remove a lot of the pointer & data length book-keeping variables and in general makes the code more readable. Change-Id: Iec870a3bacbb63b55329ef5214b0ee0a757f5b1e Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
6514cda4b2
commit
58ba5e8633
3 changed files with 100 additions and 143 deletions
|
@ -64,7 +64,7 @@ static void rx_fiber(void)
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t *rpc_alloc_cb(uint16_t length)
|
||||
struct net_buf *rpc_alloc_cb(uint16_t length)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
@ -82,7 +82,7 @@ uint8_t *rpc_alloc_cb(uint16_t length)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return buf->__buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void poll_out(const void *buf, size_t length)
|
||||
|
@ -94,14 +94,13 @@ static void poll_out(const void *buf, size_t length)
|
|||
}
|
||||
}
|
||||
|
||||
void rpc_transmit_cb(uint8_t *data, uint16_t length)
|
||||
void rpc_transmit_cb(struct net_buf *buf)
|
||||
{
|
||||
struct net_buf *buf = CONTAINER_OF(data, struct net_buf, __buf);
|
||||
struct ipc_uart_header hdr;
|
||||
|
||||
BT_DBG("buf %p length %u", data, length);
|
||||
BT_DBG("buf %p length %u", buf, buf->len);
|
||||
|
||||
hdr.len = length;
|
||||
hdr.len = buf->len;
|
||||
hdr.channel = 0;
|
||||
hdr.src_cpu_id = 0;
|
||||
|
||||
|
@ -109,7 +108,7 @@ void rpc_transmit_cb(uint8_t *data, uint16_t length)
|
|||
poll_out(&hdr, sizeof(hdr));
|
||||
|
||||
/* Send data */
|
||||
poll_out(buf->data, length);
|
||||
poll_out(buf->data, buf->len);
|
||||
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue