Commit 68bf7a8c authored by Dmitry Torokhov's avatar Dmitry Torokhov

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.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 19a3e160
...@@ -380,30 +380,28 @@ static int w8001_open(struct input_dev *dev) ...@@ -380,30 +380,28 @@ static int w8001_open(struct input_dev *dev)
struct w8001 *w8001 = input_get_drvdata(dev); struct w8001 *w8001 = input_get_drvdata(dev);
int err; int err;
err = mutex_lock_interruptible(&w8001->mutex); scoped_guard(mutex_intr, &w8001->mutex) {
if (err) if (w8001->open_count == 0) {
return err; err = w8001_command(w8001, W8001_CMD_START, false);
if (err)
return err;
}
if (w8001->open_count++ == 0) { w8001->open_count++;
err = w8001_command(w8001, W8001_CMD_START, false); return 0;
if (err)
w8001->open_count--;
} }
mutex_unlock(&w8001->mutex); return -EINTR;
return err;
} }
static void w8001_close(struct input_dev *dev) static void w8001_close(struct input_dev *dev)
{ {
struct w8001 *w8001 = input_get_drvdata(dev); struct w8001 *w8001 = input_get_drvdata(dev);
mutex_lock(&w8001->mutex); guard(mutex)(&w8001->mutex);
if (--w8001->open_count == 0) if (--w8001->open_count == 0)
w8001_command(w8001, W8001_CMD_STOP, false); w8001_command(w8001, W8001_CMD_STOP, false);
mutex_unlock(&w8001->mutex);
} }
static int w8001_detect(struct w8001 *w8001) static int w8001_detect(struct w8001 *w8001)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment