Handle tty->ops->write() returning error
authornorly <ny-git@enpas.org>
Wed, 23 Jan 2019 15:37:39 +0000 (16:37 +0100)
committernorly <ny-git@enpas.org>
Wed, 23 Jan 2019 15:41:34 +0000 (16:41 +0100)
This was already the case in elmcan_ldisc_tx_worker(), but was missing
in elm327_send().

module/elmcan.c
readme.rst

index e4552024d3ae3015657133f74fc87e0fba5eefe7..cde48caaf330062c3859828594ebc522ed62e55f 100644 (file)
@@ -137,6 +137,8 @@ struct elmcan {
 static DEFINE_SPINLOCK(elmcan_discdata_lock);
 
 
+static inline void elm327_panic(struct elmcan *elm);
+
 
 
  /************************************************************************
@@ -161,6 +163,11 @@ static void elm327_send(struct elmcan *elm, const void *buf, size_t len)
         */
        set_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags);
        actual = elm->tty->ops->write(elm->tty, elm->txbuf, len);
+       if (actual < 0) {
+               pr_err("Failed to write to tty for %s.\n", elm->dev->name);
+               elm327_panic(elm);
+       }
+
        elm->txleft = len - actual;
        elm->txhead = elm->txbuf + actual;
 }
index 45c5c6cc627fed5328b4cab777ccb83388f11ad1..8a3592535347acd04f0134ed80569e1738d19aad 100644 (file)
@@ -260,8 +260,6 @@ incomplete) data frame::
 To Do list for future development
 ----------------------------------
 
-- Handle ``write()`` error
-
 - Rename ``elm327_panic()``
 
 - No auto-restart in ``elm327_panic()``?