lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101027231948.5e62dd09@lxorguk.ukuu.org.uk>
Date:	Wed, 27 Oct 2010 23:19:48 +0100
From:	Alan Cox <alan@...rguk.ukuu.org.uk>
To:	Timur Tabi <timur@...escale.com>
Cc:	gregkh <gregkh@...e.de>, lkml <linux-kernel@...r.kernel.org>
Subject: Re: Writing a console/tty driver -- how to use tty_port?

On Wed, 27 Oct 2010 16:04:13 -0500
Timur Tabi <timur@...escale.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ