]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: hilkbd - use guard notation when acquiring spinlock
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 25 Oct 2024 01:43:44 +0000 (18:43 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 5 Nov 2024 22:17:20 +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/Zxr30BpPobpM65vO@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/hilkbd.c

index c1a4d5055de63391f4c957f866fa980aa582676a..c8d8d0ea35b0cd5dcf7c586b93df00371e70d4d5 100644 (file)
@@ -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);
 }