* [PATCH] Input: wacom_w8001 - use "guard" notation when acquiring mutex
@ 2024-06-12 5:31 Dmitry Torokhov
2024-06-28 22:07 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Torokhov @ 2024-06-12 5:31 UTC (permalink / raw)
To: linux-input, Jason Gerecke; +Cc: linux-kernel
Switch the driver to use guard notation when acquiring mutex to
have it released automatically.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/wacom_w8001.c | 22 ++++++++++------------
1 file 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)
--
2.45.2.505.gda0bf45e8d-goog
--
Dmitry
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: wacom_w8001 - use "guard" notation when acquiring mutex
2024-06-12 5:31 [PATCH] Input: wacom_w8001 - use "guard" notation when acquiring mutex Dmitry Torokhov
@ 2024-06-28 22:07 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2024-06-28 22:07 UTC (permalink / raw)
To: linux-input, Jason Gerecke; +Cc: linux-kernel
On Tue, Jun 11, 2024 at 10:31:42PM -0700, Dmitry Torokhov wrote:
> Switch the driver to use guard notation when acquiring mutex to
> have it released automatically.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Applied since there are no objections.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-28 22:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 5:31 [PATCH] Input: wacom_w8001 - use "guard" notation when acquiring mutex Dmitry Torokhov
2024-06-28 22:07 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox