usb: netusb: Add netusb_recv method

This method can be use by netusb functions on pkt reception.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
This commit is contained in:
Loic Poulain 2017-11-03 14:27:46 +01:00 committed by Jukka Rissanen
parent 53d8389a6c
commit 0188881599
3 changed files with 14 additions and 10 deletions

View File

@ -105,12 +105,9 @@ void ecm_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
net_hexdump_frags(">", in_pkt);
if (net_recv_data(ecm.iface, in_pkt) < 0) {
SYS_LOG_ERR("Queueing packet %p failed", in_pkt);
net_pkt_unref(in_pkt);
}
netusb_recv(in_pkt);
in_pkt = NULL;
return;
}
@ -162,11 +159,7 @@ void ecm_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
net_hexdump_frags(">", in_pkt);
if (net_recv_data(ecm.iface, in_pkt) < 0) {
SYS_LOG_ERR("Queueing packet %p failed", in_pkt);
net_pkt_unref(in_pkt);
}
netusb_recv(in_pkt);
in_pkt = NULL;
}
}

View File

@ -50,6 +50,16 @@ static int netusb_send(struct net_if *iface, struct net_pkt *pkt)
return -ENODEV;
}
void netusb_recv(struct net_pkt *pkt)
{
SYS_LOG_DBG("Recv pkt, len %u", net_pkt_get_len(pkt));
if (net_recv_data(netusb.iface, pkt)) {
SYS_LOG_ERR("Queueing packet %p failed", pkt);
net_pkt_unref(pkt);
}
}
static struct usb_ep_cfg_data netusb_ep_data[] = {
/* Configuration ECM */
{

View File

@ -12,4 +12,5 @@ struct netusb_function {
int (*connect_media)(bool status);
};
void netusb_recv(struct net_pkt *pkt);
int try_write(u8_t ep, u8_t *data, u16_t len);