Skip to content

Commit 6ed8b7c

Browse files
committed
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/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent d49e7d0 commit 6ed8b7c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/input/serio/sun4i-ps2.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static irqreturn_t sun4i_ps2_interrupt(int irq, void *dev_id)
101101
unsigned int rxflags = 0;
102102
u32 rval;
103103

104-
spin_lock(&drvdata->lock);
104+
guard(spinlock)(&drvdata->lock);
105105

106106
/* Get the PS/2 interrupts and clear them */
107107
intr_status = readl(drvdata->reg_base + PS2_REG_LSTS);
@@ -134,8 +134,6 @@ static irqreturn_t sun4i_ps2_interrupt(int irq, void *dev_id)
134134
writel(intr_status, drvdata->reg_base + PS2_REG_LSTS);
135135
writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS);
136136

137-
spin_unlock(&drvdata->lock);
138-
139137
return IRQ_HANDLED;
140138
}
141139

@@ -146,7 +144,6 @@ static int sun4i_ps2_open(struct serio *serio)
146144
u32 clk_scdf;
147145
u32 clk_pcdf;
148146
u32 rval;
149-
unsigned long flags;
150147

151148
/* Set line control and enable interrupt */
152149
rval = PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN
@@ -171,9 +168,8 @@ static int sun4i_ps2_open(struct serio *serio)
171168
rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER
172169
| PS2_GCTL_BUSEN;
173170

174-
spin_lock_irqsave(&drvdata->lock, flags);
171+
guard(spinlock_irqsave)(&drvdata->lock);
175172
writel(rval, drvdata->reg_base + PS2_REG_GCTL);
176-
spin_unlock_irqrestore(&drvdata->lock, flags);
177173

178174
return 0;
179175
}

0 commit comments

Comments
 (0)