lkml.org 
[lkml]   [2010]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Writing a console/tty driver -- how to use tty_port?
Alan Cox wrote:
> 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 see something weird in sdio_uart_install():

int ret = tty_init_termios(tty);

if (ret == 0) {
tty_driver_kref_get(driver);
tty->count++;
/* This is the ref sdio_uart_port get provided */
tty->driver_data = port;
driver->ttys[idx] = tty;


This function is called by tty_driver_install_tty(), which also does this:

if (tty_init_termios(tty) == 0) {
lock_kernel();
tty_driver_kref_get(driver);
tty->count++;
driver->ttys[idx] = tty;
unlock_kernel();
return 0;
}

Assuming that both calls to tty_init_termios(tty) return 0, these three lines
will be executed twice:

tty_driver_kref_get(driver);
tty->count++;
driver->ttys[idx] = tty;

Is that right?

--
Timur Tabi
Linux kernel developer at Freescale



\
 
 \ /
  Last update: 2010-10-28 22:37    [W:0.107 / U:0.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site