diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-10-24 18:43:44 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-11-05 14:17:20 -0800 |
commit | dda8fdb033f48e759ff190c59aa266905ecba3dd (patch) | |
tree | 38b4dc533f4baef37e2bac26262fabf9a8288c8e /drivers/input/keyboard/hilkbd.c | |
parent | cbdc3f95cdf817e6adc5c783464658d30e9ccb61 (diff) | |
download | lwn-dda8fdb033f48e759ff190c59aa266905ecba3dd.tar.gz lwn-dda8fdb033f48e759ff190c59aa266905ecba3dd.zip |
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.
Link: https://lore.kernel.org/r/Zxr30BpPobpM65vO@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/keyboard/hilkbd.c')
-rw-r--r-- | drivers/input/keyboard/hilkbd.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c index c1a4d5055de6..c8d8d0ea35b0 100644 --- a/drivers/input/keyboard/hilkbd.c +++ b/drivers/input/keyboard/hilkbd.c @@ -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); } |