drivers: usb: Do not enable non-existing USB endpoints

Number of USB endpoints is set via DTS, nevertheless USB driver
tries to enable all endpoints as it uses number of endpoints from
nRFx.
This commit makes driver enable only these endpoints that were
enabled in DTS.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
This commit is contained in:
Pawel Dunaj 2019-01-22 15:00:47 +01:00 committed by Carles Cufí
commit bfb23cc5de

View file

@ -507,7 +507,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
struct nrf_usbd_ep_ctx *ep_ctx;
int i;
for (i = 0; i < NRF_USBD_EPIN_CNT; i++) {
for (i = 0; i < CFG_EPIN_CNT; i++) {
ep_ctx = in_endpoint_ctx(i);
__ASSERT_NO_MSG(ep_ctx);
@ -516,7 +516,16 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
}
}
for (i = 0; i < NRF_USBD_EPOUT_CNT; i++) {
if (CFG_EP_ISOIN_CNT) {
ep_ctx = in_endpoint_ctx(NRF_USBD_EPIN(8));
__ASSERT_NO_MSG(ep_ctx);
if (ep_ctx->cfg.en) {
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
}
}
for (i = 0; i < CFG_EPOUT_CNT; i++) {
ep_ctx = out_endpoint_ctx(i);
__ASSERT_NO_MSG(ep_ctx);
@ -524,6 +533,15 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
}
}
if (CFG_EP_ISOOUT_CNT) {
ep_ctx = out_endpoint_ctx(NRF_USBD_EPOUT(8));
__ASSERT_NO_MSG(ep_ctx);
if (ep_ctx->cfg.en) {
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
}
}
}
/**