Skip to contentSkip to conversation

Input: hilkbd - use guard notation when acquiring spinlock

PATCH New Dmitry Torokhov 1 participant 1 message Oct 25, 2024

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: hilkbd - use guard notation when acquiring spinlock

Using guard notation makes the code more compact and error handling more robust by ensuring that locks are released in all code paths when control leaves critical section.

---
 drivers/input/keyboard/hilkbd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/hilkbd.c +1 -3
index c1a4d5055de6..c8d8d0ea35b0 100644
@@ -180,9 +180,8 @@ static irqreturn_t hil_interrupt(int irq, void *handle)
 /* send a command to the HIL */
 static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
 {
-	unsigned long flags;
+	guard(spinlock_irqsave)(&hil_dev.lock);
 
-	spin_lock_irqsave(&hil_dev.lock, flags);
 	while (hil_busy())
 		/* wait */;
 	hil_command(cmd);
@@ -191,7 +190,6 @@ static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
 			/* wait */;
 		hil_write_data(*(data++));
 	}
-	spin_unlock_irqrestore(&hil_dev.lock, flags);
 }
 
 
Signature · 5 lines
2.47.0.163.g1226f6d8fa-goog


-- 
Dmitry