linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com,
	jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH 2/2] scsi: cxlflash: Simplify usage of 'test_bit()'
Date: Sat, 27 Nov 2021 12:46:49 +0100	[thread overview]
Message-ID: <118d5b49e1341e4fed45b03d64a083a34556667f.1638013435.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <00ffdfddd892c40542db1012658a58934161fb58.1638013435.git.christophe.jaillet@wanadoo.fr>

'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(-)

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


      reply	other threads:[~2021-11-27 11:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 11:46 [PATCH 1/2] scsi: cxlflash: Use 'bitmap_set()' to simplify the code Christophe JAILLET
2021-11-27 11:46 ` Christophe JAILLET [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=118d5b49e1341e4fed45b03d64a083a34556667f.1638013435.git.christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manoj@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mrochs@linux.ibm.com \
    --cc=ukrishn@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).