Messages in this thread | | | Date | Thu, 28 Oct 2010 15:34:30 -0500 | From | Timur Tabi <> | Subject | Re: 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
| |