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: sun4i-ps2 - 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-23-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+2 -6
+2 -6
drivers/input/serio/sun4i-ps2.c
··· 101 101 unsigned int rxflags = 0; 102 102 u32 rval; 103 103 104 - spin_lock(&drvdata->lock); 104 + guard(spinlock)(&drvdata->lock); 105 105 106 106 /* Get the PS/2 interrupts and clear them */ 107 107 intr_status = readl(drvdata->reg_base + PS2_REG_LSTS); ··· 134 134 writel(intr_status, drvdata->reg_base + PS2_REG_LSTS); 135 135 writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS); 136 136 137 - spin_unlock(&drvdata->lock); 138 - 139 137 return IRQ_HANDLED; 140 138 } 141 139 ··· 144 146 u32 clk_scdf; 145 147 u32 clk_pcdf; 146 148 u32 rval; 147 - unsigned long flags; 148 149 149 150 /* Set line control and enable interrupt */ 150 151 rval = PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN ··· 168 171 rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER 169 172 | PS2_GCTL_BUSEN; 170 173 171 - spin_lock_irqsave(&drvdata->lock, flags); 174 + guard(spinlock_irqsave)(&drvdata->lock); 172 175 writel(rval, drvdata->reg_base + PS2_REG_GCTL); 173 - spin_unlock_irqrestore(&drvdata->lock, flags); 174 176 175 177 return 0; 176 178 }