usb: dwc2: fix possible alignment issues 27/220427/2
authorSimon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Thu, 21 Nov 2019 21:15:23 +0000 (22:15 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 19 Dec 2019 00:48:05 +0000 (09:48 +0900)
Since upgrading to gcc9, warnings are issued:
"taking address of packed member of ‘...’ may result in an unaligned
pointer value"

Fix this by converting dwc2_fifo_read to use unaligned access since packed
structures may be on an unaligned address, depending on USB hardware.

Change-Id: I4d86812b06e8c16f3e1cc8fdbe03f26653ecdac5
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

index 5e695b4ff2a26ca40fb4536be40dd8839ddb3305..667e3c99045d542e8b4941d5dc3c0ea077e16eb7 100644 (file)
@@ -731,7 +731,7 @@ static int write_fifo_ep0(struct dwc2_ep *ep, struct dwc2_request *req)
        return 0;
 }
 
-static int dwc2_fifo_read(struct dwc2_ep *ep, u32 *cp, int max)
+static int dwc2_fifo_read(struct dwc2_ep *ep, void *cp, int max)
 {
        invalidate_dcache_range((unsigned long)cp, (unsigned long)cp +
                                ROUND(max, CONFIG_SYS_CACHELINE_SIZE));
@@ -1285,7 +1285,7 @@ static void dwc2_ep0_setup(struct dwc2_udc *dev)
        nuke(ep, -EPROTO);
 
        /* read control req from fifo (8 bytes) */
-       dwc2_fifo_read(ep, (u32 *)usb_ctrl, 8);
+       dwc2_fifo_read(ep, usb_ctrl, 8);
 
        debug_cond(DEBUG_SETUP != 0,
                   "%s: bRequestType = 0x%x(%s), bRequest = 0x%x"