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

Configure Feed

Select the types of activity you want to include in your feed.

Input: sa1111ps2 - 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-18-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+3 -5
+3 -5
drivers/input/serio/sa1111ps2.c
··· 92 92 struct ps2if *ps2if = dev_id; 93 93 unsigned int status; 94 94 95 - spin_lock(&ps2if->lock); 95 + guard(spinlock)(&ps2if->lock); 96 + 96 97 status = readl_relaxed(ps2if->base + PS2STAT); 97 98 if (ps2if->head == ps2if->tail) { 98 99 disable_irq_nosync(irq); ··· 102 101 writel_relaxed(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); 103 102 ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); 104 103 } 105 - spin_unlock(&ps2if->lock); 106 104 107 105 return IRQ_HANDLED; 108 106 } ··· 113 113 static int ps2_write(struct serio *io, unsigned char val) 114 114 { 115 115 struct ps2if *ps2if = io->port_data; 116 - unsigned long flags; 117 116 unsigned int head; 118 117 119 - spin_lock_irqsave(&ps2if->lock, flags); 118 + guard(spinlock_irqsave)(&ps2if->lock); 120 119 121 120 /* 122 121 * If the TX register is empty, we can go straight out. ··· 132 133 } 133 134 } 134 135 135 - spin_unlock_irqrestore(&ps2if->lock, flags); 136 136 return 0; 137 137 } 138 138