aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hildenbrand <[email protected]>2020-11-12 14:37:48 +0100
committerMichael S. Tsirkin <[email protected]>2020-12-18 16:14:25 -0500
commit347202dc04a110bdab8d4e1c38ceccd7758fe13e (patch)
treeb300e385bf4a2816357584807af73bca66daf5ba
parent6725f21157b4b6a9fe689cdf07b040d21ea536dd (diff)
virtio-mem: more precise calculation in virtio_mem_mb_state_prepare_next_mb()
We actually need one byte less (next_mb_id is exclusive, first_mb_id is inclusive). While at it, compact the code. Cc: "Michael S. Tsirkin" <[email protected]> Cc: Jason Wang <[email protected]> Cc: Pankaj Gupta <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
-rw-r--r--drivers/virtio/virtio_mem.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index a37fd73588da..dee46865bae2 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -257,10 +257,8 @@ static enum virtio_mem_mb_state virtio_mem_mb_get_state(struct virtio_mem *vm,
*/
static int virtio_mem_mb_state_prepare_next_mb(struct virtio_mem *vm)
{
- unsigned long old_bytes = vm->next_mb_id - vm->first_mb_id + 1;
- unsigned long new_bytes = vm->next_mb_id - vm->first_mb_id + 2;
- int old_pages = PFN_UP(old_bytes);
- int new_pages = PFN_UP(new_bytes);
+ int old_pages = PFN_UP(vm->next_mb_id - vm->first_mb_id);
+ int new_pages = PFN_UP(vm->next_mb_id - vm->first_mb_id + 1);
uint8_t *new_mb_state;
if (vm->mb_state && old_pages == new_pages)