From: Akinobu Mita <akinobu.mita@gmail.com>
To: FUJITA Tomonori <tomof@acm.org>
Cc: alan@redhat.com, James.Bottomley@HansenPartnership.com,
linux-scsi@vger.kernel.org, hch@lst.de, dledford@redhat.com,
fujita.tomonori@lab.ntt.co.jp
Subject: Re: [PATCH] a100u2w: fix bitmap lookup routine
Date: Thu, 20 Mar 2008 18:34:49 +0900 [thread overview]
Message-ID: <20080320093448.GA30888@APFDCB5C> (raw)
In-Reply-To: <20080320135518W.tomof@acm.org>
On Thu, Mar 20, 2008 at 01:56:28PM +0900, FUJITA Tomonori wrote:
> @@ -715,14 +709,9 @@ static struct orc_scb *orc_alloc_scb(struct orc_host * host)
> static void orc_release_scb(struct orc_host *host, struct orc_scb *scb)
> {
> unsigned long flags;
> - u8 index, i, channel;
>
> spin_lock_irqsave(&(host->allocation_lock), flags);
> - channel = host->index; /* Channel */
> - index = scb->scbidx;
> - i = index / 32;
> - index %= 32;
> - host->allocation_map[channel][i] |= (1 << index);
> + set_bit(scb->scbidx, host->allocation_map[host->index]);
> spin_unlock_irqrestore(&(host->allocation_lock), flags);
> }
>
set_bit() and clear_bit() take unsigned long pointer as a bitmap in
the second argument on some architectures. I'd rather change the type of
allocation_map than proliferating the casts.
This is incremental patch to the original bugfix patch.
Subject: [patch 2/2] a100u2w: convert to use bitmap library for allocation_map
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/scsi/a100u2w.c | 38 ++++++++++++++------------------------
drivers/scsi/a100u2w.h | 3 ++-
2 files changed, 16 insertions(+), 25 deletions(-)
Index: 2.6-rc/drivers/scsi/a100u2w.c
===================================================================
--- 2.6-rc.orig/drivers/scsi/a100u2w.c
+++ 2.6-rc/drivers/scsi/a100u2w.c
@@ -71,6 +71,7 @@
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
+#include <linux/bitmap.h>
#include <asm/io.h>
#include <asm/irq.h>
@@ -478,13 +479,10 @@ static void setup_SCBs(struct orc_host *
static void init_alloc_map(struct orc_host * host)
{
- u8 i, j;
+ int i;
- for (i = 0; i < MAX_CHANNELS; i++) {
- for (j = 0; j < 8; j++) {
- host->allocation_map[i][j] = 0xffffffff;
- }
- }
+ for (i = 0; i < MAX_CHANNELS; i++)
+ bitmap_fill(host->allocation_map[i], 256);
}
/**
@@ -666,21 +664,16 @@ static struct orc_scb *__orc_alloc_scb(s
{
u8 channel;
unsigned long idx;
- u8 index;
- u8 i;
channel = host->index;
- for (i = 0; i < 8; i++) {
- for (index = 0; index < 32; index++) {
- if ((host->allocation_map[channel][i] >> index) & 0x01) {
- host->allocation_map[channel][i] &= ~(1 << index);
- idx = index + 32 * i;
- /*
- * Translate the index to a structure instance
- */
- return host->scb_virt + idx;
- }
- }
+
+ idx = find_first_bit(host->allocation_map[channel], 256);
+ if (idx < 256) {
+ clear_bit(idx, host->allocation_map[channel]);
+ /*
+ * Translate the index to a structure instance
+ */
+ return host->scb_virt + idx;
}
return NULL;
}
@@ -716,14 +709,11 @@ static struct orc_scb *orc_alloc_scb(str
static void orc_release_scb(struct orc_host *host, struct orc_scb *scb)
{
unsigned long flags;
- u8 index, i, channel;
+ u8 channel;
spin_lock_irqsave(&(host->allocation_lock), flags);
channel = host->index; /* Channel */
- index = scb->scbidx;
- i = index / 32;
- index %= 32;
- host->allocation_map[channel][i] |= (1 << index);
+ set_bit(scb->scbidx, host->allocation_map[channel]);
spin_unlock_irqrestore(&(host->allocation_lock), flags);
}
Index: 2.6-rc/drivers/scsi/a100u2w.h
===================================================================
--- 2.6-rc.orig/drivers/scsi/a100u2w.h
+++ 2.6-rc/drivers/scsi/a100u2w.h
@@ -239,7 +239,8 @@ struct orc_host {
dma_addr_t escb_phys; /* scatter list Physical address */
u8 target_flag[16]; /* target configuration, TCF_EN_TAG */
u8 max_tags[16]; /* ORC_MAX_SCBS */
- u32 allocation_map[MAX_CHANNELS][8]; /* Max STB is 256, So 256/32 */
+ /* Max STB is 256 */
+ unsigned long allocation_map[MAX_CHANNELS][BITS_TO_LONGS(256)];
spinlock_t allocation_lock;
struct pci_dev *pdev;
};
next prev parent reply other threads:[~2008-03-20 9:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-17 12:32 [PATCH] a100u2w: fix bitmap lookup routine Akinobu Mita
2008-03-17 13:45 ` Akinobu Mita
2008-03-17 14:46 ` James Bottomley
2008-03-17 16:04 ` Alan Cox
2008-03-19 14:24 ` Alan Cox
2008-03-20 4:56 ` FUJITA Tomonori
2008-03-20 9:34 ` Akinobu Mita [this message]
2008-03-20 9:36 ` Akinobu Mita
2008-03-20 14:12 ` Alan Cox
2008-03-20 14:17 ` James Bottomley
2008-03-20 16:34 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080320093448.GA30888@APFDCB5C \
--to=akinobu.mita@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alan@redhat.com \
--cc=dledford@redhat.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=tomof@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.