usb: dwc2: fix possible alignment issues 34/221634/1 accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix tizen_6.0 tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.104330 accepted/tizen/6.0/unified/hotfix/20201103.050745 accepted/tizen/unified/20200108.131630 submit/tizen/20200107.060950 submit/tizen_6.0/20201029.205504 submit/tizen_6.0_hotfix/20201102.192904 submit/tizen_6.0_hotfix/20201103.115104 tizen_6.0.m2_release
authorSimon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Thu, 21 Nov 2019 21:15:23 +0000 (22:15 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 6 Jan 2020 10:53:54 +0000 (19:53 +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.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
[sw0312.kim: backport mainline commit 7dc0ac601571 to remove gcc 9 build warning]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I6031f00b21a66377fa941443c5afc1c40c40b8fe

drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c

index 8f3f5e249b0f15e031cb43f51482610eb9ad601c..69c8caae2ff1045901284023c38aa2499ce42872 100644 (file)
@@ -718,7 +718,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));
@@ -1272,7 +1272,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"