Message ID | 118d5b49e1341e4fed45b03d64a083a34556667f.1638013435.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] scsi: cxlflash: Use 'bitmap_set()' to simplify the code | expand |
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;
'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@wanadoo.fr> --- 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(-)