usb: gadget: sdp: fix pointer cast warnings for 64bit archs
The SDP protocol contains multiple 32bit pointers. Add a helper function
to get a valid pointer from these values and use it.
This fixes the following warnings:
drivers/usb/gadget/f_sdp.c: In function ‘sdp_rx_data_complete’:
drivers/usb/gadget/f_sdp.c:347:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
memcpy((void *)sdp->dnl_address, req->buf + 1, datalen);
^
drivers/usb/gadget/f_sdp.c: In function ‘sdp_jump_imxheader’:
drivers/usb/gadget/f_sdp.c:625:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
entry = (void *)headerv2->entry;
^
drivers/usb/gadget/f_sdp.c: In function ‘sdp_handle_in_ep’:
drivers/usb/gadget/f_sdp.c:668:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
memcpy(&data[1], (void *)sdp_func->dnl_address, datalen);
^
drivers/usb/gadget/f_sdp.c:679:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
status = sdp_jump_imxheader((void *)sdp_func->jmp_address);
^
Signed-off-by: Andre Heider <a.heider@gmail.com>
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 6da0530..43c5cfb 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -230,6 +230,11 @@
NULL,
};
+static inline void *sdp_ptr(u32 val)
+{
+ return (void *)(uintptr_t)val;
+}
+
static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
{
struct f_sdp *sdp = req->context;
@@ -344,7 +349,7 @@
}
if (sdp->state == SDP_STATE_RX_FILE_DATA) {
- memcpy((void *)sdp->dnl_address, req->buf + 1, datalen);
+ memcpy(sdp_ptr(sdp->dnl_address), req->buf + 1, datalen);
sdp->dnl_address += datalen;
}
@@ -622,7 +627,7 @@
}
printf("Jumping to 0x%08x\n", headerv2->entry);
- entry = (void *)headerv2->entry;
+ entry = sdp_ptr(headerv2->entry);
entry();
/* The image probably never returns hence we won't reach that point */
@@ -665,7 +670,7 @@
if (datalen > 64)
datalen = 64;
- memcpy(&data[1], (void *)sdp_func->dnl_address, datalen);
+ memcpy(&data[1], sdp_ptr(sdp_func->dnl_address), datalen);
sdp_func->in_req->length = 65;
sdp_func->dnl_bytes_remaining -= datalen;
@@ -676,7 +681,7 @@
break;
case SDP_STATE_JUMP:
printf("Jumping to header at 0x%08x\n", sdp_func->jmp_address);
- status = sdp_jump_imxheader((void *)sdp_func->jmp_address);
+ status = sdp_jump_imxheader(sdp_ptr(sdp_func->jmp_address));
/* If imx header fails, try some U-Boot specific headers */
if (status) {