static int block_til_ready(struct tty_struct *tty, struct file *filp,
struct isi_port *ip)
{
- struct isi_board *card = ip->card;
struct tty_port *port = &ip->port;
int do_clocal = 0, retval;
unsigned long flags;
retval = 0;
add_wait_queue(&port->open_wait, &wait);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count--;
port->blocked_open++;
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->lock, flags);
while (1) {
tty_port_raise_dtr_rts(port);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
if (!tty_hung_up_p(filp))
port->count++;
port->blocked_open--;
- spin_unlock_irqrestore(&card->card_lock, flags);
- if (retval)
- return retval;
- port->flags |= ASYNC_NORMAL_ACTIVE;
+ if (retval == 0)
+ port->flags |= ASYNC_NORMAL_ACTIVE;
+ spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
pr_dbg("Close start!!!.\n");
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
if (tty_hung_up_p(filp)) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
return;
}
}
if (port->port.count) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
return;
}
port->port.flags |= ASYNC_CLOSING;
tty->closing = 1;
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->port.closing_wait);
isicom_flush_buffer(tty);
tty_ldisc_flush(tty);
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
tty->closing = 0;
if (port->port.blocked_open) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
if (port->port.close_delay) {
pr_dbg("scheduling until time out.\n");
msleep_interruptible(
jiffies_to_msecs(port->port.close_delay));
}
- spin_lock_irqsave(&card->card_lock, flags);
+ spin_lock_irqsave(&port->port.lock, flags);
wake_up_interruptible(&port->port.open_wait);
}
port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
wake_up_interruptible(&port->port.close_wait);
- spin_unlock_irqrestore(&card->card_lock, flags);
+ spin_unlock_irqrestore(&port->port.lock, flags);
}
/* write et all */
isicom_shutdown_port(port);
spin_unlock_irqrestore(&port->card->card_lock, flags);
- port->port.count = 0;
- port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
- tty_port_tty_set(&port->port, NULL);
- wake_up_interruptible(&port->port.open_wait);
+ tty_port_hangup(&port->port);
}
return (info->serial_signals & SerialSignal_DCD) ? 1 : 0;
}
+static void raise_dtr_rts(struct tty_port *port)
+{
+ SLMP_INFO *info = container_of(port, SLMP_INFO, port);
+ unsigned long flags;
+
+ spin_lock_irqsave(&info->lock,flags);
+ info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
+ set_signals(info);
+ spin_unlock_irqrestore(&info->lock,flags);
+}
+
/* Block the current process until the specified port is ready to open.
*/
static int block_til_ready(struct tty_struct *tty, struct file *filp,
port->blocked_open++;
while (1) {
- if ((tty->termios->c_cflag & CBAUD)) {
- spin_lock_irqsave(&info->lock,flags);
- info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR;
- set_signals(info);
- spin_unlock_irqrestore(&info->lock,flags);
- }
+ if (tty->termios->c_cflag & CBAUD)
+ tty_port_raise_dtr_rts(port);
set_current_state(TASK_INTERRUPTIBLE);
static const struct tty_port_operations port_ops = {
.carrier_raised = carrier_raised,
+ .raise_dtr_rts = raise_dtr_rts,
};
/* Allocate and initialize a device instance structure
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
+#include <linux/serial.h>
#include <linux/timer.h>
#include <linux/string.h>
#include <linux/slab.h>
}
EXPORT_SYMBOL(tty_port_tty_set);
+/**
+ * tty_port_hangup - hangup helper
+ * @port: tty port
+ *
+ * Perform port level tty hangup flag and count changes. Drop the tty
+ * reference.
+ */
+
+void tty_port_hangup(struct tty_port *port)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+ port->count = 0;
+ port->flags &= ~ASYNC_NORMAL_ACTIVE;
+ if (port->tty)
+ tty_kref_put(port->tty);
+ port->tty = NULL;
+ spin_unlock_irqrestore(&port->lock, flags);
+ wake_up_interruptible(&port->open_wait);
+}
+EXPORT_SYMBOL(tty_port_hangup);
+
/**
* tty_port_carrier_raised - carrier raised check
* @port: tty port