Commit aa27a094 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: add tty_port_tty_hangup helper

It allows for cleaning up on a considerable amount of places. They did
port_get, hangup, kref_put. Now the only thing needed is to call
tty_port_tty_hangup which does exactly that. And they can also decide
whether to consider CLOCAL or completely ignore that.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e4408ce3
...@@ -568,11 +568,7 @@ void chan_interrupt(struct line *line, int irq) ...@@ -568,11 +568,7 @@ void chan_interrupt(struct line *line, int irq)
reactivate_fd(chan->fd, irq); reactivate_fd(chan->fd, irq);
if (err == -EIO) { if (err == -EIO) {
if (chan->primary) { if (chan->primary) {
struct tty_struct *tty = tty_port_tty_get(&line->port); tty_port_tty_hangup(&line->port, false);
if (tty != NULL) {
tty_hangup(tty);
tty_kref_put(tty);
}
if (line->chan_out != chan) if (line->chan_out != chan)
close_one_chan(line->chan_out, 1); close_one_chan(line->chan_out, 1);
} }
......
...@@ -134,7 +134,6 @@ static void sdio_uart_port_put(struct sdio_uart_port *port) ...@@ -134,7 +134,6 @@ static void sdio_uart_port_put(struct sdio_uart_port *port)
static void sdio_uart_port_remove(struct sdio_uart_port *port) static void sdio_uart_port_remove(struct sdio_uart_port *port)
{ {
struct sdio_func *func; struct sdio_func *func;
struct tty_struct *tty;
BUG_ON(sdio_uart_table[port->index] != port); BUG_ON(sdio_uart_table[port->index] != port);
...@@ -155,12 +154,8 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port) ...@@ -155,12 +154,8 @@ static void sdio_uart_port_remove(struct sdio_uart_port *port)
sdio_claim_host(func); sdio_claim_host(func);
port->func = NULL; port->func = NULL;
mutex_unlock(&port->func_lock); mutex_unlock(&port->func_lock);
tty = tty_port_tty_get(&port->port);
/* tty_hangup is async so is this safe as is ?? */ /* tty_hangup is async so is this safe as is ?? */
if (tty) { tty_port_tty_hangup(&port->port, false);
tty_hangup(tty);
tty_kref_put(tty);
}
mutex_unlock(&port->port.mutex); mutex_unlock(&port->port.mutex);
sdio_release_irq(func); sdio_release_irq(func);
sdio_disable_func(func); sdio_disable_func(func);
...@@ -492,11 +487,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port) ...@@ -492,11 +487,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
wake_up_interruptible(&port->port.open_wait); wake_up_interruptible(&port->port.open_wait);
else { else {
/* DCD drop - hang up if tty attached */ /* DCD drop - hang up if tty attached */
tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, false);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
} }
} }
if (status & UART_MSR_DCTS) { if (status & UART_MSR_DCTS) {
......
...@@ -3124,18 +3124,13 @@ static void hso_serial_ref_free(struct kref *ref) ...@@ -3124,18 +3124,13 @@ static void hso_serial_ref_free(struct kref *ref)
static void hso_free_interface(struct usb_interface *interface) static void hso_free_interface(struct usb_interface *interface)
{ {
struct hso_serial *hso_dev; struct hso_serial *hso_dev;
struct tty_struct *tty;
int i; int i;
for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
if (serial_table[i] && if (serial_table[i] &&
(serial_table[i]->interface == interface)) { (serial_table[i]->interface == interface)) {
hso_dev = dev2ser(serial_table[i]); hso_dev = dev2ser(serial_table[i]);
tty = tty_port_tty_get(&hso_dev->port); tty_port_tty_hangup(&hso_dev->port, false);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
mutex_lock(&hso_dev->parent->mutex); mutex_lock(&hso_dev->parent->mutex);
hso_dev->parent->usb_gone = 1; hso_dev->parent->usb_gone = 1;
mutex_unlock(&hso_dev->parent->mutex); mutex_unlock(&hso_dev->parent->mutex);
......
...@@ -1124,14 +1124,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) ...@@ -1124,14 +1124,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
readl(&info->u.cyz.ch_ctrl->rs_status); readl(&info->u.cyz.ch_ctrl->rs_status);
if (dcd & C_RS_DCD) if (dcd & C_RS_DCD)
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&info->port.open_wait);
else { else
struct tty_struct *tty; tty_port_tty_hangup(&info->port, false);
tty = tty_port_tty_get(&info->port);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
}
} }
break; break;
case C_CM_MCTS: case C_CM_MCTS:
......
...@@ -913,16 +913,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd) ...@@ -913,16 +913,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)
/* pci hot-un-plug support */ /* pci hot-un-plug support */
for (a = 0; a < brd->numPorts; a++) for (a = 0; a < brd->numPorts; a++)
if (brd->ports[a].port.flags & ASYNC_INITIALIZED) { if (brd->ports[a].port.flags & ASYNC_INITIALIZED)
struct tty_struct *tty = tty_port_tty_get( tty_port_tty_hangup(&brd->ports[a].port, false);
&brd->ports[a].port);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
}
for (a = 0; a < MAX_PORTS_PER_BOARD; a++) for (a = 0; a < MAX_PORTS_PER_BOARD; a++)
tty_port_destroy(&brd->ports[a].port); tty_port_destroy(&brd->ports[a].port);
while (1) { while (1) {
opened = 0; opened = 0;
for (a = 0; a < brd->numPorts; a++) for (a = 0; a < brd->numPorts; a++)
...@@ -1365,7 +1361,6 @@ static void moxa_hangup(struct tty_struct *tty) ...@@ -1365,7 +1361,6 @@ static void moxa_hangup(struct tty_struct *tty)
static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
{ {
struct tty_struct *tty;
unsigned long flags; unsigned long flags;
dcd = !!dcd; dcd = !!dcd;
...@@ -1373,10 +1368,8 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) ...@@ -1373,10 +1368,8 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
if (dcd != p->DCDState) { if (dcd != p->DCDState) {
p->DCDState = dcd; p->DCDState = dcd;
spin_unlock_irqrestore(&p->port.lock, flags); spin_unlock_irqrestore(&p->port.lock, flags);
tty = tty_port_tty_get(&p->port); if (!dcd)
if (tty && !C_CLOCAL(tty) && !dcd) tty_port_tty_hangup(&p->port, true);
tty_hangup(tty);
tty_kref_put(tty);
} }
else else
spin_unlock_irqrestore(&p->port.lock, flags); spin_unlock_irqrestore(&p->port.lock, flags);
......
...@@ -1418,11 +1418,7 @@ static void gsm_dlci_close(struct gsm_dlci *dlci) ...@@ -1418,11 +1418,7 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
pr_debug("DLCI %d goes closed.\n", dlci->addr); pr_debug("DLCI %d goes closed.\n", dlci->addr);
dlci->state = DLCI_CLOSED; dlci->state = DLCI_CLOSED;
if (dlci->addr != 0) { if (dlci->addr != 0) {
struct tty_struct *tty = tty_port_tty_get(&dlci->port); tty_port_tty_hangup(&dlci->port, false);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
kfifo_reset(dlci->fifo); kfifo_reset(dlci->fifo);
} else } else
dlci->gsm->dead = 1; dlci->gsm->dead = 1;
......
...@@ -1501,12 +1501,9 @@ static void tty_exit(struct nozomi *dc) ...@@ -1501,12 +1501,9 @@ static void tty_exit(struct nozomi *dc)
DBG1(" "); DBG1(" ");
for (i = 0; i < MAX_PORT; ++i) { for (i = 0; i < MAX_PORT; ++i)
struct tty_struct *tty = tty_port_tty_get(&dc->port[i].port); tty_port_tty_hangup(&dc->port[i].port, false);
if (tty && list_empty(&tty->hangup_work.entry))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Racy below - surely should wait for scheduled work to be done or /* Racy below - surely should wait for scheduled work to be done or
complete off a hangup method ? */ complete off a hangup method ? */
while (dc->open_ttys) while (dc->open_ttys)
......
...@@ -521,15 +521,10 @@ static void rp_handle_port(struct r_port *info) ...@@ -521,15 +521,10 @@ static void rp_handle_port(struct r_port *info)
(ChanStatus & CD_ACT) ? "on" : "off"); (ChanStatus & CD_ACT) ? "on" : "off");
#endif #endif
if (!(ChanStatus & CD_ACT) && info->cd_status) { if (!(ChanStatus & CD_ACT) && info->cd_status) {
struct tty_struct *tty;
#ifdef ROCKET_DEBUG_HANGUP #ifdef ROCKET_DEBUG_HANGUP
printk(KERN_INFO "CD drop, calling hangup.\n"); printk(KERN_INFO "CD drop, calling hangup.\n");
#endif #endif
tty = tty_port_tty_get(&info->port); tty_port_tty_hangup(&info->port, false);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
} }
info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0;
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&info->port.open_wait);
......
...@@ -269,23 +269,6 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev) ...@@ -269,23 +269,6 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)
mrdy_set_high(ifx_dev); mrdy_set_high(ifx_dev);
} }
/**
* ifx_spi_hangup - hang up an IFX device
* @ifx_dev: our SPI device
*
* Hang up the tty attached to the IFX device if one is currently
* open. If not take no action
*/
static void ifx_spi_ttyhangup(struct ifx_spi_device *ifx_dev)
{
struct tty_port *pport = &ifx_dev->tty_port;
struct tty_struct *tty = tty_port_tty_get(pport);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
}
/** /**
* ifx_spi_timeout - SPI timeout * ifx_spi_timeout - SPI timeout
* @arg: our SPI device * @arg: our SPI device
...@@ -298,7 +281,7 @@ static void ifx_spi_timeout(unsigned long arg) ...@@ -298,7 +281,7 @@ static void ifx_spi_timeout(unsigned long arg)
struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg;
dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***");
ifx_spi_ttyhangup(ifx_dev); tty_port_tty_hangup(&ifx_dev->tty_port, false);
mrdy_set_low(ifx_dev); mrdy_set_low(ifx_dev);
clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
} }
...@@ -933,7 +916,7 @@ static irqreturn_t ifx_spi_reset_interrupt(int irq, void *dev) ...@@ -933,7 +916,7 @@ static irqreturn_t ifx_spi_reset_interrupt(int irq, void *dev)
set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state);
if (!solreset) { if (!solreset) {
/* unsolicited reset */ /* unsolicited reset */
ifx_spi_ttyhangup(ifx_dev); tty_port_tty_hangup(&ifx_dev->tty_port, false);
} }
} else { } else {
/* exited reset */ /* exited reset */
......
...@@ -232,6 +232,23 @@ void tty_port_hangup(struct tty_port *port) ...@@ -232,6 +232,23 @@ void tty_port_hangup(struct tty_port *port)
} }
EXPORT_SYMBOL(tty_port_hangup); EXPORT_SYMBOL(tty_port_hangup);
/**
* tty_port_tty_hangup - helper to hang up a tty
*
* @port: tty port
* @check_clocal: hang only ttys with CLOCAL unset?
*/
void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
{
struct tty_struct *tty = tty_port_tty_get(port);
if (tty && (!check_clocal || !C_CLOCAL(tty))) {
tty_hangup(tty);
tty_kref_put(tty);
}
}
EXPORT_SYMBOL_GPL(tty_port_tty_hangup);
/** /**
* tty_port_tty_wakeup - helper to wake up a tty * tty_port_tty_wakeup - helper to wake up a tty
* *
......
...@@ -292,7 +292,6 @@ static void acm_ctrl_irq(struct urb *urb) ...@@ -292,7 +292,6 @@ static void acm_ctrl_irq(struct urb *urb)
{ {
struct acm *acm = urb->context; struct acm *acm = urb->context;
struct usb_cdc_notification *dr = urb->transfer_buffer; struct usb_cdc_notification *dr = urb->transfer_buffer;
struct tty_struct *tty;
unsigned char *data; unsigned char *data;
int newctrl; int newctrl;
int retval; int retval;
...@@ -327,17 +326,12 @@ static void acm_ctrl_irq(struct urb *urb) ...@@ -327,17 +326,12 @@ static void acm_ctrl_irq(struct urb *urb)
break; break;
case USB_CDC_NOTIFY_SERIAL_STATE: case USB_CDC_NOTIFY_SERIAL_STATE:
tty = tty_port_tty_get(&acm->port);
newctrl = get_unaligned_le16(data); newctrl = get_unaligned_le16(data);
if (tty) { if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
if (!acm->clocal && dev_dbg(&acm->control->dev, "%s - calling hangup\n",
(acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { __func__);
dev_dbg(&acm->control->dev, tty_port_tty_hangup(&acm->port, false);
"%s - calling hangup\n", __func__);
tty_hangup(tty);
}
tty_kref_put(tty);
} }
acm->ctrlin = newctrl; acm->ctrlin = newctrl;
...@@ -1498,15 +1492,9 @@ static int acm_resume(struct usb_interface *intf) ...@@ -1498,15 +1492,9 @@ static int acm_resume(struct usb_interface *intf)
static int acm_reset_resume(struct usb_interface *intf) static int acm_reset_resume(struct usb_interface *intf)
{ {
struct acm *acm = usb_get_intfdata(intf); struct acm *acm = usb_get_intfdata(intf);
struct tty_struct *tty;
if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags))
tty = tty_port_tty_get(&acm->port); tty_port_tty_hangup(&acm->port, false);
if (tty) {
tty_hangup(tty);
tty_kref_put(tty);
}
}
return acm_resume(intf); return acm_resume(intf);
} }
......
...@@ -378,7 +378,6 @@ static void usa26_instat_callback(struct urb *urb) ...@@ -378,7 +378,6 @@ static void usa26_instat_callback(struct urb *urb)
struct usb_serial *serial; struct usb_serial *serial;
struct usb_serial_port *port; struct usb_serial_port *port;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
struct tty_struct *tty;
int old_dcd_state, err; int old_dcd_state, err;
int status = urb->status; int status = urb->status;
...@@ -421,12 +420,8 @@ static void usa26_instat_callback(struct urb *urb) ...@@ -421,12 +420,8 @@ static void usa26_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0);
if (old_dcd_state != p_priv->dcd_state) { if (old_dcd_state != p_priv->dcd_state)
tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, true);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
...@@ -510,7 +505,6 @@ static void usa28_instat_callback(struct urb *urb) ...@@ -510,7 +505,6 @@ static void usa28_instat_callback(struct urb *urb)
struct usb_serial *serial; struct usb_serial *serial;
struct usb_serial_port *port; struct usb_serial_port *port;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
struct tty_struct *tty;
int old_dcd_state; int old_dcd_state;
int status = urb->status; int status = urb->status;
...@@ -551,12 +545,8 @@ static void usa28_instat_callback(struct urb *urb) ...@@ -551,12 +545,8 @@ static void usa28_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0);
if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, true);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
...@@ -642,12 +632,8 @@ static void usa49_instat_callback(struct urb *urb) ...@@ -642,12 +632,8 @@ static void usa49_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0);
if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
struct tty_struct *tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, true);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
...@@ -851,7 +837,6 @@ static void usa90_instat_callback(struct urb *urb) ...@@ -851,7 +837,6 @@ static void usa90_instat_callback(struct urb *urb)
struct usb_serial *serial; struct usb_serial *serial;
struct usb_serial_port *port; struct usb_serial_port *port;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
struct tty_struct *tty;
int old_dcd_state, err; int old_dcd_state, err;
int status = urb->status; int status = urb->status;
...@@ -880,12 +865,8 @@ static void usa90_instat_callback(struct urb *urb) ...@@ -880,12 +865,8 @@ static void usa90_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0); p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0); p_priv->ri_state = ((msg->ri) ? 1 : 0);
if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, true);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
...@@ -953,12 +934,8 @@ static void usa67_instat_callback(struct urb *urb) ...@@ -953,12 +934,8 @@ static void usa67_instat_callback(struct urb *urb)
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
struct tty_struct *tty = tty_port_tty_get(&port->port); tty_port_tty_hangup(&port->port, true);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
/* Resubmit urb so we continue receiving */ /* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC); err = usb_submit_urb(urb, GFP_ATOMIC);
......
...@@ -1532,13 +1532,8 @@ static void option_instat_callback(struct urb *urb) ...@@ -1532,13 +1532,8 @@ static void option_instat_callback(struct urb *urb)
portdata->dsr_state = ((signals & 0x02) ? 1 : 0); portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
portdata->ri_state = ((signals & 0x08) ? 1 : 0); portdata->ri_state = ((signals & 0x08) ? 1 : 0);
if (old_dcd_state && !portdata->dcd_state) { if (old_dcd_state && !portdata->dcd_state)
struct tty_struct *tty = tty_port_tty_hangup(&port->port, true);
tty_port_tty_get(&port->port);
if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
} else { } else {
dev_dbg(dev, "%s: type %x req %x\n", __func__, dev_dbg(dev, "%s: type %x req %x\n", __func__,
req_pkt->bRequestType, req_pkt->bRequest); req_pkt->bRequestType, req_pkt->bRequest);
......
...@@ -628,7 +628,6 @@ static void sierra_instat_callback(struct urb *urb) ...@@ -628,7 +628,6 @@ static void sierra_instat_callback(struct urb *urb)
unsigned char signals = *((unsigned char *) unsigned char signals = *((unsigned char *)
urb->transfer_buffer + urb->transfer_buffer +
sizeof(struct usb_ctrlrequest)); sizeof(struct usb_ctrlrequest));
struct tty_struct *tty;
dev_dbg(&port->dev, "%s: signal x%x\n", __func__, dev_dbg(&port->dev, "%s: signal x%x\n", __func__,
signals); signals);
...@@ -639,11 +638,8 @@ static void sierra_instat_callback(struct urb *urb) ...@@ -639,11 +638,8 @@ static void sierra_instat_callback(struct urb *urb)
portdata->dsr_state = ((signals & 0x02) ? 1 : 0); portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
portdata->ri_state = ((signals & 0x08) ? 1 : 0); portdata->ri_state = ((signals & 0x08) ? 1 : 0);
tty = tty_port_tty_get(&port->port); if (old_dcd_state && !portdata->dcd_state)
if (tty && !C_CLOCAL(tty) && tty_port_tty_hangup(&port->port, true);
old_dcd_state && !portdata->dcd_state)
tty_hangup(tty);
tty_kref_put(tty);
} else { } else {
dev_dbg(&port->dev, "%s: type %x req %x\n", dev_dbg(&port->dev, "%s: type %x req %x\n",
__func__, req_pkt->bRequestType, __func__, req_pkt->bRequestType,
......
...@@ -534,6 +534,7 @@ extern int tty_port_carrier_raised(struct tty_port *port); ...@@ -534,6 +534,7 @@ extern int tty_port_carrier_raised(struct tty_port *port);
extern void tty_port_raise_dtr_rts(struct tty_port *port); extern void tty_port_raise_dtr_rts(struct tty_port *port);
extern void tty_port_lower_dtr_rts(struct tty_port *port); extern void tty_port_lower_dtr_rts(struct tty_port *port);
extern void tty_port_hangup(struct tty_port *port); extern void tty_port_hangup(struct tty_port *port);
extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal);
extern void tty_port_tty_wakeup(struct tty_port *port); extern void tty_port_tty_wakeup(struct tty_port *port);
extern int tty_port_block_til_ready(struct tty_port *port, extern int tty_port_block_til_ready(struct tty_port *port,
struct tty_struct *tty, struct file *filp); struct tty_struct *tty, struct file *filp);
......
...@@ -997,12 +997,8 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, ...@@ -997,12 +997,8 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
self->settings.dce = IRCOMM_DELTA_CD; self->settings.dce = IRCOMM_DELTA_CD;
ircomm_tty_check_modem_status(self); ircomm_tty_check_modem_status(self);
} else { } else {
struct tty_struct *tty = tty_port_tty_get(&self->port);
IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ );
if (tty) { tty_port_tty_hangup(&self->port, false);
tty_hangup(tty);
tty_kref_put(tty);
}
} }
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment