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: mk712 - 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.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+4 -12
+4 -12
drivers/input/touchscreen/mk712.c
··· 82 82 static unsigned short last_x; 83 83 static unsigned short last_y; 84 84 85 - spin_lock(&mk712_lock); 85 + guard(spinlock)(&mk712_lock); 86 86 87 87 status = inb(mk712_io + MK712_STATUS); 88 88 ··· 110 110 last_x = inw(mk712_io + MK712_X) & 0x0fff; 111 111 last_y = inw(mk712_io + MK712_Y) & 0x0fff; 112 112 input_sync(mk712_dev); 113 - spin_unlock(&mk712_lock); 113 + 114 114 return IRQ_HANDLED; 115 115 } 116 116 117 117 static int mk712_open(struct input_dev *dev) 118 118 { 119 - unsigned long flags; 120 - 121 - spin_lock_irqsave(&mk712_lock, flags); 119 + guard(spinlock_irqsave)(&mk712_lock); 122 120 123 121 outb(0, mk712_io + MK712_CONTROL); /* Reset */ 124 122 ··· 127 129 128 130 outb(10, mk712_io + MK712_RATE); /* 187 points per second */ 129 131 130 - spin_unlock_irqrestore(&mk712_lock, flags); 131 - 132 132 return 0; 133 133 } 134 134 135 135 static void mk712_close(struct input_dev *dev) 136 136 { 137 - unsigned long flags; 138 - 139 - spin_lock_irqsave(&mk712_lock, flags); 137 + guard(spinlock_irqsave)(&mk712_lock); 140 138 141 139 outb(0, mk712_io + MK712_CONTROL); 142 - 143 - spin_unlock_irqrestore(&mk712_lock, flags); 144 140 } 145 141 146 142 static int __init mk712_init(void)