diff mbox series

[1/5] staging: nvec: add ability to ignore EC responses in sync writes

Message ID 20240406123123.37148-2-marvin24@gmx.de
State New
Headers show
Series staging: nvec: improve robustnes during initialization | expand

Commit Message

Marc Dietrich April 6, 2024, 12:31 p.m. UTC
In case we just want to submit a message to the EC but are not
interested in its response, we can free the response buffer early.

Signed-off-by: Marc Dietrich <marvin24@gmx.de>
---
 drivers/staging/nvec/nvec.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 282a664c9176..45df190c2f94 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -300,7 +300,9 @@  int nvec_write_sync(struct nvec_chip *nvec,
 {
 	mutex_lock(&nvec->sync_write_mutex);

-	*msg = NULL;
+	if (msg != NULL)
+		*msg = NULL;
+
 	nvec->sync_write_pending = (data[1] << 8) + data[0];

 	if (nvec_write_async(nvec, data, size) < 0) {
@@ -320,7 +322,10 @@  int nvec_write_sync(struct nvec_chip *nvec,

 	dev_dbg(nvec->dev, "nvec_sync_write: pong!\n");

-	*msg = nvec->last_sync_msg;
+	if (msg != NULL)
+		*msg = nvec->last_sync_msg;
+	else
+		nvec_msg_free(nvec, nvec->last_sync_msg);

 	mutex_unlock(&nvec->sync_write_mutex);