[PATCH 1/4] arm: socfpga: mailbox_s10: make retry logic more visible
Michael Tretter
m.tretter at pengutronix.de
Wed Mar 11 04:06:39 PDT 2026
The driver tries to open the QSPI a second time after closing the device
if the first open failed. The second try is open coded and repeats code
from the first try.
Refactor the code to have a single open and make the error handling more
obvious.
Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
arch/arm/mach-socfpga/mailbox_s10.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c
index 9211d643e3b6..f9ff6663dc38 100644
--- a/arch/arm/mach-socfpga/mailbox_s10.c
+++ b/arch/arm/mach-socfpga/mailbox_s10.c
@@ -301,20 +301,18 @@ int socfpga_mailbox_s10_qspi_open(void)
u32 resp_buf_len;
u32 reg;
u32 clk_khz;
+ int try = 0;
+retry:
ret = mbox_send_cmd(MBOX_ID_BAREBOX, MBOX_QSPI_OPEN, MBOX_CMD_DIRECT,
0, NULL, 0, 0, NULL);
- if (ret) {
- /* retry again by closing and reopen the QSPI again */
- ret = socfpga_mailbox_s10_qspi_close();
- if (ret)
- return ret;
-
- ret = mbox_send_cmd(MBOX_ID_BAREBOX, MBOX_QSPI_OPEN,
- MBOX_CMD_DIRECT, 0, NULL, 0, 0, NULL);
- if (ret)
- return ret;
+ if (ret != MBOX_RESP_STATOK && try++ < 2) {
+ /* retry after closing the QSPI */
+ socfpga_mailbox_s10_qspi_close();
+ goto retry;
}
+ if (ret)
+ return ret;
/* HPS will directly control the QSPI controller, no longer mailbox */
resp_buf_len = 1;
--
2.47.3
More information about the barebox
mailing list