diff mbox series

[v3,01/17] firmware: turris-mox-rwtm: Do not complete if there are no waiters

Message ID 20240617144532.17385-2-kabel@kernel.org (mailing list archive)
State Superseded
Delegated to: Arnd Bergmann
Headers show
Series Updates for turris-mox-rwtm driver | expand

Commit Message

Marek Behún June 17, 2024, 2:45 p.m. UTC
Do not complete the command done completion if there are no waiters.
This can happen if a wait_for_completion timed out or was interrupted.

Fixes: 389711b37493 ("firmware: Add Turris Mox rWTM firmware driver")
Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/firmware/turris-mox-rwtm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko June 17, 2024, 7:42 p.m. UTC | #1
On Mon, Jun 17, 2024 at 4:45 PM Marek Behún <kabel@kernel.org> wrote:
>
> Do not complete the command done completion if there are no waiters.

"command done"

(perhaps in double quotes, since it's a kind of a name)

> This can happen if a wait_for_completion timed out or was interrupted.

wait_for_completion()

...

In case you need a new version, no need to resend because of the above
nit-picks.
diff mbox series

Patch

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 31d962cdd6eb..f1f9160c4195 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -2,7 +2,7 @@ 
 /*
  * Turris Mox rWTM firmware driver
  *
- * Copyright (C) 2019 Marek Behún <kabel@kernel.org>
+ * Copyright (C) 2019, 2024 Marek Behún <kabel@kernel.org>
  */
 
 #include <linux/armada-37xx-rwtm-mailbox.h>
@@ -174,6 +174,9 @@  static void mox_rwtm_rx_callback(struct mbox_client *cl, void *data)
 	struct mox_rwtm *rwtm = dev_get_drvdata(cl->dev);
 	struct armada_37xx_rwtm_rx_msg *msg = data;
 
+	if (completion_done(&rwtm->cmd_done))
+		return;
+
 	rwtm->reply = *msg;
 	complete(&rwtm->cmd_done);
 }