[PATCH 2/2] scsi: cxlflash: Simplify usage of 'test_bit()'

From: Christophe JAILLET
Date: Sat Nov 27 2021 - 06:49:10 EST


'test_bit()' can access any bit of a bitmap. There is no need to precompute
anything. This just duplicate some computations and is more verbose.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
This is only partially compile tested because I don't have the needed
cross-compiling tool chain.
---
drivers/scsi/cxlflash/vlun.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c
index 5600082145bc..39de9ae49aaf 100644
--- a/drivers/scsi/cxlflash/vlun.c
+++ b/drivers/scsi/cxlflash/vlun.c
@@ -221,12 +221,7 @@ static u64 ba_alloc(struct ba_lun *ba_lun)
*/
static int validate_alloc(struct ba_lun_info *bali, u64 aun)
{
- int idx = 0, bit_pos = 0;
-
- idx = aun / BITS_PER_LONG;
- bit_pos = aun % BITS_PER_LONG;
-
- if (test_bit(bit_pos, (ulong *)&bali->lun_alloc_map[idx]))
+ if (test_bit(aun, (ulong *)bali->lun_alloc_map))
return -1;

return 0;
--
2.30.2