From: Jiri Slaby <jslaby@suse.cz>
To: gregkh@linuxfoundation.org
Cc: alan@linux.intel.com, linux-kernel@vger.kernel.org,
jirislaby@gmail.com, Samuel Ortiz <samuel@sortiz.org>,
netdev@vger.kernel.org
Subject: [PATCH 09/24] TTY: ircomm, define carrier routines
Date: Mon, 4 Jun 2012 13:35:23 +0200 [thread overview]
Message-ID: <1338809738-18967-10-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1338809738-18967-1-git-send-email-jslaby@suse.cz>
These will be used by the tty_port wait_til_ready later. (Now they are
used by our code.)
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: netdev@vger.kernel.org
---
net/irda/ircomm/ircomm_tty.c | 43 ++++++++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 199d9cb..3fdce18 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -104,6 +104,35 @@ static const struct tty_operations ops = {
#endif /* CONFIG_PROC_FS */
};
+static void ircomm_port_raise_dtr_rts(struct tty_port *port, int raise)
+{
+ struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
+ port);
+ /*
+ * Here, we use to lock those two guys, but as ircomm_param_request()
+ * does it itself, I don't see the point (and I see the deadlock).
+ * Jean II
+ */
+ if (raise)
+ self->settings.dte |= IRCOMM_RTS | IRCOMM_DTR;
+ else
+ self->settings.dte &= ~(IRCOMM_RTS | IRCOMM_DTR);
+
+ ircomm_param_request(self, IRCOMM_DTE, TRUE);
+}
+
+static int ircomm_port_carrier_raised(struct tty_port *port)
+{
+ struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb,
+ port);
+ return self->settings.dce & IRCOMM_CD;
+}
+
+static const struct tty_port_operations ircomm_port_ops = {
+ .dtr_rts = ircomm_port_raise_dtr_rts,
+ .carrier_raised = ircomm_port_carrier_raised,
+};
+
/*
* Function ircomm_tty_init()
*
@@ -290,15 +319,8 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
port->blocked_open++;
while (1) {
- if (tty->termios->c_cflag & CBAUD) {
- /* Here, we use to lock those two guys, but
- * as ircomm_param_request() does it itself,
- * I don't see the point (and I see the deadlock).
- * Jean II */
- self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR;
-
- ircomm_param_request(self, IRCOMM_DTE, TRUE);
- }
+ if (tty->termios->c_cflag & CBAUD)
+ tty_port_raise_dtr_rts(port);
current->state = TASK_INTERRUPTIBLE;
@@ -315,7 +337,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
* ready
*/
if (!test_bit(ASYNCB_CLOSING, &port->flags) &&
- (do_clocal || (self->settings.dce & IRCOMM_CD)) &&
+ (do_clocal || tty_port_carrier_raised(port)) &&
self->state == IRCOMM_TTY_READY)
{
break;
@@ -379,6 +401,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
}
tty_port_init(&self->port);
+ self->port.ops = &ircomm_port_ops;
self->magic = IRCOMM_TTY_MAGIC;
self->flow = FLOW_STOP;
--
1.7.10.3
next prev parent reply other threads:[~2012-06-04 11:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1338809738-18967-1-git-send-email-jslaby@suse.cz>
2012-06-04 11:35 ` [PATCH 02/24] TTY: ircomm, add tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 03/24] TTY: ircomm, use close times from tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 04/24] TTY: ircomm, use open counts " Jiri Slaby
2012-06-04 16:36 ` Alan Cox
2012-06-04 11:35 ` [PATCH 05/24] TTY: ircomm, use flags " Jiri Slaby
2012-06-04 11:35 ` [PATCH 06/24] TTY: ircomm, revamp locking Jiri Slaby
2012-06-04 16:57 ` Alan Cox
2012-06-04 11:35 ` [PATCH 07/24] TTY: ircomm, use tty from tty_port Jiri Slaby
2012-06-04 11:35 ` [PATCH 08/24] TTY: ircomm, define local tty_port Jiri Slaby
2012-06-04 11:35 ` Jiri Slaby [this message]
2012-06-04 11:35 ` [PATCH 10/24] TTY: ircomm, use tty_port_close_end helper Jiri Slaby
2012-06-04 11:35 ` [PATCH 11/24] TTY: ircomm, use tty_port_close_start helper Jiri Slaby
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=1338809738-18967-10-git-send-email-jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=samuel@sortiz.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).