Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 263d9401 authored by Akinobu Mita's avatar Akinobu Mita Committed by James Bottomley
Browse files

[SCSI] hpsa: use find_first_zero_bit



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: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Acked-by: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent de13e965
Loading
Loading
Loading
Loading
+8 −10
Original line number Original line Diff line number Diff line
@@ -579,21 +579,19 @@ static int hpsa_find_target_lun(struct ctlr_info *h,
	int i, found = 0;
	int i, found = 0;
	DECLARE_BITMAP(lun_taken, HPSA_MAX_DEVICES);
	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++) {
	for (i = 0; i < h->ndevices; i++) {
		if (h->dev[i]->bus == bus && h->dev[i]->target != -1)
		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++) {
	i = find_first_zero_bit(lun_taken, HPSA_MAX_DEVICES);
		if (!test_bit(i, lun_taken)) {
	if (i < HPSA_MAX_DEVICES) {
		/* *bus = 1; */
		/* *bus = 1; */
		*target = i;
		*target = i;
		*lun = 0;
		*lun = 0;
		found = 1;
		found = 1;
			break;
		}
	}
	}
	return !found;
	return !found;
}
}