mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Henry Sloan <henryksloan@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: pbonzini@redhat.com, Henry Sloan <henryksloan@gmail.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 7/7] KVM: Modified two MMIO functions to return bool
Date: Sat,  5 Mar 2022 22:19:07 -0500	[thread overview]
Message-ID: <20220306031907.210499-9-henryksloan@gmail.com> (raw)
In-Reply-To: <20220306031907.210499-1-henryksloan@gmail.com>

Adjusted the signatures and implementations of
coalesced_mmio_in_range and coalesced_mmio_has_room to produce booleans.

Signed-off-by: Henry Sloan <henryksloan@gmail.com>
---
 virt/kvm/coalesced_mmio.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index 1ff2bca6489c..e129d88a95c5 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -22,28 +22,27 @@ static inline struct kvm_coalesced_mmio_dev *to_mmio(struct kvm_io_device *dev)
 	return container_of(dev, struct kvm_coalesced_mmio_dev, dev);
 }
 
-static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
-				   gpa_t addr, int len)
+static bool coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
+				    gpa_t addr, int len)
 {
 	/* is it in a batchable area ?
 	 * (addr,len) is fully included in
 	 * (zone->addr, zone->size)
 	 */
 	if (len < 0)
-		return 0;
+		return false;
 	if (addr + len < addr)
-		return 0;
+		return false;
 	if (addr < dev->zone.addr)
-		return 0;
+		return false;
 	if (addr + len > dev->zone.addr + dev->zone.size)
-		return 0;
-	return 1;
+		return false;
+	return true;
 }
 
-static int coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev, u32 last)
+static bool coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev, u32 last)
 {
 	struct kvm_coalesced_mmio_ring *ring;
-	unsigned int avail;
 
 	/* Are we able to batch it ? */
 
@@ -52,13 +51,7 @@ static int coalesced_mmio_has_room(struct kvm_coalesced_mmio_dev *dev, u32 last)
 	 * there is always one unused entry in the buffer
 	 */
 	ring = dev->kvm->coalesced_mmio_ring;
-	avail = (ring->first - last - 1) % KVM_COALESCED_MMIO_MAX;
-	if (avail == 0) {
-		/* full */
-		return 0;
-	}
-
-	return 1;
+	return (ring->first - last - 1) % KVM_COALESCED_MMIO_MAX != 0;
 }
 
 static int coalesced_mmio_write(struct kvm_vcpu *vcpu,
-- 
2.35.1


      parent reply	other threads:[~2022-03-06  3:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220306031907.210499-1-henryksloan@gmail.com>
2022-03-06  3:19 ` [PATCH v2] KVM: Fix minor indentation and brace style issues Henry Sloan
2022-03-06  3:19 ` [PATCH v2 1/7] KVM: Use typical SPDX comment style Henry Sloan
2022-03-06  3:19 ` [PATCH v2 2/7] KVM: Replace bare 'unsigned' with 'unsigned int' Henry Sloan
2022-03-06  3:19 ` [PATCH v2 3/7] KVM: Replace '__attribute__((weak))' with '__weak' Henry Sloan
2022-03-06  3:19 ` [PATCH v2 4/7] KVM: Add blank lines after some declarations Henry Sloan
2022-03-06  3:19 ` [PATCH v2 5/7] KVM: Use typical style for block comments Henry Sloan
2022-03-06  3:19 ` [PATCH v2 6/7] KVM: Fix minor indentation and brace style issues Henry Sloan
2022-03-06  3:19 ` Henry Sloan [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=20220306031907.210499-9-henryksloan@gmail.com \
    --to=henryksloan@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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®