return;
}
-static int zforce_suspend(struct device *dev)
+static int __zforce_suspend(struct zforce_ts *ts)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct zforce_ts *ts = i2c_get_clientdata(client);
+ struct i2c_client *client = ts->client;
struct input_dev *input = ts->input;
- int ret = 0;
-
- mutex_lock(&input->mutex);
+ int ret;
- WRITE_ONCE(ts->suspending, true);
- smp_mb();
+ guard(mutex)(&input->mutex);
/*
* When configured as a wakeup source device should always wake
if (!input_device_enabled(input)) {
ret = zforce_start(ts);
if (ret)
- goto unlock;
+ return ret;
}
enable_irq_wake(client->irq);
ret = zforce_stop(ts);
if (ret)
- goto unlock;
+ return ret;
disable_irq(client->irq);
}
ts->suspended = true;
+ return 0;
+}
-unlock:
+static int zforce_suspend(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct zforce_ts *ts = i2c_get_clientdata(client);
+ int ret;
+
+ WRITE_ONCE(ts->suspending, true);
smp_mb();
- WRITE_ONCE(ts->suspending, false);
- mutex_unlock(&input->mutex);
+ ret = __zforce_suspend(ts);
+
+ smp_mb();
+ WRITE_ONCE(ts->suspending, false);
return ret;
}
struct i2c_client *client = to_i2c_client(dev);
struct zforce_ts *ts = i2c_get_clientdata(client);
struct input_dev *input = ts->input;
- int ret = 0;
+ int ret;
- mutex_lock(&input->mutex);
+ guard(mutex)(&input->mutex);
ts->suspended = false;
if (!input_device_enabled(input)) {
ret = zforce_stop(ts);
if (ret)
- goto unlock;
+ return ret;
}
} else if (input_device_enabled(input)) {
dev_dbg(&client->dev, "resume without being a wakeup source\n");
ret = zforce_start(ts);
if (ret < 0)
- goto unlock;
+ return ret;
}
-unlock:
- mutex_unlock(&input->mutex);
-
- return ret;
+ return 0;
}
static DEFINE_SIMPLE_DEV_PM_OPS(zforce_pm_ops, zforce_suspend, zforce_resume);