From 5d960d2cd59cf00f75e78522d907cea3c2273d43 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 18 Apr 2024 16:14:38 +0100 Subject: [PATCH] usb/dwc: Further implementation cleanup to fix integer conversions issues --- lib/usb/usb_dwc_common.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/usb/usb_dwc_common.c b/lib/usb/usb_dwc_common.c index 8afcb941ac..6a92afb44e 100644 --- a/lib/usb/usb_dwc_common.c +++ b/lib/usb/usb_dwc_common.c @@ -177,19 +177,17 @@ void dwc_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall) uint8_t dwc_ep_stall_get(usbd_device *usbd_dev, uint8_t addr) { /* Return non-zero if STALL set. */ - if (addr & 0x80) { - return (REBASE(OTG_DIEPCTL(addr & 0x7f)) & - OTG_DIEPCTL0_STALL) ? 1 : 0; + if (addr & 0x80U) { + return (REBASE(OTG_DIEPCTL(addr & 0x7fU)) & OTG_DIEPCTL0_STALL) ? 1U : 0U; } else { - return (REBASE(OTG_DOEPCTL(addr)) & - OTG_DOEPCTL0_STALL) ? 1 : 0; + return (REBASE(OTG_DOEPCTL(addr)) & OTG_DOEPCTL0_STALL) ? 1U : 0U; } } void dwc_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak) { /* It does not make sense to force NAK on IN endpoints. */ - if (addr & 0x80) { + if (addr & 0x80U) { return; } @@ -217,7 +215,7 @@ uint16_t dwc_ep_write_packet(usbd_device *usbd_dev, uint8_t addr, REBASE(OTG_DIEPTSIZ(addr)) = OTG_DIEPSIZ0_PKTCNT | (len & OTG_DIEPSIZ0_XFRSIZ_MASK); REBASE(OTG_DIEPCTL(addr)) |= OTG_DIEPCTL0_EPENA | OTG_DIEPCTL0_CNAK; - const uint8_t *buf8 = buf; + const uint8_t *const buf8 = buf; /* Figure out where to copy the data to */ volatile uint32_t *const fifo = (volatile uint32_t *)(usbd_dev->driver->base_address + OTG_FIFO(addr)); /* Copy the data into the FIFO for this endpoint */