public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomof@acm.org>
To: alan@redhat.com
Cc: James.Bottomley@HansenPartnership.com, akinobu.mita@gmail.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 13:56:28 +0900	[thread overview]
Message-ID: <20080320135518W.tomof@acm.org> (raw)
In-Reply-To: <20080319142419.GA27779@devserv.devel.redhat.com>

On Wed, 19 Mar 2008 10:24:19 -0400
Alan Cox <alan@redhat.com> wrote:

> On Mon, Mar 17, 2008 at 09:46:44AM -0500, James Bottomley wrote:
> > On Mon, 2008-03-17 at 21:32 +0900, Akinobu Mita wrote:
> > > This patch is only compile tested.
> > 
> > It looks fine to me ... I don't suppose we can find someone with an
> > actual card to test it out, could we?
> > 
> > Another observation is that this code is really trying to reinvent
> > bitmaps, so if someone with a card cares they could convert it over to
> > the linux bitmap infrastructure.
> 
> If you want it tested then send me the patch.

Can you try this?

Thanks,

diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index f608d4a..a183dab 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -664,22 +664,16 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig
 
 static struct orc_scb *__orc_alloc_scb(struct orc_host * host)
 {
-	u8 channel;
-	unsigned long idx;
-	u8 index;
-	u8 i;
+	long idx;
+	unsigned size = sizeof(host->allocation_map[host->index]) * 8;
+	unsigned long *map = (unsigned long *)host->allocation_map[host->index];
 
-	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);
-				break;
-			}
-		}
-		idx = index + 32 * i;
+	idx = find_first_bit(map, size);
+	if (idx < size) {
+		clear_bit(idx, map);
 		/* Translate the index to a structure instance */
-		return (struct orc_scb *) ((unsigned long) host->scb_virt + (idx * sizeof(struct orc_scb)));
+		return (struct orc_scb *)((unsigned long) host->scb_virt
+					  + (idx * sizeof(struct orc_scb)));
 	}
 	return NULL;
 }
@@ -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);
 }
 

  reply	other threads:[~2008-03-20  4:57 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 [this message]
2008-03-20  9:34       ` Akinobu Mita
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=20080320135518W.tomof@acm.org \
    --to=tomof@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akinobu.mita@gmail.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 \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox