From: Okash Khawaja <okash.khawaja@gmail.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: speakup@linux-speakup.org
Subject: Re: [patch 6/7] staging: speakup: add TTY-based input functionality
Date: Mon, 10 Apr 2017 21:17:17 +0100 [thread overview]
Message-ID: <20170410201717.GB819@sanghar> (raw)
In-Reply-To: <20170409225337.ykcd5ekk6phy7ejw@var.youpi.perso.aquilenet.fr>
On Mon, Apr 10, 2017 at 12:53:37AM +0200, Samuel Thibault wrote:
> Hello,
>
> We need to add comments about the synchronization, added inline:
>
> Okash Khawaja, on lun. 03 avril 2017 21:21:29 +0100, wrote:
> > +static int spk_ttyio_receive_buf2(struct tty_struct *tty,
> > + const unsigned char *cp, char *fp, int count)
> > +{
> > + struct spk_ldisc_data *ldisc_data = (struct spk_ldisc_data *)tty->disc_data;
> > +
> > + if (spk_ttyio_synth->read_buff_add) {
> > + int i;
> > + for (i = 0; i < count; i++)
> > + spk_ttyio_synth->read_buff_add(cp[i]);
> > +
> > + return count;
> > + }
> > +
> > + if (ldisc_data->buf_free == 0)
> /* ttyio_in will tty_schedule_flip */
> > + return 0;
> > +
> /* Make sure the consumer has read buf before we have seen
> * buf_free == 1 and overwrite buf */
> > + mb();
> > +
> > + ldisc_data->buf = cp[0];
> > + ldisc_data->buf_free--;
>
> Don't decrement, set to 0. Decrementing would make the reader think
> that there is potential for multi-character support, but with such a
> lightweight synchronization there can't be. The fact that buf_free is 1
> allows the tty part to set it to 0, but not more.
How about changing the type to bool and switching between true and false
only?
next prev parent reply other threads:[~ UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[patch 0/7] staging: speakup: migrate synths to use TTY-based comms Okash Khawaja
` [patch 1/7] tty: export tty_open_by_driver Okash Khawaja
` Samuel Thibault
` [patch 2/7] staging: speakup: add tty-based comms functions Okash Khawaja
` Samuel Thibault
` [patch 3/7] staging: speakup: migrate acntsa, bns, dummy and txprt to ttyio Okash Khawaja
` Samuel Thibault
` [patch 4/7] staging: speakup: add send_xchar and tiocmset methods Okash Khawaja
` Samuel Thibault
` [patch 5/7] staging: speakup: make input functionality swappable Okash Khawaja
` Samuel Thibault
` [patch 6/7] staging: speakup: add TTY-based input functionality Okash Khawaja
` Samuel Thibault
` Okash Khawaja [this message]
` Samuel Thibault
` [patch 7/7] staging: speakup: migrate apollo, ltlk, audptr, decext, dectlk and spkout Okash Khawaja
` Samuel Thibault
` Okash Khawaja
` [patch 0/7] staging: speakup: migrate synths to use TTY-based comms Okash Khawaja
` Okash Khawaja
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=20170410201717.GB819@sanghar \
--to=okash.khawaja@gmail.com \
--cc=samuel.thibault@ens-lyon.org \
--cc=speakup@linux-speakup.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).