From: Alessio Maroni <alessiomaroni0@gmail.com>
To: Yury Norov <yury.norov@gmail.com>,
David Hildenbrand <david@kernel.org>,
"Michael S . Tsirkin" <mst@redhat.com>
Cc: "Jason Wang" <jasowangio@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
"Alessio Maroni" <alessiomaroni0@gmail.com>
Subject: [PATCH 2/2] virtio-mem: use bitmap_all_set() and bitmap_all_clear()
Date: Sun, 6 Dec 2026 14:52:20 +0100 [thread overview]
Message-ID: <20261206135220.153130-3-alessiomaroni0@gmail.com> (raw)
In-Reply-To: <20261206135220.153130-1-alessiomaroni0@gmail.com>
Replace the open-coded find_next_zero_bit() and find_next_bit() checks
in virtio_mem_sbm_test_sb_plugged() and
virtio_mem_sbm_test_sb_unplugged() with the new bitmap_all_set() and
bitmap_all_clear() helpers, resolving the TODO comments.
Signed-off-by: Alessio Maroni <alessiomaroni0@gmail.com>
---
drivers/virtio/virtio_mem.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index b28d2da7d5b6..19362d3107a7 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -547,12 +547,7 @@ static bool virtio_mem_sbm_test_sb_plugged(struct virtio_mem *vm,
{
const int bit = virtio_mem_sbm_sb_state_bit_nr(vm, mb_id, sb_id);
- if (count == 1)
- return test_bit(bit, vm->sbm.sb_states);
-
- /* TODO: Helper similar to bitmap_set() */
- return find_next_zero_bit(vm->sbm.sb_states, bit + count, bit) >=
- bit + count;
+ return bitmap_all_set(vm->sbm.sb_states, bit, count);
}
/*
@@ -564,9 +559,7 @@ static bool virtio_mem_sbm_test_sb_unplugged(struct virtio_mem *vm,
{
const int bit = virtio_mem_sbm_sb_state_bit_nr(vm, mb_id, sb_id);
- /* TODO: Helper similar to bitmap_set() */
- return find_next_bit(vm->sbm.sb_states, bit + count, bit) >=
- bit + count;
+ return bitmap_all_clear(vm->sbm.sb_states, bit, count);
}
/*
--
2.56.1
prev parent reply other threads:[~2026-12-06 13:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 13:52 [PATCH 0/2] bitmap: add bitmap_all_set()/bitmap_all_clear() and use in virtio-mem Alessio Maroni
2026-12-06 13:52 ` [PATCH 1/2] bitmap: add bitmap_all_set() and bitmap_all_clear() Alessio Maroni
2026-12-06 13:52 ` Alessio Maroni [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=20261206135220.153130-3-alessiomaroni0@gmail.com \
--to=alessiomaroni0@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=eperezma@redhat.com \
--cc=jasowangio@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yury.norov@gmail.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
all inboxes | Powered by JetHome®