Skip to content

Commit 79df764

Browse files
committed
Input: zinitix - use guard notation when acquiring mutex
Guard notation simplifies code. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 35ee829 commit 79df764

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/input/touchscreen/zinitix.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -703,30 +703,29 @@ static int zinitix_suspend(struct device *dev)
703703
struct i2c_client *client = to_i2c_client(dev);
704704
struct bt541_ts_data *bt541 = i2c_get_clientdata(client);
705705

706-
mutex_lock(&bt541->input_dev->mutex);
706+
guard(mutex)(&bt541->input_dev->mutex);
707707

708708
if (input_device_enabled(bt541->input_dev))
709709
zinitix_stop(bt541);
710710

711-
mutex_unlock(&bt541->input_dev->mutex);
712-
713711
return 0;
714712
}
715713

716714
static int zinitix_resume(struct device *dev)
717715
{
718716
struct i2c_client *client = to_i2c_client(dev);
719717
struct bt541_ts_data *bt541 = i2c_get_clientdata(client);
720-
int ret = 0;
721-
722-
mutex_lock(&bt541->input_dev->mutex);
718+
int error;
723719

724-
if (input_device_enabled(bt541->input_dev))
725-
ret = zinitix_start(bt541);
720+
guard(mutex)(&bt541->input_dev->mutex);
726721

727-
mutex_unlock(&bt541->input_dev->mutex);
722+
if (input_device_enabled(bt541->input_dev)) {
723+
error = zinitix_start(bt541);
724+
if (error)
725+
return error;
726+
}
728727

729-
return ret;
728+
return 0;
730729
}
731730

732731
static DEFINE_SIMPLE_DEV_PM_OPS(zinitix_pm_ops, zinitix_suspend, zinitix_resume);

0 commit comments

Comments
 (0)