From: Dmitry Torokhov Date: Fri, 25 Oct 2024 01:44:32 +0000 (-0700) Subject: Input: locomokbd - use guard notation when acquiring spinlock X-Git-Tag: v6.13-rc1~95^2^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=229ba714e52f7f29f41c1aa2e9f49feef3629322;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 4b0f8323c4922..c501a93a44178 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -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); } /*