[PATCH v2 2/2] staging: speakup: refactor to use existing code in vt

Okash Khawaja okash.khawaja at gmail.com
Thu Apr 4 03:11:16 EDT 2019


(Sorry just ignore that. Our existing approach is better)

On Thu, 4 Apr 2019, 10:00 Okash Khawaja, <okash.khawaja at gmail.com> wrote:

> On Thu, 4 Apr 2019 00:21:34 +0200
> Samuel Thibault <samuel.thibault at ens-lyon.org> wrote:
>
> > But can't just just get the kref in set_selection before using
> > cmpxchg? and if that fails, put it back. If it succeeded, the work
> > schedule will happen, and either it will manage to take the tty and
> > put its kref, or be canceled, and the kref will be put as well.
>
> Thinking about it, we can also make use of return value of
> cancel_work_sync(). It returns true if work was pending. So, if no work
> was pending then we don't need to do anything as the kref would be
> balanced and the tty would be set to NULL by the time
> cancel_work_sync() returns. This would make speakup_cancel_selection()
> simpler:
>
> void speakup_cancel_selection(void)
> {
>         struct tty_struct *tty;
>         bool was_pending;
>
>         was_pending = cancel_work_sync(&speakup_sel_work.work);
>         if (!was_pending)
>                 return;
>
>         tty_kref_put(speakup_sel_work.tty);
>         speakup_sel_work.tty = NULL;
> }
>
> We will still need to get kref before cmpxchg() as you suggested above.
>
> Let me know what you think.
>
> Thanks,
> Okash
>


More information about the Speakup mailing list