mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
Input: mms114 - use guard notation when acquiring mutex
Guard notation simplifies code. Also stop trying to check if input device is opened/in use in the interrupt handler - the interrupt is disabled when device is closed or suspended. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
7e1e5722e8
commit
11a64d6bb7
|
|
@ -216,20 +216,12 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
|
|||
{
|
||||
struct mms114_data *data = dev_id;
|
||||
struct i2c_client *client = data->client;
|
||||
struct input_dev *input_dev = data->input_dev;
|
||||
struct mms114_touch touch[MMS114_MAX_TOUCH];
|
||||
int packet_size;
|
||||
int touch_size;
|
||||
int index;
|
||||
int error;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
if (!input_device_enabled(input_dev)) {
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
goto out;
|
||||
}
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
packet_size = mms114_read_reg(data, MMS114_PACKET_SIZE);
|
||||
if (packet_size <= 0)
|
||||
goto out;
|
||||
|
|
@ -646,10 +638,10 @@ static int mms114_suspend(struct device *dev)
|
|||
input_mt_report_pointer_emulation(input_dev, true);
|
||||
input_sync(input_dev);
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
guard(mutex)(&input_dev->mutex);
|
||||
|
||||
if (input_device_enabled(input_dev))
|
||||
mms114_stop(data);
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -661,15 +653,13 @@ static int mms114_resume(struct device *dev)
|
|||
struct input_dev *input_dev = data->input_dev;
|
||||
int error;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
guard(mutex)(&input_dev->mutex);
|
||||
|
||||
if (input_device_enabled(input_dev)) {
|
||||
error = mms114_start(data);
|
||||
if (error < 0) {
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user