diff options
| -rw-r--r-- | drivers/usb/host/isp1362-hcd.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 5c774ab98252..73352f3739b5 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c | |||
| @@ -80,7 +80,7 @@ | |||
| 80 | #include <linux/platform_device.h> | 80 | #include <linux/platform_device.h> |
| 81 | #include <linux/pm.h> | 81 | #include <linux/pm.h> |
| 82 | #include <linux/io.h> | 82 | #include <linux/io.h> |
| 83 | #include <linux/bitops.h> | 83 | #include <linux/bitmap.h> |
| 84 | 84 | ||
| 85 | #include <asm/irq.h> | 85 | #include <asm/irq.h> |
| 86 | #include <asm/system.h> | 86 | #include <asm/system.h> |
| @@ -190,10 +190,8 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq, | |||
| 190 | struct isp1362_ep *ep, u16 len) | 190 | struct isp1362_ep *ep, u16 len) |
| 191 | { | 191 | { |
| 192 | int ptd_offset = -EINVAL; | 192 | int ptd_offset = -EINVAL; |
| 193 | int index; | ||
| 194 | int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1; | 193 | int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1; |
| 195 | int found = -1; | 194 | int found; |
| 196 | int last = -1; | ||
| 197 | 195 | ||
| 198 | BUG_ON(len > epq->buf_size); | 196 | BUG_ON(len > epq->buf_size); |
| 199 | 197 | ||
| @@ -205,20 +203,9 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq, | |||
| 205 | epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map); | 203 | epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map); |
| 206 | BUG_ON(ep->num_ptds != 0); | 204 | BUG_ON(ep->num_ptds != 0); |
| 207 | 205 | ||
| 208 | for (index = 0; index <= epq->buf_count - num_ptds; index++) { | 206 | found = bitmap_find_next_zero_area(&epq->buf_map, epq->buf_count, 0, |
| 209 | if (test_bit(index, &epq->buf_map)) | 207 | num_ptds, 0); |
| 210 | continue; | 208 | if (found >= epq->buf_count) |
| 211 | found = index; | ||
| 212 | for (last = index + 1; last < index + num_ptds; last++) { | ||
| 213 | if (test_bit(last, &epq->buf_map)) { | ||
| 214 | found = -1; | ||
| 215 | break; | ||
| 216 | } | ||
| 217 | } | ||
| 218 | if (found >= 0) | ||
| 219 | break; | ||
| 220 | } | ||
| 221 | if (found < 0) | ||
| 222 | return -EOVERFLOW; | 209 | return -EOVERFLOW; |
| 223 | 210 | ||
| 224 | DBG(1, "%s: Found %d PTDs[%d] for %d/%d byte\n", __func__, | 211 | DBG(1, "%s: Found %d PTDs[%d] for %d/%d byte\n", __func__, |
| @@ -230,8 +217,7 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq, | |||
| 230 | epq->buf_avail -= num_ptds; | 217 | epq->buf_avail -= num_ptds; |
| 231 | BUG_ON(epq->buf_avail > epq->buf_count); | 218 | BUG_ON(epq->buf_avail > epq->buf_count); |
| 232 | ep->ptd_index = found; | 219 | ep->ptd_index = found; |
| 233 | for (index = found; index < last; index++) | 220 | bitmap_set(&epq->buf_map, found, num_ptds); |
| 234 | __set_bit(index, &epq->buf_map); | ||
| 235 | DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n", | 221 | DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n", |
| 236 | __func__, epq->name, ep->ptd_index, ep->ptd_offset, | 222 | __func__, epq->name, ep->ptd_index, ep->ptd_offset, |
| 237 | epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map); | 223 | epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map); |
