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

Using guard notation 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.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/Zxr4nF-igbrmgq85@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+8 -8
+8 -8
drivers/input/keyboard/omap-keypad.c
··· 156 156 if ((state != 1) && (state != 0)) 157 157 return -EINVAL; 158 158 159 - mutex_lock(&kp_enable_mutex); 160 - if (state != kp_enable) { 161 - if (state) 162 - enable_irq(omap_kp->irq); 163 - else 164 - disable_irq(omap_kp->irq); 165 - kp_enable = state; 159 + scoped_guard(mutex, &kp_enable_mutex) { 160 + if (state != kp_enable) { 161 + if (state) 162 + enable_irq(omap_kp->irq); 163 + else 164 + disable_irq(omap_kp->irq); 165 + kp_enable = state; 166 + } 166 167 } 167 - mutex_unlock(&kp_enable_mutex); 168 168 169 169 return strnlen(buf, count); 170 170 }