drivers/ieee802154: Switch CC2520 to new net_ptk allocator
Now buffer is allocated at the same time. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
7981c2792b
commit
52fd371504
1 changed files with 6 additions and 14 deletions
|
@ -541,9 +541,9 @@ static inline u8_t read_rxfifo_length(struct cc2520_context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool read_rxfifo_content(struct cc2520_context *ctx,
|
static inline bool read_rxfifo_content(struct cc2520_context *ctx,
|
||||||
struct net_buf *frag, u8_t len)
|
struct net_buf *buf, u8_t len)
|
||||||
{
|
{
|
||||||
if (!_cc2520_access(ctx, true, CC2520_INS_RXBUF, 0, frag->data, len)) {
|
if (!_cc2520_access(ctx, true, CC2520_INS_RXBUF, 0, buf->data, len)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ static inline bool read_rxfifo_content(struct cc2520_context *ctx,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
net_buf_add(frag, len);
|
net_buf_add(buf, len);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,6 @@ static void cc2520_rx(int arg)
|
||||||
{
|
{
|
||||||
struct device *dev = INT_TO_POINTER(arg);
|
struct device *dev = INT_TO_POINTER(arg);
|
||||||
struct cc2520_context *cc2520 = dev->driver_data;
|
struct cc2520_context *cc2520 = dev->driver_data;
|
||||||
struct net_buf *pkt_frag = NULL;
|
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
u8_t pkt_len;
|
u8_t pkt_len;
|
||||||
|
|
||||||
|
@ -638,25 +637,18 @@ static void cc2520_rx(int arg)
|
||||||
goto flush;
|
goto flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt = net_pkt_get_reserve_rx(K_NO_WAIT);
|
pkt = net_pkt_alloc_with_buffer(cc2520->iface, pkt_len,
|
||||||
|
AF_UNSPEC, 0, K_NO_WAIT);
|
||||||
if (!pkt) {
|
if (!pkt) {
|
||||||
LOG_ERR("No pkt available");
|
LOG_ERR("No pkt available");
|
||||||
goto flush;
|
goto flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt_frag = net_pkt_get_frag(pkt, K_NO_WAIT);
|
|
||||||
if (!pkt_frag) {
|
|
||||||
LOG_ERR("No pkt_frag available");
|
|
||||||
goto flush;
|
|
||||||
}
|
|
||||||
|
|
||||||
net_pkt_frag_insert(pkt, pkt_frag);
|
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE)) {
|
if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE)) {
|
||||||
pkt_len -= 2;
|
pkt_len -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_rxfifo_content(cc2520, pkt_frag, pkt_len)) {
|
if (!read_rxfifo_content(cc2520, pkt->buffer, pkt_len)) {
|
||||||
LOG_ERR("No content read");
|
LOG_ERR("No content read");
|
||||||
goto flush;
|
goto flush;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue