* [PATCH] hpsa: use find_first_zero_bit
[not found] <1327072528-8479-1-git-send-email-akinobu.mita@gmail.com>
@ 2012-01-20 15:15 ` Akinobu Mita
2012-01-20 15:41 ` scameron
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2012-01-20 15:15 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Akinobu Mita, Stephen M. Cameron, iss_storagedev,
James E.J. Bottomley, linux-scsi
Use find_first_zero_bit to find the first cleared bit in a memory region.
This also includes the following minor changes.
- Use bitmap_zero
- Reduce unnecessary atomic bitops usage
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
Cc: iss_storagedev@hp.com
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/hpsa.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 7d14443..7f79ed8 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -577,21 +577,19 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
int i, found = 0;
DECLARE_BITMAP(lun_taken, HPSA_MAX_DEVICES);
- memset(&lun_taken[0], 0, HPSA_MAX_DEVICES >> 3);
+ bitmap_zero(lun_taken, HPSA_MAX_DEVICES);
for (i = 0; i < h->ndevices; i++) {
if (h->dev[i]->bus == bus && h->dev[i]->target != -1)
- set_bit(h->dev[i]->target, lun_taken);
+ __set_bit(h->dev[i]->target, lun_taken);
}
- for (i = 0; i < HPSA_MAX_DEVICES; i++) {
- if (!test_bit(i, lun_taken)) {
- /* *bus = 1; */
- *target = i;
- *lun = 0;
- found = 1;
- break;
- }
+ i = find_first_zero_bit(lun_taken, HPSA_MAX_DEVICES);
+ if (i < HPSA_MAX_DEVICES) {
+ /* *bus = 1; */
+ *target = i;
+ *lun = 0;
+ found = 1;
}
return !found;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hpsa: use find_first_zero_bit
2012-01-20 15:15 ` [PATCH] hpsa: use find_first_zero_bit Akinobu Mita
@ 2012-01-20 15:41 ` scameron
0 siblings, 0 replies; 2+ messages in thread
From: scameron @ 2012-01-20 15:41 UTC (permalink / raw)
To: Akinobu Mita
Cc: linux-kernel, akpm, iss_storagedev, James E.J. Bottomley,
linux-scsi, scameron
On Sat, Jan 21, 2012 at 12:15:27AM +0900, Akinobu Mita wrote:
> Use find_first_zero_bit to find the first cleared bit in a memory region.
>
> This also includes the following minor changes.
> - Use bitmap_zero
> - Reduce unnecessary atomic bitops usage
Ack.
This isn't performance sensitive code though, hpsa_find_target_lun()
only gets called during device discovery when a multi-lun device
like a tape drive with an auto changer is encountered.
I tried it out and it doesn't conflict with any of the patches
I sent up yesterday, and it works with a tape drive/autochanger.
-- steve
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
> Cc: iss_storagedev@hp.com
> Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/hpsa.c | 18 ++++++++----------
> 1 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 7d14443..7f79ed8 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -577,21 +577,19 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
> int i, found = 0;
> DECLARE_BITMAP(lun_taken, HPSA_MAX_DEVICES);
>
> - memset(&lun_taken[0], 0, HPSA_MAX_DEVICES >> 3);
> + bitmap_zero(lun_taken, HPSA_MAX_DEVICES);
>
> for (i = 0; i < h->ndevices; i++) {
> if (h->dev[i]->bus == bus && h->dev[i]->target != -1)
> - set_bit(h->dev[i]->target, lun_taken);
> + __set_bit(h->dev[i]->target, lun_taken);
> }
>
> - for (i = 0; i < HPSA_MAX_DEVICES; i++) {
> - if (!test_bit(i, lun_taken)) {
> - /* *bus = 1; */
> - *target = i;
> - *lun = 0;
> - found = 1;
> - break;
> - }
> + i = find_first_zero_bit(lun_taken, HPSA_MAX_DEVICES);
> + if (i < HPSA_MAX_DEVICES) {
> + /* *bus = 1; */
> + *target = i;
> + *lun = 0;
> + found = 1;
> }
> return !found;
> }
> --
> 1.7.4.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-20 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1327072528-8479-1-git-send-email-akinobu.mita@gmail.com>
2012-01-20 15:15 ` [PATCH] hpsa: use find_first_zero_bit Akinobu Mita
2012-01-20 15:41 ` scameron
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).