mirror of
https://github.com/CTCaer/switch-l4t-atf.git
synced 2025-03-03 16:08:31 +00:00
Tegra: bpmp_ipc: improve cyclomatic complexity
Code complexity is a good indication of maintainability versus testability of a piece of software. ISO26262 introduces the following thresholds: complexity < 10 is accepted 10 <= complexity < 20 has to be justified complexity >= 20 cannot be accepted Rationale is that number of test cases to fully test a piece of software can (depending on the coverage metrics) grow exponentially with the number of branches in the software. This patch removes redundant conditionals from 'ipc_send_req_atomic' handler to reduce the McCabe Cyclomatic Complexity for this function Change-Id: I20fef79a771301e1c824aea72a45ff83f97591d5 Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
This commit is contained in:
parent
6f47acdb3b
commit
21368290b4
@ -175,44 +175,39 @@ static int32_t tegra_bpmp_ipc_send_req_atomic(uint32_t mrq, void *p_out,
|
||||
if ((p_out == NULL) || (size_out > IVC_DATA_SZ_BYTES) ||
|
||||
(frame == NULL)) {
|
||||
ERROR("%s: invalid parameters, exiting\n", __func__);
|
||||
ret = -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* prepare the command frame */
|
||||
frame->mrq = mrq;
|
||||
frame->flags = FLAG_DO_ACK;
|
||||
p_fdata = frame->data;
|
||||
(void)memcpy(p_fdata, p_out, (size_t)size_out);
|
||||
|
||||
/* prepare the command frame */
|
||||
frame->mrq = mrq;
|
||||
frame->flags = FLAG_DO_ACK;
|
||||
p_fdata = frame->data;
|
||||
(void)memcpy(p_fdata, p_out, (size_t)size_out);
|
||||
/* signal the slave */
|
||||
tegra_bpmp_signal_slave();
|
||||
|
||||
/* signal the slave */
|
||||
tegra_bpmp_signal_slave();
|
||||
/* wait for slave to ack */
|
||||
ret = tegra_bpmp_wait_for_slave_ack();
|
||||
if (ret < 0) {
|
||||
ERROR("%s: wait for slave failed (%d)\n", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* wait for slave to ack */
|
||||
ret = tegra_bpmp_wait_for_slave_ack();
|
||||
if (ret != 0) {
|
||||
ERROR("failed waiting for the slave to ack\n");
|
||||
/* retrieve the response frame */
|
||||
if ((size_in <= IVC_DATA_SZ_BYTES) && (p_in != NULL)) {
|
||||
|
||||
f_in = tegra_bpmp_get_cur_in_frame();
|
||||
if (f_in != NULL) {
|
||||
ERROR("Failed to get next input frame!\n");
|
||||
} else {
|
||||
(void)memcpy(p_in, p_fdata, (size_t)size_in);
|
||||
}
|
||||
}
|
||||
|
||||
/* retrieve the response frame */
|
||||
if ((size_in <= IVC_DATA_SZ_BYTES) && (p_in != NULL) &&
|
||||
(ret == 0)) {
|
||||
|
||||
f_in = tegra_bpmp_get_cur_in_frame();
|
||||
if (f_in != NULL) {
|
||||
ERROR("Failed to get next input frame!\n");
|
||||
} else {
|
||||
(void)memcpy(p_in, p_fdata, (size_t)size_in);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ret = tegra_bpmp_free_master();
|
||||
if (ret != 0) {
|
||||
ERROR("Failed to free master\n");
|
||||
}
|
||||
}
|
||||
ret = tegra_bpmp_free_master();
|
||||
if (ret < 0) {
|
||||
ERROR("%s: free master failed (%d)\n", __func__, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user