mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-03 00:03:44 +00:00
Input: q40kbd - 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/20240905041732.2034348-17-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
@@ -39,17 +39,14 @@ struct q40kbd {
|
||||
static irqreturn_t q40kbd_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct q40kbd *q40kbd = dev_id;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&q40kbd->lock, flags);
|
||||
guard(spinlock_irqsave)(&q40kbd->lock);
|
||||
|
||||
if (Q40_IRQ_KEYB_MASK & master_inb(INTERRUPT_REG))
|
||||
serio_interrupt(q40kbd->port, master_inb(KEYCODE_REG), 0);
|
||||
|
||||
master_outb(-1, KEYBOARD_UNLOCK_REG);
|
||||
|
||||
spin_unlock_irqrestore(&q40kbd->lock, flags);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -60,14 +57,11 @@ static irqreturn_t q40kbd_interrupt(int irq, void *dev_id)
|
||||
static void q40kbd_flush(struct q40kbd *q40kbd)
|
||||
{
|
||||
int maxread = 100;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&q40kbd->lock, flags);
|
||||
guard(spinlock_irqsave)(&q40kbd->lock);
|
||||
|
||||
while (maxread-- && (Q40_IRQ_KEYB_MASK & master_inb(INTERRUPT_REG)))
|
||||
master_inb(KEYCODE_REG);
|
||||
|
||||
spin_unlock_irqrestore(&q40kbd->lock, flags);
|
||||
}
|
||||
|
||||
static void q40kbd_stop(void)
|
||||
|
||||
Reference in New Issue
Block a user