diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-06-11 22:31:42 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-06-28 15:06:29 -0700 |
commit | 68bf7a8cc5f3ec6630d6a8b2675288694b1a5f63 (patch) | |
tree | 06673c419b21de3fc4c70ec5d5537d5b8d39cec1 | |
parent | 19a3e1600671b54b2a11203479ed7358d5a8d8d8 (diff) |
Input: wacom_w8001 - use "guard" notation when acquiring mutex
Switch the driver to use guard notation when acquiring mutex to
have it released automatically.
Link: https://lore.kernel.org/r/Zmkyvkr9AFyywy1V@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/wacom_w8001.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index c8abb9557ee8..ed2ca8a689d5 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -380,30 +380,28 @@ static int w8001_open(struct input_dev *dev) struct w8001 *w8001 = input_get_drvdata(dev); int err; - err = mutex_lock_interruptible(&w8001->mutex); - if (err) - return err; + scoped_guard(mutex_intr, &w8001->mutex) { + if (w8001->open_count == 0) { + err = w8001_command(w8001, W8001_CMD_START, false); + if (err) + return err; + } - if (w8001->open_count++ == 0) { - err = w8001_command(w8001, W8001_CMD_START, false); - if (err) - w8001->open_count--; + w8001->open_count++; + return 0; } - mutex_unlock(&w8001->mutex); - return err; + return -EINTR; } static void w8001_close(struct input_dev *dev) { struct w8001 *w8001 = input_get_drvdata(dev); - mutex_lock(&w8001->mutex); + guard(mutex)(&w8001->mutex); if (--w8001->open_count == 0) w8001_command(w8001, W8001_CMD_STOP, false); - - mutex_unlock(&w8001->mutex); } static int w8001_detect(struct w8001 *w8001) |