提交 735e1b9a 编写于 作者: A Akinobu Mita 提交者: Linus Torvalds

isp1362-hcd: use bitmap_find_next_zero_area

Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Lothar Wassmann <LW@KARO-electronics.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a66022c4
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/bitops.h> #include <linux/bitmap.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -190,10 +190,8 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq, ...@@ -190,10 +190,8 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
struct isp1362_ep *ep, u16 len) struct isp1362_ep *ep, u16 len)
{ {
int ptd_offset = -EINVAL; int ptd_offset = -EINVAL;
int index;
int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1; int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1;
int found = -1; int found;
int last = -1;
BUG_ON(len > epq->buf_size); BUG_ON(len > epq->buf_size);
...@@ -205,20 +203,9 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq, ...@@ -205,20 +203,9 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map); epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map);
BUG_ON(ep->num_ptds != 0); BUG_ON(ep->num_ptds != 0);
for (index = 0; index <= epq->buf_count - num_ptds; index++) { found = bitmap_find_next_zero_area(&epq->buf_map, epq->buf_count, 0,
if (test_bit(index, &epq->buf_map)) num_ptds, 0);
continue; if (found >= epq->buf_count)
found = index;
for (last = index + 1; last < index + num_ptds; last++) {
if (test_bit(last, &epq->buf_map)) {
found = -1;
break;
}
}
if (found >= 0)
break;
}
if (found < 0)
return -EOVERFLOW; return -EOVERFLOW;
DBG(1, "%s: Found %d PTDs[%d] for %d/%d byte\n", __func__, 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,8 +217,7 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
epq->buf_avail -= num_ptds; epq->buf_avail -= num_ptds;
BUG_ON(epq->buf_avail > epq->buf_count); BUG_ON(epq->buf_avail > epq->buf_count);
ep->ptd_index = found; ep->ptd_index = found;
for (index = found; index < last; index++) bitmap_set(&epq->buf_map, found, num_ptds);
__set_bit(index, &epq->buf_map);
DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n", DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n",
__func__, epq->name, ep->ptd_index, ep->ptd_offset, __func__, epq->name, ep->ptd_index, ep->ptd_offset,
epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map); epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册