linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] hpsa: remove unneeded loop
@ 2013-08-01 13:11 Tomas Henzl
  2013-08-01 13:14 ` [PATCH 2/3] hpsa: fix a race in cmd_free/scsi_done Tomas Henzl
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Tomas Henzl @ 2013-08-01 13:11 UTC (permalink / raw)
  To: 'linux-scsi@vger.kernel.org'
  Cc: Stephen M. Cameron, stephenmcameron, mikem

From: Tomas Henzl <thenzl@redhat.com>

The cmd_pool_bits is protected everywhere with a spinlock, 
we don't need the test_and_set_bit, set_bit is enough and the loop
can be removed too.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
 drivers/scsi/hpsa.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 796482b..d7df01e 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2662,15 +2662,12 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
 	unsigned long flags;
 
 	spin_lock_irqsave(&h->lock, flags);
-	do {
-		i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
-		if (i == h->nr_cmds) {
-			spin_unlock_irqrestore(&h->lock, flags);
-			return NULL;
-		}
-	} while (test_and_set_bit
-		 (i & (BITS_PER_LONG - 1),
-		  h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0);
+	i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
+	if (i == h->nr_cmds) {
+		spin_unlock_irqrestore(&h->lock, flags);
+		return NULL;
+	}
+	set_bit(i & (BITS_PER_LONG - 1), h->cmd_pool_bits + (i / BITS_PER_LONG));
 	h->nr_allocs++;
 	spin_unlock_irqrestore(&h->lock, flags);
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-08-26 10:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 13:11 [PATCH 1/3] hpsa: remove unneeded loop Tomas Henzl
2013-08-01 13:14 ` [PATCH 2/3] hpsa: fix a race in cmd_free/scsi_done Tomas Henzl
2013-08-01 13:46   ` scameron
2013-08-01 13:14 ` [PATCH 3/3] hpsa: remove unneeded variable Tomas Henzl
2013-08-01 13:48   ` scameron
2013-08-01 13:39 ` [PATCH 1/3] hpsa: remove unneeded loop scameron
2013-08-01 14:05   ` Tomas Henzl
2013-08-01 14:21     ` scameron
2013-08-01 14:59       ` Tomas Henzl
2013-08-01 15:19         ` scameron
2013-08-01 15:39           ` Tomas Henzl
2013-08-01 16:18             ` scameron
2013-08-02 11:13               ` Tomas Henzl
2013-08-06 15:46                 ` scameron
2013-08-07 12:23                   ` Tomas Henzl
2013-08-26 10:57 ` Tomas Henzl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).