]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: pixcir_i2c_ts - use guard notation when acquiring mutex
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 18 Aug 2024 02:07:03 +0000 (19:07 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 25 Mar 2026 14:53:58 +0000 (07:53 -0700)
Guard notation simplifies code.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/pixcir_i2c_ts.c

index dad5786e82a46d0714369b97bb80043c349ffb32..c6b3615c877553fca11cc003f75449841266cb01 100644 (file)
@@ -410,26 +410,25 @@ static int pixcir_i2c_ts_suspend(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
        struct input_dev *input = ts->input;
-       int ret = 0;
+       int error;
 
-       mutex_lock(&input->mutex);
+       guard(mutex)(&input->mutex);
 
        if (device_may_wakeup(&client->dev)) {
                if (!input_device_enabled(input)) {
-                       ret = pixcir_start(ts);
-                       if (ret) {
+                       error = pixcir_start(ts);
+                       if (error) {
                                dev_err(dev, "Failed to start\n");
-                               goto unlock;
+                               return error;
                        }
                }
        } else if (input_device_enabled(input)) {
-               ret = pixcir_stop(ts);
+               error = pixcir_stop(ts);
+               if (error)
+                       return error;
        }
 
-unlock:
-       mutex_unlock(&input->mutex);
-
-       return ret;
+       return 0;
 }
 
 static int pixcir_i2c_ts_resume(struct device *dev)
@@ -437,26 +436,25 @@ static int pixcir_i2c_ts_resume(struct device *dev)
        struct i2c_client *client = to_i2c_client(dev);
        struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
        struct input_dev *input = ts->input;
-       int ret = 0;
+       int error;
 
-       mutex_lock(&input->mutex);
+       guard(mutex)(&input->mutex);
 
        if (device_may_wakeup(&client->dev)) {
                if (!input_device_enabled(input)) {
-                       ret = pixcir_stop(ts);
-                       if (ret) {
+                       error = pixcir_stop(ts);
+                       if (error) {
                                dev_err(dev, "Failed to stop\n");
-                               goto unlock;
+                               return error;
                        }
                }
        } else if (input_device_enabled(input)) {
-               ret = pixcir_start(ts);
+               error = pixcir_start(ts);
+               if (error)
+                       return error;
        }
 
-unlock:
-       mutex_unlock(&input->mutex);
-
-       return ret;
+       return 0;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,