Skip to contentSkip to conversation

KVM: x86: enhance the readability of function pic_intack()

PATCH In review Wang Guangju 2 participants 2 messages Jan 13, 2022 – Jan 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: enhance the readability of function pic_intack()

From: wangguangju <[email protected]>

In function pic_intack(), use a varibale of "mask" to record expression of "1 << irq", so we can enhance the readability of this function.

---
 arch/x86/kvm/i8259.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/kvm/i8259.c +5 -3
index 814064d06016..ad6b64b11adc 100644
@@ -216,12 +216,14 @@ void kvm_pic_clear_all(struct kvm_pic *s, int irq_source_id)
  */
 static inline void pic_intack(struct kvm_kpic_state *s, int irq)
 {
-	s->isr |= 1 << irq;
+	int mask;
+	mask = 1 << irq;
+	s->isr |= mask;
 	/*
 	 * We don't clear a level sensitive interrupt here
 	 */
-	if (!(s->elcr & (1 << irq)))
-		s->irr &= ~(1 << irq);
+	if (!(s->elcr & mask))
+		s->irr &= ~mask;
 
 	if (s->auto_eoi) {
 		if (s->rotate_on_auto_eoi)
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Wang Guangju

From: wangguangju <[email protected]>

In function pic_intack(), use a varibale of "mask" to record expression of "1 << irq", so we can enhance the readability of this function.

Please wrap at ~75 chars.

Quoted 10 lines
---
 arch/x86/kvm/i8259.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/kvm/i8259.c +0 -0
index 814064d06016..ad6b64b11adc 100644

arch/x86/kvm/i8259.c void kvm_pic_clear_all(struct kvm_pic *s, int irq_source_id) · line 219

Quoted 5 lines
arch/x86/kvm/i8259.c +1 -1
@@ -216,12 +216,14 @@ void kvm_pic_clear_all(struct kvm_pic *s, int irq_source_id)
  */
 static inline void pic_intack(struct kvm_kpic_state *s, int irq)
 {
-	s->isr |= 1 << irq;
+	int mask;

Needs a newline, and could also be:

	int mask = 1 << irq;

or even

	int mask = BIT(irq);

That said, I oddly find the existing code more readable. Maybe "irq_mask" instead of "mask"? Dunno. I guess I don't have a strong opinion :-)