mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Timur Tabi <timur@freescale.com>
Cc: gregkh <gregkh@suse.de>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: Writing a console/tty driver -- how to use tty_port?
Date: Wed, 27 Oct 2010 23:19:48 +0100	[thread overview]
Message-ID: <20101027231948.5e62dd09@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <4CC893CD.7020701@freescale.com>

On Wed, 27 Oct 2010 16:04:13 -0500
Timur Tabi <timur@freescale.com> wrote:

> Greg,
> 
> Do you have an updated version of Tiny TTY that uses tty_port structures?  I'm
> trying to write a new TTY driver for a device that is not a UART, and I'm having
> a hard time finding a good example.  I suspect I need to understand the tty_port
> structure, but I can't find any documentation for it.
> 
> One specific problem I'm having is that I can't figure out how to get a
> tty_struct pointer in my interrupt handler.  The ISR gets called whenever there
> is new input, and it needs to call tty_insert_flip_string().  But it appears
> that it's possible to have my driver opened multiple times, each time creating a
> new TTY.  But since I can only have one interrupt handler, I don't know how to
> determine which of the tty_structs to use.  I figure tty_port is a way to
> resolve this problem, but I don't know how to use it exactly.

You only have one tty struct for the multiple opens.

Basically

		tty_port	-	lifetime of hardware being loaded
		tty_struct	-	lifetime open/close (and a bit
					beyond for refs)


So you can use tty_port_tty_get() which also knows about all the ghastly
internal locking rules.

Eventually the rx buffer should be moved to the tty_port which will make
the world vastly saner.

drivers/mmc/card/sdio_uart.c

is in some ways the best example, it handles all the horrible cases
including unloading of hardware v open races, its way more than you'd
need but does illustrate it all.

I've also got a draft tty_kfifo layer which is designed to be tty_port
with kfifo queues as a helper. Remind me next week if it would be useful
and I'll dig it back out.

Alan

  reply	other threads:[~2010-10-27 22:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 21:04 Timur Tabi
2010-10-27 22:19 ` Alan Cox [this message]
2010-10-28 19:35   ` Timur Tabi
2010-10-29 13:55     ` Timur Tabi
2010-10-29 14:14       ` Timur Tabi
2010-10-28 20:34   ` Timur Tabi
2010-10-28 20:47     ` Timur Tabi
2010-10-28 20:57 ` Arnd Bergmann
2010-10-28 21:08   ` Timur Tabi
2010-10-29 14:21     ` Arnd Bergmann
2010-10-28 22:11   ` Alan Cox
2010-10-29 23:55     ` Arnd Bergmann

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=20101027231948.5e62dd09@lxorguk.ukuu.org.uk \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=timur@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®