OSDN Git Service

usb: gadget: core: unmap request from DMA only if previously mapped
authorJack Pham <jackp@codeaurora.org>
Tue, 1 Aug 2017 09:00:56 +0000 (02:00 -0700)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 15 Aug 2017 11:18:54 +0000 (14:18 +0300)
commit31fe084ffaaf8abece14f8ca28e5e3b4e2bf97b6
tree42714e3aa40f6ce62c1e42be22a24de6efe467f1
parentf8faa3bf5fc988e504766b8d1bb7b3d5fb09f6f8
usb: gadget: core: unmap request from DMA only if previously mapped

In the SG case this is already handled since a non-zero
request->num_mapped_sgs is a clear indicator that dma_map_sg()
had been called. While it would be nice to do the same for the
singly mapped case by simply checking for non-zero request->dma,
it's conceivable that 0 is a valid dma_addr_t handle. Hence add
a flag 'dma_mapped' to struct usb_request and use this to
determine the need to call dma_unmap_single(). Otherwise, if a
request is not DMA mapped then the result of calling
usb_request_unmap_request() would safely be a no-op.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/core.c
include/linux/usb/gadget.h