Skip to content

Commit

Permalink
Merge pull request #21028 from benpicco/usbus_cdc_ecm-netdev_new
Browse files Browse the repository at this point in the history
usbus/cdc_ecm: port to netdev_new_api
  • Loading branch information
maribu authored Nov 21, 2024
2 parents a841fc3 + 8cd8547 commit 0054f6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions sys/usb/usbus/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ifneq (,$(filter usbus_cdc_ecm,$(USEMODULE)))
USEMODULE += iolist
USEMODULE += fmt
USEMODULE += usbus_urb
USEMODULE += netdev_new_api
USEMODULE += netdev_eth
USEMODULE += luid
endif
Expand Down
12 changes: 11 additions & 1 deletion sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
uint8_t *buf = cdcecm->data_in;
const iolist_t *iolist_start = iolist;
size_t len = iolist_size(iolist);
size_t res = len;
/* interface with alternative function ID 1 is the interface containing the
* data endpoints, no sense trying to transmit data if it is not active */
if (cdcecm->active_iface != 1) {
Expand Down Expand Up @@ -124,7 +125,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
cdcecm->tx_len = 0;
_signal_tx_xmit(cdcecm);
}
return len;
return res;
}

static int _recv(netdev_t *netdev, void *buf, size_t max_len, void *info)
Expand Down Expand Up @@ -204,11 +205,20 @@ static void _isr(netdev_t *dev)
}
}

static int _confirm_send(netdev_t *netdev, void *info)
{
(void)netdev;
(void)info;

return -EOPNOTSUPP;
}

static const netdev_driver_t netdev_driver_cdcecm = {
.send = _send,
.recv = _recv,
.init = _init,
.isr = _isr,
.get = _get,
.set = _set,
.confirm_send = _confirm_send,
};

0 comments on commit 0054f6c

Please sign in to comment.