diff mbox series

[v3,02/11] libflash/mbox-flash: Always close windows before opening a new window

Message ID 20171205010113.23263-3-cyril.bur@au1.ibm.com
State Accepted
Headers show
Series MBOX Protocol: Onwards to V3 | expand

Commit Message

Cyril Bur Dec. 5, 2017, 1:01 a.m. UTC
The MBOX protocol states that if an open window command fails then all
open windows are closed. Currently, if an open window command fails
mbox-flash will erroneously assume that the previously open window is
still open.

The solution to this is to mark all windows as closed before issuing an
open window command and then on success we'll mark the new window as
open.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 libflash/mbox-flash.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 950e24f0..c8a8dade 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -617,6 +617,9 @@  static int mbox_window_move(struct mbox_flash_data *mbox_flash,
 		goto out;
 	}
 
+	mbox_flash->read.open = false;
+	mbox_flash->write.open = false;
+
 	rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT);
 	if (rc) {
 		prlog(PR_ERR, "Error waiting for BMC\n");