diff options
author | Conor Dooley <conor.dooley@microchip.com> | 2023-03-07 21:22:57 +0100 |
---|---|---|
committer | Conor Dooley <conor.dooley@microchip.com> | 2023-04-03 20:26:59 +0200 |
commit | 7606f4dfffa7a4e4aadd8aef918cc8ac1f1e2196 (patch) | |
tree | 962e82c75a5f188e846018d0eb8f803d114cdf0b /drivers/soc/microchip | |
parent | soc: microchip: mpfs: use a consistent completion timeout (diff) | |
download | linux-7606f4dfffa7a4e4aadd8aef918cc8ac1f1e2196.tar.xz linux-7606f4dfffa7a4e4aadd8aef918cc8ac1f1e2196.zip |
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>
Diffstat (limited to 'drivers/soc/microchip')
-rw-r--r-- | drivers/soc/microchip/mpfs-sys-controller.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 738ecd624d64..e61ba9b7aae3 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -32,28 +32,27 @@ struct mpfs_sys_controller { int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg) { unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); - int ret, err; + int ret; - err = mutex_lock_interruptible(&transaction_lock); - if (err) - return err; + ret = mutex_lock_interruptible(&transaction_lock); + if (ret) + return ret; reinit_completion(&sys_controller->c); ret = mbox_send_message(sys_controller->chan, msg); - if (ret >= 0) { - if (wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret = 0; - } else { - ret = -ETIMEDOUT; - dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); - } + if (ret < 0) + goto out; + + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + ret = -ETIMEDOUT; + dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n"); } else { - dev_err(sys_controller->client.dev, - "mpfs sys controller transaction returned %d\n", ret); + /* mbox_send_message() returns positive integers on success */ + ret = 0; } +out: mutex_unlock(&transaction_lock); return ret; |