drivers/ieee802154: Switch MCR20A 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:
Tomasz Bursztyka 2019-02-20 12:07:23 +01:00 committed by Anas Nashif
commit f63e9d295b

View file

@ -532,36 +532,30 @@ static inline bool read_rxfifo_content(struct mcr20a_context *dev,
.count = 2
};
if (spi_transceive(dev->spi, &dev->spi_cfg, &tx, &rx) == 0) {
net_buf_add(buf, len);
if (spi_transceive(dev->spi, &dev->spi_cfg, &tx, &rx) != 0) {
return false;
}
net_buf_add(buf, len);
return true;
}
static inline void mcr20a_rx(struct mcr20a_context *mcr20a, u8_t len)
{
struct net_pkt *pkt = NULL;
struct net_buf *frag;
u8_t pkt_len;
pkt_len = len - MCR20A_FCS_LENGTH;
pkt = net_pkt_get_reserve_rx(K_NO_WAIT);
pkt = net_pkt_alloc_with_buffer(mcr20a->iface, pkt_len,
AF_UNSPEC, 0, K_NO_WAIT);
if (!pkt) {
LOG_ERR("No buf available");
goto out;
}
frag = net_pkt_get_frag(pkt, K_NO_WAIT);
if (!frag) {
LOG_ERR("No frag available");
goto out;
}
net_pkt_frag_insert(pkt, frag);
if (!read_rxfifo_content(mcr20a, frag, pkt_len)) {
if (!read_rxfifo_content(mcr20a, pkt->buffer, pkt_len)) {
LOG_ERR("No content read");
goto out;
}