]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: cyttsp - use guard notation when acquiring mutex
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 18 Aug 2024 00:14:57 +0000 (17:14 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 25 Mar 2026 04:14:23 +0000 (21:14 -0700)
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>
drivers/input/touchscreen/cyttsp_core.c

index 9e729910fbc8d8b713a8ac3d8449544a16f0cffb..012dfcae01ccd4c36ca3f6364f5a212551f243bc 100644 (file)
@@ -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;
 }