Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: locomokbd - 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.

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

+1 -4
+1 -4
drivers/input/keyboard/locomokbd.c
··· 112 112 static void locomokbd_scankeyboard(struct locomokbd *locomokbd) 113 113 { 114 114 unsigned int row, col, rowd; 115 - unsigned long flags; 116 115 unsigned int num_pressed; 117 116 unsigned long membase = locomokbd->base; 118 117 119 - spin_lock_irqsave(&locomokbd->lock, flags); 118 + guard(spinlock_irqsave)(&locomokbd->lock); 120 119 121 120 locomokbd_charge_all(membase); 122 121 ··· 166 167 mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL); 167 168 else 168 169 locomokbd->count_cancel = 0; 169 - 170 - spin_unlock_irqrestore(&locomokbd->lock, flags); 171 170 } 172 171 173 172 /*