summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2024-08-18 03:14:57 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2026-03-25 07:14:23 +0300
commita0a92414af42b79f4e2829adfd55478a8e74eb33 (patch)
tree122bb6fafe5ed12a453ee8731041cdc6b3c2d079
parent37115e7df5d0e75c661aa65f7ac9fa0991759c6d (diff)
downloadlinux-a0a92414af42b79f4e2829adfd55478a8e74eb33.tar.xz
Input: cyttsp - use guard notation when acquiring mutex
Guard notation simplifies code. Also fix the touchscreen not being marked as suspended when noone has opened/is using it. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/cyttsp_core.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 9e729910fbc8..012dfcae01cc 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -494,34 +494,30 @@ static int cyttsp_disable(struct cyttsp *ts)
static int cyttsp_suspend(struct device *dev)
{
struct cyttsp *ts = dev_get_drvdata(dev);
- int retval = 0;
+ int error;
- mutex_lock(&ts->input->mutex);
+ guard(mutex)(&ts->input->mutex);
if (input_device_enabled(ts->input)) {
- retval = cyttsp_disable(ts);
- if (retval == 0)
- ts->suspended = true;
+ error = cyttsp_disable(ts);
+ if (error)
+ return error;
}
- mutex_unlock(&ts->input->mutex);
-
- return retval;
+ ts->suspended = true;
+ return 0;
}
static int cyttsp_resume(struct device *dev)
{
struct cyttsp *ts = dev_get_drvdata(dev);
- mutex_lock(&ts->input->mutex);
+ guard(mutex)(&ts->input->mutex);
if (input_device_enabled(ts->input))
cyttsp_enable(ts);
ts->suspended = false;
-
- mutex_unlock(&ts->input->mutex);
-
return 0;
}