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: spear-keyboard - 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-16-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+2 -6
+2 -6
drivers/input/keyboard/spear-keyboard.c
··· 274 274 struct input_dev *input_dev = kbd->input; 275 275 unsigned int rate = 0, mode_ctl_reg, val; 276 276 277 - mutex_lock(&input_dev->mutex); 277 + guard(mutex)(&input_dev->mutex); 278 278 279 279 /* explicitly enable clock as we may program device */ 280 280 clk_enable(kbd->clk); ··· 315 315 /* restore previous clk state */ 316 316 clk_disable(kbd->clk); 317 317 318 - mutex_unlock(&input_dev->mutex); 319 - 320 318 return 0; 321 319 } 322 320 ··· 324 326 struct spear_kbd *kbd = platform_get_drvdata(pdev); 325 327 struct input_dev *input_dev = kbd->input; 326 328 327 - mutex_lock(&input_dev->mutex); 329 + guard(mutex)(&input_dev->mutex); 328 330 329 331 if (device_may_wakeup(&pdev->dev)) { 330 332 if (kbd->irq_wake_enabled) { ··· 339 341 /* restore current configuration */ 340 342 if (input_device_enabled(input_dev)) 341 343 writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); 342 - 343 - mutex_unlock(&input_dev->mutex); 344 344 345 345 return 0; 346 346 }