diff options
author | norly <ny-git@enpas.org> | 2022-05-03 09:58:52 +0200 |
---|---|---|
committer | norly <ny-git@enpas.org> | 2022-05-03 09:58:52 +0200 |
commit | 3413e1f059ebbaa28eb36418f1fdee2ca32038d1 (patch) | |
tree | 48f57a45aa838f6b4bbb3a971702a6f7b1310ea6 /module | |
parent | d6610fa34973f10945add245d43234040fdf5745 (diff) |
Restore WAKEUP set_bit vs. write() order in elm327_send()
Also, fix a silly spelling error.
Diffstat (limited to 'module')
-rw-r--r-- | module/elmcan.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/module/elmcan.c b/module/elmcan.c index 8a54240..e2d616f 100644 --- a/module/elmcan.c +++ b/module/elmcan.c @@ -148,6 +148,15 @@ static void elm327_send(struct elmcan *elm, const void *buf, size_t len) memcpy(elm->txbuf, buf, len); + /* Order of next two lines is *very* important. + * When we are sending a little amount of data, + * the transfer may be completed inside the ops->write() + * routine, because it's running with interrupts enabled. + * In this case we *never* got WRITE_WAKEUP event, + * if we did not request it before write operation. + * 14 Oct 1994 Dmitry Gorodchanin. + */ + set_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); written = elm->tty->ops->write(elm->tty, elm->txbuf, len); if (written < 0) { netdev_err(elm->dev, @@ -159,9 +168,6 @@ static void elm327_send(struct elmcan *elm, const void *buf, size_t len) elm->txleft = len - written; elm->txhead = elm->txbuf + written; - - if (elm->txleft) - set_bit(TTY_DO_WRITE_WAKEUP, &elm->tty->flags); } /* Take the ELM327 out of almost any state and back into command mode. @@ -573,7 +579,7 @@ static void elm327_handle_prompt(struct elmcan *elm) elm->state = ELM327_STATE_RECEIVING; /* We will be in the default state once this command is - * send, so enable the TX packet queue. + * sent, so enable the TX packet queue. */ netif_wake_queue(elm->dev); @@ -652,7 +658,7 @@ static void elm327_handle_prompt(struct elmcan *elm) elm->state = ELM327_STATE_RECEIVING; /* We will be in the default state once this command is - * send, so enable the TX packet queue. + * sent, so enable the TX packet queue. */ netif_wake_queue(elm->dev); } |