Input: pixcir_i2c_ts - use guard notation when acquiring mutex

Guard notation simplifies code.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
Dmitry Torokhov 2024-08-17 19:07:03 -07:00
parent 9f33f4fd39
commit 738de07ddf

View 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,