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: ep93xx_keypad - use guard notation when acquiring mutex

This makes the code more compact and error handling more robust
by ensuring that mutexes are released in all code paths when control
leaves critical section.

Link: https://lore.kernel.org/r/20240825051627.2848495-5-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+2 -6
+2 -6
drivers/input/keyboard/ep93xx_keypad.c
··· 184 184 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); 185 185 struct input_dev *input_dev = keypad->input_dev; 186 186 187 - mutex_lock(&input_dev->mutex); 187 + guard(mutex)(&input_dev->mutex); 188 188 189 189 if (keypad->enabled) { 190 190 clk_disable(keypad->clk); 191 191 keypad->enabled = false; 192 192 } 193 - 194 - mutex_unlock(&input_dev->mutex); 195 193 196 194 return 0; 197 195 } ··· 200 202 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); 201 203 struct input_dev *input_dev = keypad->input_dev; 202 204 203 - mutex_lock(&input_dev->mutex); 205 + guard(mutex)(&input_dev->mutex); 204 206 205 207 if (input_device_enabled(input_dev)) { 206 208 if (!keypad->enabled) { ··· 209 211 keypad->enabled = true; 210 212 } 211 213 } 212 - 213 - mutex_unlock(&input_dev->mutex); 214 214 215 215 return 0; 216 216 }