static int a2232_open(struct tty_struct * tty, struct file * filp) { /* More or less stolen from other drivers. */ int line; int retval; struct a2232_port *port; line = tty->index; port = &a2232_ports[line]; tty->driver_data = port; port->gs.port.tty = tty; port->gs.port.count++; retval = gs_init_port(&port->gs); if (retval) { port->gs.port.count--; return retval; } port->gs.port.flags |= GS_ACTIVE; retval = gs_block_til_ready(port, filp); if (retval) { port->gs.port.count--; return retval; } a2232_enable_rx_interrupts(port); return 0; }
/* * Open the serial port */ static int rs_open(struct tty_struct * tty, struct file * filp) { int retval; func_enter(); if(!rs_initialized) { return -EIO; } if(MINOR(tty->device) - tty->driver.minor_start) { return -ENODEV; } rs_dprintk(TX3912_UART_DEBUG_OPEN, "Serial opening...\n"); tty->driver_data = rs_port; rs_port->gs.tty = tty; rs_port->gs.count++; /* * Start up serial port */ retval = gs_init_port(&rs_port->gs); rs_dprintk(TX3912_UART_DEBUG_OPEN, "Finished gs_init...\n"); if(retval) { rs_port->gs.count--; return retval; } rs_port->gs.flags |= GS_ACTIVE; if(rs_port->gs.count == 1) { MOD_INC_USE_COUNT; } rs_enable_rx_interrupts(rs_port); rs_enable_tx_interrupts(rs_port); retval = gs_block_til_ready(&rs_port->gs, filp); if(retval) { MOD_DEC_USE_COUNT; rs_port->gs.count--; return retval; } if((rs_port->gs.count == 1) && (rs_port->gs.flags & ASYNC_SPLIT_TERMIOS)) { if (tty->driver.subtype == SERIAL_TYPE_NORMAL) *tty->termios = rs_port->gs.normal_termios; else *tty->termios = rs_port->gs.callout_termios; rs_set_real_termios(rs_port); } rs_port->gs.session = current->session; rs_port->gs.pgrp = current->pgrp; func_exit(); return 0; }
static int a2232_open(struct tty_struct * tty, struct file * filp) { /* More or less stolen from other drivers. */ int line; int retval; struct a2232_port *port; line = MINOR(tty->device); port = &a2232_ports[line]; tty->driver_data = port; port->gs.tty = tty; port->gs.count++; retval = gs_init_port(&port->gs); if (retval) { port->gs.count--; return retval; } port->gs.flags |= GS_ACTIVE; if (port->gs.count == 1) { MOD_INC_USE_COUNT; } retval = gs_block_til_ready(port, filp); if (retval) { MOD_DEC_USE_COUNT; port->gs.count--; return retval; } if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)){ if (tty->driver.subtype == A2232_TTY_SUBTYPE_NORMAL) *tty->termios = port->gs.normal_termios; else *tty->termios = port->gs.callout_termios; a2232_set_real_termios (port); } port->gs.session = current->session; port->gs.pgrp = current->pgrp; a2232_enable_rx_interrupts(port); return 0; }
int riotopen(struct tty_struct *tty, struct file *filp) { unsigned int SysPort; int repeat_this = 250; struct Port *PortP; /* pointer to the port structure */ unsigned long flags; int retval = 0; func_enter(); /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close is going to oops. */ tty->driver_data = NULL; SysPort = rio_minor(tty); if (p->RIOFailed) { rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); func_exit(); return -ENXIO; } rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped); /* ** Validate that we have received a legitimate request. ** Currently, just check that we are opening a port on ** a host card that actually exists, and that the port ** has been mapped onto a host. */ if (SysPort >= RIO_PORTS) { /* out of range ? */ rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); func_exit(); return -ENXIO; } /* ** Grab pointer to the port stucture */ PortP = p->RIOPortp[SysPort]; /* Get control struc */ rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP); if (!PortP->Mapped) { /* we aren't mapped yet! */ /* ** The system doesn't know which RTA this port ** corresponds to. */ rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); func_exit(); return -ENXIO; } tty->driver_data = PortP; PortP->gs.tty = tty; PortP->gs.count++; rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt); retval = gs_init_port(&PortP->gs); if (retval) { PortP->gs.count--; return -ENXIO; } /* ** If the host hasn't been booted yet, then ** fail */ if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); func_exit(); return -ENXIO; } /* ** If the RTA has not booted yet and the user has choosen to block ** until the RTA is present then we must spin here waiting for ** the RTA to boot. */ /* I find the above code a bit hairy. I find the below code easier to read and shorter. Now, if it works too that would be great... -- REW */ rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { if (!PortP->WaitUntilBooted) { rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n"); func_exit(); return -ENXIO; } /* Under Linux you'd normally use a wait instead of this busy-waiting. I'll stick with the old implementation for now. --REW */ if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); func_exit(); return -EINTR; } if (repeat_this-- <= 0) { rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); func_exit(); return -EIO; } } rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n"); rio_spin_lock_irqsave(&PortP->portSem, flags); if (p->RIOHalted) { goto bombout; } /* ** If the port is in the final throws of being closed, ** we should wait here (politely), waiting ** for it to finish, so that it doesn't close us! */ while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) { rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); if (repeat_this-- <= 0) { rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); RIOPreemptiveCmd(p, PortP, FCLOSE); retval = -EINTR; goto bombout; } rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { rio_spin_lock_irqsave(&PortP->portSem, flags); retval = -EINTR; goto bombout; } rio_spin_lock_irqsave(&PortP->portSem, flags); } if (!PortP->Mapped) { rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); retval = -ENXIO; func_exit(); return retval; } if (p->RIOHalted) { goto bombout; } /* ** 15.10.1998 ARG - ESIL 0761 part fix ** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure, ** we need to make sure that the flags are clear when the port is opened. */ /* Uh? Suppose I turn these on and then another process opens the port again? The flags get cleared! Not good. -- REW */ if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) { PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); } if (!(PortP->firstOpen)) { /* First time ? */ rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n"); PortP->firstOpen++; PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ PortP->InUse = NOT_INUSE; /* Tentative fix for bug PR27. Didn't work. */ /* PortP->gs.xmit_cnt = 0; */ rio_spin_unlock_irqrestore(&PortP->portSem, flags); /* Someone explain to me why this delay/config is here. If I read the docs correctly the "open" command piggybacks the parameters immediately. -- REW */ RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */ rio_spin_lock_irqsave(&PortP->portSem, flags); /* ** wait for the port to be not closed. */ while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); RIOPreemptiveCmd(p, PortP, FCLOSE); func_exit(); return -EINTR; } rio_spin_lock_irqsave(&PortP->portSem, flags); } if (p->RIOHalted) { retval = -EIO; bombout: /* RIOClearUp( PortP ); */ rio_spin_unlock_irqrestore(&PortP->portSem, flags); return retval; } rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); } rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); /* ** ACTION ** insert test for carrier here. -- ??? ** I already see that test here. What's the deal? -- REW */ if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); /* tp->tm.c_state |= CARR_ON; wakeup((caddr_t) &tp->tm.c_canq); */ PortP->State |= RIO_CARR_ON; wake_up_interruptible(&PortP->gs.open_wait); } else { /* no carrier - wait for DCD */ /* while (!(PortP->gs.tty->termios->c_state & CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) */ while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); /* PortP->gs.tty->termios->c_state |= WOPEN; */ PortP->State |= RIO_WOPEN; rio_spin_unlock_irqrestore(&PortP->portSem, flags); if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { rio_spin_lock_irqsave(&PortP->portSem, flags); /* ** ACTION: verify that this is a good thing ** to do here. -- ??? ** I think it's OK. -- REW */ rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort); RIOPreemptiveCmd(p, PortP, FCLOSE); /* tp->tm.c_state &= ~WOPEN; */ PortP->State &= ~RIO_WOPEN; rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return -EINTR; } rio_spin_lock_irqsave(&PortP->portSem, flags); } PortP->State &= ~RIO_WOPEN; } if (p->RIOHalted) goto bombout; rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); PortP->State |= RIO_MOPEN; if (p->RIOHalted) goto bombout; rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); /* ** Count opens for port statistics reporting */ if (PortP->statsGather) PortP->opens++; rio_spin_unlock_irqrestore(&PortP->portSem, flags); rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n"); func_exit(); return 0; }
int nb85e_uart_tty_open (struct tty_struct *tty, struct file *filp) { int err; struct nb85e_uart_tty_port *port; unsigned chan = MINOR (tty->device) - NB85E_UART_MINOR_BASE; if (chan >= NB85E_UART_NUM_CHANNELS) return -ENODEV; port = &nb85e_uart_tty_ports[chan]; tty->driver_data = port; port->gs.tty = tty; port->gs.count++; port->tqueue.routine = gs_do_softint; port->tqueue.data = &port->gs; /* * Start up serial port */ err = gs_init_port (&port->gs); if (err) goto failed_1; port->gs.flags |= GS_ACTIVE; if (port->gs.count == 1) { MOD_INC_USE_COUNT; /* Alloc RX irq. */ err = request_irq (IRQ_INTSR (chan), nb85e_uart_tty_rx_irq, SA_INTERRUPT, "nb85e_uart", port); if (err) goto failed_2; /* Alloc TX irq. */ err = request_irq (IRQ_INTST (chan), nb85e_uart_tty_tx_irq, SA_INTERRUPT, "nb85e_uart", port); if (err) { free_irq (IRQ_INTSR (chan), port); goto failed_2; } } err = gs_block_til_ready (port, filp); if (err) goto failed_3; *tty->termios = port->gs.normal_termios; nb85e_uart_tty_enable_rx_interrupts (port); port->gs.session = current->session; port->gs.pgrp = current->pgrp; return 0; failed_3: free_irq (IRQ_INTST (chan), port); free_irq (IRQ_INTSR (chan), port); failed_2: MOD_DEC_USE_COUNT; failed_1: port->gs.count--; return err; }
static int scc_open (struct tty_struct * tty, struct file * filp) { int line = tty->index; int retval; struct scc_port *port = &scc_ports[line]; int i, channel = port->channel; unsigned long flags; SCC_ACCESS_INIT(port); #if defined(CONFIG_MVME162_SCC) || defined(CONFIG_MVME147_SCC) static const struct { unsigned reg, val; } mvme_init_tab[] = { /* Values for MVME162 and MVME147 */ /* no parity, 1 stop bit, async, 1:16 */ { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 }, /* parity error is special cond, ints disabled, no DMA */ { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB }, /* Rx 8 bits/char, no auto enable, Rx off */ { RX_CTRL_REG, RCR_CHSIZE_8 }, /* DTR off, Tx 8 bits/char, RTS off, Tx off */ { TX_CTRL_REG, TCR_CHSIZE_8 }, /* special features off */ { AUX2_CTRL_REG, 0 }, { CLK_CTRL_REG, CCR_RXCLK_BRG | CCR_TXCLK_BRG }, { DPLL_CTRL_REG, DCR_BRG_ENAB | DCR_BRG_USE_PCLK }, /* Start Rx */ { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 }, /* Start Tx */ { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 }, /* Ext/Stat ints: DCD only */ { INT_CTRL_REG, ICR_ENAB_DCD_INT }, /* Reset Ext/Stat ints */ { COMMAND_REG, CR_EXTSTAT_RESET }, /* ...again */ { COMMAND_REG, CR_EXTSTAT_RESET }, }; #endif #if defined(CONFIG_BVME6000_SCC) static const struct { unsigned reg, val; } bvme_init_tab[] = { /* Values for BVME6000 */ /* no parity, 1 stop bit, async, 1:16 */ { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 }, /* parity error is special cond, ints disabled, no DMA */ { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB }, /* Rx 8 bits/char, no auto enable, Rx off */ { RX_CTRL_REG, RCR_CHSIZE_8 }, /* DTR off, Tx 8 bits/char, RTS off, Tx off */ { TX_CTRL_REG, TCR_CHSIZE_8 }, /* special features off */ { AUX2_CTRL_REG, 0 }, { CLK_CTRL_REG, CCR_RTxC_XTAL | CCR_RXCLK_BRG | CCR_TXCLK_BRG }, { DPLL_CTRL_REG, DCR_BRG_ENAB }, /* Start Rx */ { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 }, /* Start Tx */ { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 }, /* Ext/Stat ints: DCD only */ { INT_CTRL_REG, ICR_ENAB_DCD_INT }, /* Reset Ext/Stat ints */ { COMMAND_REG, CR_EXTSTAT_RESET }, /* ...again */ { COMMAND_REG, CR_EXTSTAT_RESET }, }; #endif if (!(port->gs.port.flags & ASYNC_INITIALIZED)) { local_irq_save(flags); #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC) if (MACH_IS_MVME147 || MACH_IS_MVME16x) { for (i = 0; i < ARRAY_SIZE(mvme_init_tab); ++i) SCCwrite(mvme_init_tab[i].reg, mvme_init_tab[i].val); } #endif #if defined(CONFIG_BVME6000_SCC) if (MACH_IS_BVME6000) { for (i = 0; i < ARRAY_SIZE(bvme_init_tab); ++i) SCCwrite(bvme_init_tab[i].reg, bvme_init_tab[i].val); } #endif /* remember status register for detection of DCD and CTS changes */ scc_last_status_reg[channel] = SCCread(STATUS_REG); port->c_dcd = 0; /* Prevent initial 1->0 interrupt */ scc_setsignals (port, 1,1); local_irq_restore(flags); } tty->driver_data = port; port->gs.port.tty = tty; port->gs.port.count++; retval = gs_init_port(&port->gs); if (retval) { port->gs.port.count--; return retval; } port->gs.port.flags |= GS_ACTIVE; retval = gs_block_til_ready(port, filp); if (retval) { port->gs.port.count--; return retval; } port->c_dcd = tty_port_carrier_raised(&port->gs.port); scc_enable_rx_interrupts(port); return 0; }
static int scc_open (struct tty_struct * tty, struct file * filp) { int line = MINOR(tty->device) - SCC_MINOR_BASE; int retval; struct scc_port *port = &scc_ports[line]; int i, channel = port->channel; unsigned long flags; SCC_ACCESS_INIT(port); #if defined(CONFIG_MVME162_SCC) || defined(CONFIG_MVME147_SCC) static const struct { unsigned reg, val; } mvme_init_tab[] = { /* Values for MVME162 and MVME147 */ /* no parity, 1 stop bit, async, 1:16 */ { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 }, /* parity error is special cond, ints disabled, no DMA */ { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB }, /* Rx 8 bits/char, no auto enable, Rx off */ { RX_CTRL_REG, RCR_CHSIZE_8 }, /* DTR off, Tx 8 bits/char, RTS off, Tx off */ { TX_CTRL_REG, TCR_CHSIZE_8 }, /* special features off */ { AUX2_CTRL_REG, 0 }, { CLK_CTRL_REG, CCR_RXCLK_BRG | CCR_TXCLK_BRG }, { DPLL_CTRL_REG, DCR_BRG_ENAB | DCR_BRG_USE_PCLK }, /* Start Rx */ { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 }, /* Start Tx */ { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 }, /* Ext/Stat ints: DCD only */ { INT_CTRL_REG, ICR_ENAB_DCD_INT }, /* Reset Ext/Stat ints */ { COMMAND_REG, CR_EXTSTAT_RESET }, /* ...again */ { COMMAND_REG, CR_EXTSTAT_RESET }, }; #endif #if defined(CONFIG_BVME6000_SCC) static const struct { unsigned reg, val; } bvme_init_tab[] = { /* Values for BVME6000 */ /* no parity, 1 stop bit, async, 1:16 */ { AUX1_CTRL_REG, A1CR_PARITY_NONE|A1CR_MODE_ASYNC_1|A1CR_CLKMODE_x16 }, /* parity error is special cond, ints disabled, no DMA */ { INT_AND_DMA_REG, IDR_PARERR_AS_SPCOND | IDR_RX_INT_DISAB }, /* Rx 8 bits/char, no auto enable, Rx off */ { RX_CTRL_REG, RCR_CHSIZE_8 }, /* DTR off, Tx 8 bits/char, RTS off, Tx off */ { TX_CTRL_REG, TCR_CHSIZE_8 }, /* special features off */ { AUX2_CTRL_REG, 0 }, { CLK_CTRL_REG, CCR_RTxC_XTAL | CCR_RXCLK_BRG | CCR_TXCLK_BRG }, { DPLL_CTRL_REG, DCR_BRG_ENAB }, /* Start Rx */ { RX_CTRL_REG, RCR_RX_ENAB | RCR_CHSIZE_8 }, /* Start Tx */ { TX_CTRL_REG, TCR_TX_ENAB | TCR_RTS | TCR_DTR | TCR_CHSIZE_8 }, /* Ext/Stat ints: DCD only */ { INT_CTRL_REG, ICR_ENAB_DCD_INT }, /* Reset Ext/Stat ints */ { COMMAND_REG, CR_EXTSTAT_RESET }, /* ...again */ { COMMAND_REG, CR_EXTSTAT_RESET }, }; #endif if (!(port->gs.flags & ASYNC_INITIALIZED)) { save_flags(flags); cli(); #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC) if (MACH_IS_MVME147 || MACH_IS_MVME16x) { for (i=0; i<sizeof(mvme_init_tab)/sizeof(*mvme_init_tab); ++i) SCCwrite(mvme_init_tab[i].reg, mvme_init_tab[i].val); } #endif #if defined(CONFIG_BVME6000_SCC) if (MACH_IS_BVME6000) { for (i=0; i<sizeof(bvme_init_tab)/sizeof(*bvme_init_tab); ++i) SCCwrite(bvme_init_tab[i].reg, bvme_init_tab[i].val); } #endif /* remember status register for detection of DCD and CTS changes */ scc_last_status_reg[channel] = SCCread(STATUS_REG); port->c_dcd = 0; /* Prevent initial 1->0 interrupt */ scc_setsignals (port, 1,1); restore_flags(flags); } tty->driver_data = port; port->gs.tty = tty; port->gs.count++; retval = gs_init_port(&port->gs); if (retval) { port->gs.count--; return retval; } port->gs.flags |= GS_ACTIVE; if (port->gs.count == 1) { MOD_INC_USE_COUNT; } retval = gs_block_til_ready(port, filp); if (retval) { MOD_DEC_USE_COUNT; port->gs.count--; return retval; } if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) { if (tty->driver.subtype == SERIAL_TYPE_NORMAL) *tty->termios = port->gs.normal_termios; else *tty->termios = port->gs.callout_termios; scc_set_real_termios (port); } port->gs.session = current->session; port->gs.pgrp = current->pgrp; port->c_dcd = scc_get_CD (port); scc_enable_rx_interrupts(port); return 0; }
/* ********************************************************************** * * Here are the routines that actually * * interface with the rest of the system * * ********************************************************************** */ static int rs_open (struct tty_struct * tty, struct file * filp) { struct rs_port *port; int retval, line; func_enter(); if (!rs_initialized) { return -EIO; } line = MINOR(tty->device) - tty->driver.minor_start; rs_dprintk (TX3912_UART_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p)\n", (int) current->pid, line, tty, current->tty); if ((line < 0) || (line >= TX3912_UART_NPORTS)) return -ENODEV; /* Pre-initialized already */ port = & rs_ports[line]; rs_dprintk (TX3912_UART_DEBUG_OPEN, "port = %p\n", port); tty->driver_data = port; port->gs.tty = tty; port->gs.count++; rs_dprintk (TX3912_UART_DEBUG_OPEN, "starting port\n"); /* * Start up serial port */ retval = gs_init_port(&port->gs); rs_dprintk (TX3912_UART_DEBUG_OPEN, "done gs_init\n"); if (retval) { port->gs.count--; return retval; } port->gs.flags |= GS_ACTIVE; rs_dprintk (TX3912_UART_DEBUG_OPEN, "before inc_use_count (count=%d.\n", port->gs.count); if (port->gs.count == 1) { MOD_INC_USE_COUNT; } rs_dprintk (TX3912_UART_DEBUG_OPEN, "after inc_use_count\n"); /* Jim: Initialize port hardware here */ /* Enable high-priority interrupts for UARTA */ IntEnable6 |= INT6_UARTARXINT; rs_enable_rx_interrupts(&rs_ports[0]); retval = gs_block_til_ready(&port->gs, filp); rs_dprintk (TX3912_UART_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", retval, port->gs.count); if (retval) { MOD_DEC_USE_COUNT; port->gs.count--; return retval; } /* tty->low_latency = 1; */ if ((port->gs.count == 1) && (port->gs.flags & ASYNC_SPLIT_TERMIOS)) { if (tty->driver.subtype == SERIAL_TYPE_NORMAL) *tty->termios = port->gs.normal_termios; else *tty->termios = port->gs.callout_termios; rs_set_real_termios (port); } port->gs.session = current->session; port->gs.pgrp = current->pgrp; func_exit(); /* Jim */ /* cli(); */ return 0; }
/** * gserial_connect - notify TTY I/O glue that USB link is active * @gser: the function, set up with endpoints and descriptors * @port_num: which port is active * Context: any (usually from irq) * * This is called activate endpoints and let the TTY layer know that * the connection is active ... not unlike "carrier detect". It won't * necessarily start I/O queues; unless the TTY is held open by any * task, there would be no point. However, the endpoints will be * activated so the USB host can perform I/O, subject to basic USB * hardware flow control. * * Caller needs to have set up the endpoints and USB function in @dev * before calling this, as well as the appropriate (speed-specific) * endpoint descriptors, and also have set up the TTY driver by calling * @gserial_setup(). * * Returns negative errno or zero. * On success, ep->driver_data will be overwritten. */ int gserial_connect(struct gserial *gser, u8 port_num) { struct gs_port *port; unsigned long flags; int status; pr_info("Davis: enter gserial_connect port_num %d\n", port_num); if (!gs_tty_driver || port_num >= n_ports) return -ENXIO; /* we "know" gserial_cleanup() hasn't been called */ port = ports[port_num].port; /* activate the endpoints */ status = usb_ep_enable(gser->in, gser->in_desc); if (status < 0) return status; gser->in->driver_data = port; status = usb_ep_enable(gser->out, gser->out_desc); if (status < 0) goto fail_out; gser->out->driver_data = port; /* then tell the tty glue that I/O can work */ spin_lock_irqsave(&port->port_lock, flags); gser->ioport = port; port->port_usb = gser; /* REVISIT unclear how best to handle this state... * we don't really couple it with the Linux TTY. */ gser->port_line_coding = port->port_line_coding; /* REVISIT if waiting on "carrier detect", signal. */ /* if it's already open, start I/O ... and notify the serial * protocol about open/close status (connect/disconnect). */ if (port->open_count) { pr_debug("gserial_connect: start ttyGS%d\n", port->port_num); gs_start_io(port); if (gser->connect) gser->connect(gser); } else { if (gser->disconnect) gser->disconnect(gser); } spin_unlock_irqrestore(&port->port_lock, flags); // Davis: open the gserial port #ifdef CONFIG_USB_SERIAL_RELAY if(port_num == GS_PORT_NUM) gs_init_port(port_num); #endif return status; fail_out: usb_ep_disable(gser->in); gser->in->driver_data = NULL; return status; }