From: Grant Edwards <grant.b.edwards@gmail.com>
To: linux-serial@vger.kernel.org
Subject: close() handler of tty driver called for port that's not open?
Date: Wed, 14 Sep 2011 16:21:03 +0000 (UTC) [thread overview]
Message-ID: <j4qk9f$vro$1@dough.gmane.org> (raw)
Why does the tty layer call my tty driver's close() handler on a port
that's not open?
The scenario I've run into is that my open() handler is called for a
serial port that's not currently available, so I return -EBUSY. The
libc open() call returns an error:
[Errno 16] Device or resource busy: '/dev/ttySI0'
But then after the open has failed, my tty driver sees a call to
close() the device which failed to open.
Why does the tty layer try to close a device that isn't open?
Does the tty consider a device to be open even if the open() handler
returned an error?
The problem is that my driver keeps a usage count on the port so it
can clean up some internal stuff when the last user closes a port.
I only increment the usage count when an open is successful. That
doesn't work very well when the tty layer calls close() on a device
regardless of whether or not it was able to open it first.
Does the tty layer guarantee that the number of close() calls will
match the number of open() calls regardless of whether the open()
calls succeed or not?
If so, has that always been the policy, or is calling close() on
non-open device a new feature?
--
Grant Edwards grant.b.edwards Yow! I want to mail a
at bronzed artichoke to
gmail.com Nicaragua!
next reply other threads:[~2011-09-14 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-14 16:21 Grant Edwards [this message]
2011-09-14 19:33 ` close() handler of tty driver called for port that's not open? Alan Cox
2011-09-14 19:52 ` Grant Edwards
2011-09-14 20:05 ` Alan Cox
2011-09-14 20:13 ` Grant Edwards
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='j4qk9f$vro$1@dough.gmane.org' \
--to=grant.b.edwards@gmail.com \
--cc=linux-serial@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;
as well as URLs for NNTP newsgroup(s).