Re: Writing a console/tty driver -- how to use tty_port?

From: Timur Tabi
Date: Thu Oct 28 2010 - 16:34:52 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/