Input: locomokbd - use guard notation when acquiring spinlock
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 25 Oct 2024 01:44:32 +0000 (18:44 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 5 Nov 2024 22:17:25 +0000 (14:17 -0800)
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.

Link: https://lore.kernel.org/r/Zxr4AMJrzhZlHAlf@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/locomokbd.c

index 4b0f832..c501a93 100644 (file)
@@ -112,11 +112,10 @@ static inline void locomokbd_reset_col(unsigned long membase, int col)
 static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
 {
        unsigned int row, col, rowd;
-       unsigned long flags;
        unsigned int num_pressed;
        unsigned long membase = locomokbd->base;
 
-       spin_lock_irqsave(&locomokbd->lock, flags);
+       guard(spinlock_irqsave)(&locomokbd->lock);
 
        locomokbd_charge_all(membase);
 
@@ -167,8 +166,6 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
                mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL);
        else
                locomokbd->count_cancel = 0;
-
-       spin_unlock_irqrestore(&locomokbd->lock, flags);
 }
 
 /*