[U-Boot] [PATCH] usb: dwc2: make truncation of ep->dma_buf explicit for setdma_rx/tx

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Mon Jul 3 16:15:50 UTC 2017


There's an implicit truncation in setdma_rx/tx of the dma_buf address
to 32bit that triggers the following warning with recent GCC versions:

  writel((unsigned int) ep->dma_buf, &reg->out_endp[ep_num].doepdma);
         ^
  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c: In function 'setdma_rx':
  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c:116:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

This change makes the truncation explicit by casting to u32 via
uintptr_t.

Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
---

 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 0d6d2fb..de2c2b7 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -113,7 +113,7 @@ static int setdma_rx(struct dwc2_ep *ep, struct dwc2_request *req)
 	invalidate_dcache_range((unsigned long) ep->dma_buf,
 				(unsigned long) ep->dma_buf + ep->len);
 
-	writel((unsigned int) ep->dma_buf, &reg->out_endp[ep_num].doepdma);
+	writel((u32)(uintptr_t) ep->dma_buf, &reg->out_endp[ep_num].doepdma);
 	writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
 	       &reg->out_endp[ep_num].doeptsiz);
 	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl, &reg->out_endp[ep_num].doepctl);
@@ -161,7 +161,7 @@ static int setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req)
 	while (readl(&reg->grstctl) & TX_FIFO_FLUSH)
 		;
 
-	writel((unsigned long) ep->dma_buf, &reg->in_endp[ep_num].diepdma);
+	writel((u32)(uintptr_t) ep->dma_buf, &reg->in_endp[ep_num].diepdma);
 	writel(DIEPT_SIZ_PKT_CNT(pktcnt) | DIEPT_SIZ_XFER_SIZE(length),
 	       &reg->in_endp[ep_num].dieptsiz);
 
-- 
2.1.4



More information about the U-Boot mailing list