diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2024-08-18 03:26:09 +0300 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2026-03-25 07:14:26 +0300 |
| commit | 576c99f1a34da9618a5df8ed8648f2beee7e5411 (patch) | |
| tree | 37b3ec8fdd04be3e5a645c6f1c019165e9c1eb04 | |
| parent | cec3bcec6fd54cd1bdcb8786ca661912d879d399 (diff) | |
| download | linux-576c99f1a34da9618a5df8ed8648f2beee7e5411.tar.xz | |
Input: exc3000 - use guard notation when acquiring mutex
Guard notation simplifies code.
Note that callers of exc3000_vendor_data_request() always expect
response, so it was adjusted to always wait for it.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | drivers/input/touchscreen/exc3000.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c index 28da7ba55a4b..78c0911ba6e2 100644 --- a/drivers/input/touchscreen/exc3000.c +++ b/drivers/input/touchscreen/exc3000.c @@ -234,7 +234,7 @@ static int exc3000_vendor_data_request(struct exc3000_data *data, u8 *request, int ret; unsigned long time_left; - mutex_lock(&data->query_lock); + guard(mutex)(&data->query_lock); reinit_completion(&data->wait_event); @@ -243,29 +243,18 @@ static int exc3000_vendor_data_request(struct exc3000_data *data, u8 *request, ret = i2c_master_send(data->client, buf, EXC3000_LEN_VENDOR_REQUEST); if (ret < 0) - goto out_unlock; - - if (response) { - time_left = wait_for_completion_timeout(&data->wait_event, - timeout * HZ); - if (time_left == 0) { - ret = -ETIMEDOUT; - goto out_unlock; - } - - if (data->buf[3] >= EXC3000_LEN_FRAME) { - ret = -ENOSPC; - goto out_unlock; - } + return ret; - memcpy(response, &data->buf[4], data->buf[3]); - ret = data->buf[3]; - } + time_left = wait_for_completion_timeout(&data->wait_event, + timeout * HZ); + if (time_left == 0) + return -ETIMEDOUT; -out_unlock: - mutex_unlock(&data->query_lock); + if (data->buf[3] >= EXC3000_LEN_FRAME) + return -ENOSPC; - return ret; + memcpy(response, &data->buf[4], data->buf[3]); + return data->buf[3]; } static ssize_t fw_version_show(struct device *dev, |
