All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: Gregory CLEMENT <gregory.clement@bootlin.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v2 3/3] tty: n_gsm: Fix waking up upper tty layer when room available
Date: Mon, 18 May 2020 08:44:17 +0200	[thread overview]
Message-ID: <4d3863a3-4c82-797f-6c20-b74e61a11724@suse.cz> (raw)
In-Reply-To: <20200512115323.1447922-4-gregory.clement@bootlin.com>

On 12. 05. 20, 13:53, Gregory CLEMENT wrote:
> Warn the upper layer when n_gms is ready to receive data
> again. Without this the associated virtual tty remains blocked
> indefinitely.
> 
> Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
> ---
>  drivers/tty/n_gsm.c | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index d8d196645500..69200bd411f7 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -663,7 +663,7 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
>   *	FIXME: lock against link layer control transmissions
>   */
>  
> -static void gsm_data_kick(struct gsm_mux *gsm)
> +static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
>  {
>  	struct gsm_msg *msg, *nmsg;
>  	int len;
> @@ -695,6 +695,24 @@ static void gsm_data_kick(struct gsm_mux *gsm)
>  
>  		list_del(&msg->list);
>  		kfree(msg);
> +
> +		if (dlci) {
> +			tty_port_tty_wakeup(&dlci->port);
> +		} else {
> +			int i = 0;
> +
> +			for (i = 0; i < NUM_DLCI; i++) {
> +				struct gsm_dlci *dlci;
> +
> +				dlci = gsm->dlci[i];
> +				if (dlci == NULL) {
> +					i++;

This "i++" looks bogus here.

> +					continue;
> +				}
> +
> +				tty_port_tty_wakeup(&dlci->port);


So simply:
for (i = 0; i < NUM_DLCI; i++) {
  struct gsm_dlci *dlci = gsm->dlci[i];
  if (dlci)
    tty_port_tty_wakeup(&dlci->port);
}

? Or even maybe directly:
for (i = 0; i < NUM_DLCI; i++)
  if (gsm->dlci[i])
    tty_port_tty_wakeup(&gsm->dlci[i]->port);

thanks,
-- 
js
suse labs

  reply	other threads:[~2020-05-18  6:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 11:53 [PATCH v2 0/3] TTY improve n_gsm support Gregory CLEMENT
2020-05-12 11:53 ` [PATCH v2 1/3] tty: n_gsm: Improve debug output Gregory CLEMENT
2020-05-18  6:40   ` Jiri Slaby
2020-05-18  7:33     ` Gregory CLEMENT
2020-05-18  7:38       ` Greg Kroah-Hartman
2020-05-18  7:44         ` Gregory CLEMENT
2020-05-18  7:48           ` Greg Kroah-Hartman
2020-05-18 17:50             ` [PATCH] tty: n_gsm: gsm_print_packet: use scnprintf to avoid pr_cont Joe Perches
2020-05-12 11:53 ` [PATCH v2 2/3] tty: n_gsm: Fix SOF skipping Gregory CLEMENT
2020-05-12 11:53 ` [PATCH v2 3/3] tty: n_gsm: Fix waking up upper tty layer when room available Gregory CLEMENT
2020-05-18  6:44   ` Jiri Slaby [this message]
2020-05-18  7:42     ` Gregory CLEMENT
2020-05-18  8:45 [PATCH 0/2] TTY fix-ups for "TTY improve n_gsm support" series Gregory CLEMENT
2020-05-18  8:45 ` [PATCH v2 3/3] tty: n_gsm: Fix waking up upper tty layer when room available Gregory CLEMENT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d3863a3-4c82-797f-6c20-b74e61a11724@suse.cz \
    --to=jslaby@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.