public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: gregkh <gregkh@suse.de>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: Writing a console/tty driver -- how to use tty_port?
Date: Thu, 28 Oct 2010 15:34:30 -0500	[thread overview]
Message-ID: <4CC9DE56.8070707@freescale.com> (raw)
In-Reply-To: <20101027231948.5e62dd09@lxorguk.ukuu.org.uk>

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


  parent reply	other threads:[~2010-10-28 20:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 21:04 Writing a console/tty driver -- how to use tty_port? Timur Tabi
2010-10-27 22:19 ` Alan Cox
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 [this message]
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=4CC9DE56.8070707@freescale.com \
    --to=timur@freescale.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /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