summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2024-08-18 03:20:30 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2026-03-25 07:14:26 +0300
commitcec3bcec6fd54cd1bdcb8786ca661912d879d399 (patch)
treee2340b60d1cc390ce5a65d5fcf34367789c06f46
parente5c79d9f65a1211c56a41ca27136c985842fb1b5 (diff)
downloadlinux-cec3bcec6fd54cd1bdcb8786ca661912d879d399.tar.xz
Input: elo - use guard notation when acquiring mutex
Guard notation simplifies code. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/elo.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 434b9b47e964..6814d5789b6f 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -219,40 +219,40 @@ static irqreturn_t elo_interrupt(struct serio *serio,
static int elo_command_10(struct elo *elo, unsigned char *packet)
{
- int rc = -1;
+ int error;
int i;
unsigned char csum = 0xaa + ELO10_LEAD_BYTE;
- mutex_lock(&elo->cmd_mutex);
+ guard(mutex)(&elo->cmd_mutex);
scoped_guard(serio_pause_rx, elo->serio) {
elo->expected_packet = toupper(packet[0]);
init_completion(&elo->cmd_done);
}
- if (serio_write(elo->serio, ELO10_LEAD_BYTE))
- goto out;
+ error = serio_write(elo->serio, ELO10_LEAD_BYTE);
+ if (error)
+ return error;
for (i = 0; i < ELO10_PACKET_LEN; i++) {
csum += packet[i];
- if (serio_write(elo->serio, packet[i]))
- goto out;
+ error = serio_write(elo->serio, packet[i]);
+ if (error)
+ return error;
}
- if (serio_write(elo->serio, csum))
- goto out;
+ error = serio_write(elo->serio, csum);
+ if (error)
+ return error;
wait_for_completion_timeout(&elo->cmd_done, HZ);
- if (elo->expected_packet == ELO10_TOUCH_PACKET) {
- /* We are back in reporting mode, the command was ACKed */
- memcpy(packet, elo->response, ELO10_PACKET_LEN);
- rc = 0;
- }
+ if (elo->expected_packet != ELO10_TOUCH_PACKET)
+ return -EIO;
- out:
- mutex_unlock(&elo->cmd_mutex);
- return rc;
+ /* We are back in reporting mode, the command was ACKed */
+ memcpy(packet, elo->response, ELO10_PACKET_LEN);
+ return 0;
}
static int elo_setup_10(struct elo *elo)