static void acm_tty_close(struct tty_struct *tty, struct file *filp) { struct acm *acm = tty->driver_data; /* Perform the closing process and see if we need to do the hardware shutdown */ if (!acm || tty_port_close_start(&acm->port, tty, filp) == 0) return; acm_port_down(acm, 0); tty_port_close_end(&acm->port, tty); mutex_lock(&open_mutex); tty_port_tty_set(&acm->port, NULL); if (!acm->dev) acm_tty_unregister(acm); mutex_unlock(&open_mutex); }
/* * ------------------------------------------------------------ * rs_close() * * This routine is called when the serial port gets closed. First, we * wait for the last remaining data to be sent. Then, we unlink its * async structure from the interrupt chain if necessary, and we free * that IRQ if nothing is left in the chain. * ------------------------------------------------------------ */ static void rs_close(struct tty_struct *tty, struct file * filp) { struct serial_state *state = tty->driver_data; struct tty_port *port = &state->tport; if (serial_paranoia_check(state, tty->name, "rs_close")) return; if (tty_port_close_start(port, tty, filp) == 0) return; /* * At this point we stop accepting input. To do this, we * disable the receive line status interrupts, and tell the * interrupt driver to stop checking the data ready bit in the * line status register. */ state->read_status_mask &= ~UART_LSR_DR; if (port->flags & ASYNC_INITIALIZED) { /* disable receive interrupts */ custom.intena = IF_RBF; mb(); /* clear any pending receive interrupt */ custom.intreq = IF_RBF; mb(); /* * Before we drop DTR, make sure the UART transmitter * has completely drained; this is especially * important if there is a transmit FIFO! */ rs_wait_until_sent(tty, state->timeout); } shutdown(tty, state); rs_flush_buffer(tty); tty_ldisc_flush(tty); port->tty = NULL; tty_port_close_end(port, tty); }