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

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>

+1 -3
+1 -3
drivers/input/keyboard/hilkbd.c
··· 180 180 /* send a command to the HIL */ 181 181 static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len) 182 182 { 183 - unsigned long flags; 183 + guard(spinlock_irqsave)(&hil_dev.lock); 184 184 185 - spin_lock_irqsave(&hil_dev.lock, flags); 186 185 while (hil_busy()) 187 186 /* wait */; 188 187 hil_command(cmd); ··· 190 191 /* wait */; 191 192 hil_write_data(*(data++)); 192 193 } 193 - spin_unlock_irqrestore(&hil_dev.lock, flags); 194 194 } 195 195 196 196