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>
This commit is contained in:
@@ -32,28 +32,27 @@ struct mpfs_sys_controller {
|
|||||||
int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg)
|
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);
|
unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);
|
||||||
int ret, err;
|
int ret;
|
||||||
|
|
||||||
err = mutex_lock_interruptible(&transaction_lock);
|
ret = mutex_lock_interruptible(&transaction_lock);
|
||||||
if (err)
|
if (ret)
|
||||||
return err;
|
return ret;
|
||||||
|
|
||||||
reinit_completion(&sys_controller->c);
|
reinit_completion(&sys_controller->c);
|
||||||
|
|
||||||
ret = mbox_send_message(sys_controller->chan, msg);
|
ret = mbox_send_message(sys_controller->chan, msg);
|
||||||
if (ret >= 0) {
|
if (ret < 0)
|
||||||
if (wait_for_completion_timeout(&sys_controller->c, timeout)) {
|
goto out;
|
||||||
ret = 0;
|
|
||||||
} else {
|
if (!wait_for_completion_timeout(&sys_controller->c, timeout)) {
|
||||||
ret = -ETIMEDOUT;
|
ret = -ETIMEDOUT;
|
||||||
dev_warn(sys_controller->client.dev,
|
dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n");
|
||||||
"MPFS sys controller transaction timeout\n");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dev_err(sys_controller->client.dev,
|
/* mbox_send_message() returns positive integers on success */
|
||||||
"mpfs sys controller transaction returned %d\n", ret);
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
mutex_unlock(&transaction_lock);
|
mutex_unlock(&transaction_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user