From: Johan Hovold <johan@kernel.org>
Date: Wed, 14 Nov 2018 08:33:57 +0000 (+0100)
Subject: gnss: serial: fix synchronous write timeout
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=56a6c7268312cba9436b84cac01b3e502c5c511d;p=linux.git

gnss: serial: fix synchronous write timeout

Passing a timeout of zero to the synchronous serdev_device_write()
helper does currently not imply to wait forever (unlike passing zero to
serdev_device_wait_until_sent()). Instead, if there's insufficient
room in the write buffer, we'd end up with an incomplete write.

Fixes: 37768b054f20 ("gnss: add generic serial driver")
Cc: stable <stable@vger.kernel.org>     # 4.19
Signed-off-by: Johan Hovold <johan@kernel.org>
---

diff --git a/drivers/gnss/serial.c b/drivers/gnss/serial.c
index b01ba4438501a..31e891f00175c 100644
--- a/drivers/gnss/serial.c
+++ b/drivers/gnss/serial.c
@@ -13,6 +13,7 @@
 #include <linux/of.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/sched.h>
 #include <linux/serdev.h>
 #include <linux/slab.h>
 
@@ -63,7 +64,7 @@ static int gnss_serial_write_raw(struct gnss_device *gdev,
 	int ret;
 
 	/* write is only buffered synchronously */
-	ret = serdev_device_write(serdev, buf, count, 0);
+	ret = serdev_device_write(serdev, buf, count, MAX_SCHEDULE_TIMEOUT);
 	if (ret < 0)
 		return ret;