diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-07-05 08:59:05 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-07-05 09:41:15 -0400 |
commit | 1425b80e0dc0d4b002aee0705dd78c2efc913fee (patch) | |
tree | e2d7325317c7e906272df61348b87b610cae0df4 /drivers/usb | |
parent | c2b65f8422a3f51435c9f60f9752a6ed82d47e13 (diff) |
usb: gadget: fusb300_udc: fix compile warnings
- remove pointer u32 abuse in fusb300_fill_idma_prdtbl().
It is assigned the dma_addr to a pointer and then back.
Poor families may have to recycle variables but we don't
- don't free req.buf in error case. We don't do it in the
ok case so it is probably wrong to do it in error case.
- return in error case. There is no reason to continue
without data and performing ops on an invalid pointer.
- The if (d) statement is bogus since an invalid DMA pointer
is ~0 on some architecutres. And since we return for the
invalid case we don't need it.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/fusb300_udc.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 4739f5baa363..24a924330c81 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c | |||
@@ -997,8 +997,8 @@ static void done(struct fusb300_ep *ep, struct fusb300_request *req, | |||
997 | fusb300_set_cxdone(ep->fusb300); | 997 | fusb300_set_cxdone(ep->fusb300); |
998 | } | 998 | } |
999 | 999 | ||
1000 | void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, | 1000 | static void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, dma_addr_t d, |
1001 | struct fusb300_request *req) | 1001 | u32 len) |
1002 | { | 1002 | { |
1003 | u32 value; | 1003 | u32 value; |
1004 | u32 reg; | 1004 | u32 reg; |
@@ -1010,10 +1010,9 @@ void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, | |||
1010 | reg &= FUSB300_EPPRD0_H; | 1010 | reg &= FUSB300_EPPRD0_H; |
1011 | } while (reg); | 1011 | } while (reg); |
1012 | 1012 | ||
1013 | iowrite32((u32) req->req.buf, ep->fusb300->reg + | 1013 | iowrite32(d, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W1(ep->epnum)); |
1014 | FUSB300_OFFSET_EPPRD_W1(ep->epnum)); | ||
1015 | 1014 | ||
1016 | value = FUSB300_EPPRD0_BTC(req->req.length) | FUSB300_EPPRD0_H | | 1015 | value = FUSB300_EPPRD0_BTC(len) | FUSB300_EPPRD0_H | |
1017 | FUSB300_EPPRD0_F | FUSB300_EPPRD0_L | FUSB300_EPPRD0_I; | 1016 | FUSB300_EPPRD0_F | FUSB300_EPPRD0_L | FUSB300_EPPRD0_I; |
1018 | iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); | 1017 | iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); |
1019 | 1018 | ||
@@ -1050,13 +1049,12 @@ static void fusb300_set_idma(struct fusb300_ep *ep, | |||
1050 | struct fusb300_request *req) | 1049 | struct fusb300_request *req) |
1051 | { | 1050 | { |
1052 | dma_addr_t d; | 1051 | dma_addr_t d; |
1053 | u8 *tmp = NULL; | ||
1054 | 1052 | ||
1055 | d = dma_map_single(NULL, req->req.buf, req->req.length, DMA_TO_DEVICE); | 1053 | d = dma_map_single(NULL, req->req.buf, req->req.length, DMA_TO_DEVICE); |
1056 | 1054 | ||
1057 | if (dma_mapping_error(NULL, d)) { | 1055 | if (dma_mapping_error(NULL, d)) { |
1058 | kfree(req->req.buf); | ||
1059 | printk(KERN_DEBUG "dma_mapping_error\n"); | 1056 | printk(KERN_DEBUG "dma_mapping_error\n"); |
1057 | return; | ||
1060 | } | 1058 | } |
1061 | 1059 | ||
1062 | dma_sync_single_for_device(NULL, d, req->req.length, DMA_TO_DEVICE); | 1060 | dma_sync_single_for_device(NULL, d, req->req.length, DMA_TO_DEVICE); |
@@ -1064,17 +1062,11 @@ static void fusb300_set_idma(struct fusb300_ep *ep, | |||
1064 | fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, | 1062 | fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, |
1065 | FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); | 1063 | FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); |
1066 | 1064 | ||
1067 | tmp = req->req.buf; | 1065 | fusb300_fill_idma_prdtbl(ep, d, req->req.length); |
1068 | req->req.buf = (u8 *)d; | ||
1069 | |||
1070 | fusb300_fill_idma_prdtbl(ep, req); | ||
1071 | /* check idma is done */ | 1066 | /* check idma is done */ |
1072 | fusb300_wait_idma_finished(ep); | 1067 | fusb300_wait_idma_finished(ep); |
1073 | 1068 | ||
1074 | req->req.buf = tmp; | 1069 | dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); |
1075 | |||
1076 | if (d) | ||
1077 | dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); | ||
1078 | } | 1070 | } |
1079 | 1071 | ||
1080 | static void in_ep_fifo_handler(struct fusb300_ep *ep) | 1072 | static void in_ep_fifo_handler(struct fusb300_ep *ep) |