Skip to content

Commit 7606f4d

Browse files
committed
soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction()
The error handling has a kinda weird nested-if setup that is not really adding anything. Switch it to more of an early return arrangement as a predatory step for adding different handing for timeouts and failed services. Tested-by: Valentina Fernandez <valentina.fernandezalanis@microchip.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent 4f739af commit 7606f4d

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

drivers/soc/microchip/mpfs-sys-controller.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,27 @@ struct mpfs_sys_controller {
3232
int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg)
3333
{
3434
unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);
35-
int ret, err;
35+
int ret;
3636

37-
err = mutex_lock_interruptible(&transaction_lock);
38-
if (err)
39-
return err;
37+
ret = mutex_lock_interruptible(&transaction_lock);
38+
if (ret)
39+
return ret;
4040

4141
reinit_completion(&sys_controller->c);
4242

4343
ret = mbox_send_message(sys_controller->chan, msg);
44-
if (ret >= 0) {
45-
if (wait_for_completion_timeout(&sys_controller->c, timeout)) {
46-
ret = 0;
47-
} else {
48-
ret = -ETIMEDOUT;
49-
dev_warn(sys_controller->client.dev,
50-
"MPFS sys controller transaction timeout\n");
51-
}
44+
if (ret < 0)
45+
goto out;
46+
47+
if (!wait_for_completion_timeout(&sys_controller->c, timeout)) {
48+
ret = -ETIMEDOUT;
49+
dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n");
5250
} else {
53-
dev_err(sys_controller->client.dev,
54-
"mpfs sys controller transaction returned %d\n", ret);
51+
/* mbox_send_message() returns positive integers on success */
52+
ret = 0;
5553
}
5654

55+
out:
5756
mutex_unlock(&transaction_lock);
5857

5958
return ret;

0 commit comments

Comments
 (0)