* [PATCH v2] hpsa: remove unneeded loop
@ 2013-09-11 14:42 Tomas Henzl
0 siblings, 0 replies; only message in thread
From: Tomas Henzl @ 2013-09-11 14:42 UTC (permalink / raw)
To: 'linux-scsi@vger.kernel.org'; +Cc: Stephen M. Cameron, James Bottomley
From: Tomas Henzl <thenzl@redhat.com>
Originally this was first patch in a series, but while the other patches
were taken into 'for-next', this one was forgotten.
The code below is adapted for the 'for=next' branch.
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 31489b5..6069c45 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -2736,15 +2736,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));
spin_unlock_irqrestore(&h->lock, flags);
c = h->cmd_pool + i;
--
1.8.3.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-09-11 14:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 14:42 [PATCH v2] hpsa: remove unneeded loop 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).