Loading drivers/char/esp.c +283 −308 Original line number Diff line number Diff line Loading @@ -61,11 +61,11 @@ #include <linux/bitops.h> #include <asm/system.h> #include <asm/io.h> #include <linux/io.h> #include <asm/dma.h> #include <linux/slab.h> #include <asm/uaccess.h> #include <linux/uaccess.h> #include <linux/hayesesp.h> Loading Loading @@ -127,8 +127,10 @@ static struct tty_driver *esp_driver; #undef SERIAL_DEBUG_FLOW #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ tty->name, (info->flags), serial_driver.refcount,info->count,tty->count,s) #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ tty->name, info->flags, \ serial_driver.refcount, \ info->count, tty->count, s) #else #define DBG_CNT(s) #endif Loading Loading @@ -189,7 +191,7 @@ static inline void serial_out(struct esp_struct *info, int offset, */ static void rs_stop(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_stop")) Loading @@ -206,7 +208,7 @@ static void rs_stop(struct tty_struct *tty) static void rs_start(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_start")) Loading Loading @@ -325,8 +327,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) flag = TTY_BREAK; if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (err_buf->data[i] & 0x02) } else if (err_buf->data[i] & 0x02) flag = TTY_FRAME; else if (err_buf->data[i] & 0x01) flag = TTY_PARITY; Loading @@ -341,22 +342,28 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) release_pio_buffer(err_buf); } static inline void receive_chars_dma(struct esp_struct *info, int num_bytes) static void program_isa_dma(int dma, int dir, unsigned long addr, int len) { unsigned long flags; info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; dma_bytes = num_bytes; info->stat_flags |= ESP_STAT_DMA_RX; flags = claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_READ); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); set_dma_mode(dma, dir); set_dma_addr(dma, addr); set_dma_count(dma, len); enable_dma(dma); release_dma_lock(flags); } static void receive_chars_dma(struct esp_struct *info, int num_bytes) { info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; dma_bytes = num_bytes; info->stat_flags |= ESP_STAT_DMA_RX; program_isa_dma(dma, DMA_MODE_READ, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX); } Loading Loading @@ -393,13 +400,13 @@ static inline void receive_chars_dma_done(struct esp_struct *info, do_SAK(tty); } else if (status & 0x08) { statflag = TTY_FRAME; (info->icount.frame)++; } else if (status & 0x04) { info->icount.frame++; } else if (status & 0x04) { statflag = TTY_PARITY; (info->icount.parity)++; info->icount.parity++; } tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); } tty_schedule_flip(tty); } Loading Loading @@ -484,8 +491,6 @@ static inline void transmit_chars_pio(struct esp_struct *info, /* Caller must hold info->lock */ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) { unsigned long flags; dma_bytes = num_bytes; if (info->xmit_tail + dma_bytes <= ESP_XMIT_SIZE) { Loading Loading @@ -518,15 +523,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) info->stat_flags |= ESP_STAT_DMA_TX; flags=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_WRITE); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); enable_dma(dma); release_dma_lock(flags); program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); } Loading @@ -535,7 +533,6 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) int num_bytes; unsigned long flags; flags = claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); Loading @@ -548,14 +545,8 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) dma_bytes -= num_bytes; memmove(dma_buffer, dma_buffer + num_bytes, dma_bytes); flags=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_WRITE); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); enable_dma(dma); release_dma_lock(flags); program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); } else { Loading @@ -564,7 +555,7 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) } } static inline void check_modem_status(struct esp_struct *info) static void check_modem_status(struct esp_struct *info) { int status; Loading Loading @@ -722,7 +713,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id) * --------------------------------------------------------------- */ static inline void esp_basic_init(struct esp_struct * info) static void esp_basic_init(struct esp_struct *info) { /* put ESPC in enhanced mode */ serial_out(info, UART_ESI_CMD1, ESI_SET_MODE); Loading Loading @@ -802,7 +793,8 @@ static int startup(struct esp_struct * info) } #ifdef SERIAL_DEBUG_OPEN printk("starting up ttys%d (irq %d)...", info->line, info->irq); printk(KERN_DEBUG "starting up ttys%d (irq %d)...", info->line, info->irq); #endif /* Flush the RX buffer. Using the ESI flush command may cause */ Loading Loading @@ -1037,14 +1029,12 @@ static void change_speed(struct esp_struct *info) if (cflag & CMSPAR) cval |= UART_LCR_SPAR; #endif baud = tty_get_baud_rate(info->tty); if (baud == 38400 && ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) quot = info->custom_divisor; else { if (baud == 134) /* Special case since 134 is really 134.5 */ if (baud == 134) /* Special case since 134 is really 134.5 */ quot = (2*BASE_BAUD / 269); else if (baud) quot = BASE_BAUD / baud; Loading @@ -1053,6 +1043,11 @@ static void change_speed(struct esp_struct *info) if (!quot) quot = BASE_BAUD / 9600; if (baud) { /* Actual rate */ baud = BASE_BAUD/quot; tty_encode_baud_rate(info->tty, baud, baud); } info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50); /* CTS flow control flag and modem status interrupts */ Loading @@ -1066,10 +1061,8 @@ static void change_speed(struct esp_struct *info) info->flags &= ~ASYNC_CTS_FLOW; if (cflag & CLOCAL) info->flags &= ~ASYNC_CHECK_CD; else { else info->flags |= ASYNC_CHECK_CD; /* info->IER |= UART_IER_MSI; */ } /* * Set up parity check flag Loading Loading @@ -1158,7 +1151,7 @@ static void change_speed(struct esp_struct *info) static int rs_put_char(struct tty_struct *tty, unsigned char ch) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; int ret = 0; Loading @@ -1181,7 +1174,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch) static void rs_flush_chars(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) Loading @@ -1205,7 +1198,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) { int c, t, ret = 0; struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_write")) Loading Loading @@ -1255,7 +1248,7 @@ static int rs_write(struct tty_struct * tty, static int rs_write_room(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; int ret; unsigned long flags; Loading @@ -1273,7 +1266,7 @@ static int rs_write_room(struct tty_struct *tty) static int rs_chars_in_buffer(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) return 0; Loading @@ -1282,7 +1275,7 @@ static int rs_chars_in_buffer(struct tty_struct *tty) static void rs_flush_buffer(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) Loading @@ -1303,13 +1296,13 @@ static void rs_flush_buffer(struct tty_struct *tty) */ static void rs_throttle(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; #ifdef SERIAL_DEBUG_THROTTLE char buf[64]; printk("throttle %s: %d....\n", tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty)); tty_chars_in_buffer(tty)); #endif if (serial_paranoia_check(info, tty->name, "rs_throttle")) Loading @@ -1326,13 +1319,13 @@ static void rs_throttle(struct tty_struct * tty) static void rs_unthrottle(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; #ifdef SERIAL_DEBUG_THROTTLE char buf[64]; printk("unthrottle %s: %d....\n", tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty)); printk(KERN_DEBUG "unthrottle %s: %d....\n", tty_name(tty, buf), tty_chars_in_buffer(tty)); #endif if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) Loading Loading @@ -1557,7 +1550,6 @@ static int set_esp_config(struct esp_struct * info, if (new_config.dma_channel) { /* PIO mode to DMA mode transition OR */ /* change current DMA channel */ current_async = ports; while (current_async) { Loading @@ -1567,8 +1559,7 @@ static int set_esp_config(struct esp_struct * info, } else if (current_async->count) return -EBUSY; current_async = current_async->next_port; current_async = current_async->next_port; } shutdown(info); Loading @@ -1587,7 +1578,6 @@ static int set_esp_config(struct esp_struct * info, spin_unlock_irqrestore(&info->lock, flags); } else { /* DMA mode to PIO mode only */ if (info->count > 1) return -EBUSY; Loading Loading @@ -1677,7 +1667,7 @@ static int get_lsr_info(struct esp_struct * info, unsigned int __user *value) static int esp_tiocmget(struct tty_struct *tty, struct file *file) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned char control, status; unsigned long flags; Loading @@ -1704,7 +1694,7 @@ static int esp_tiocmget(struct tty_struct *tty, struct file *file) static int esp_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, __FUNCTION__)) Loading Loading @@ -1737,7 +1727,7 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file, */ static void esp_break(struct tty_struct *tty, int break_state) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "esp_break")) Loading @@ -1762,7 +1752,7 @@ static void esp_break(struct tty_struct *tty, int break_state) static int rs_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; struct async_icount cprev, cnow; /* kernel counter temps */ struct serial_icounter_struct __user *p_cuser; /* user space */ void __user *argp = (void __user *)arg; Loading @@ -1789,21 +1779,14 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, ret = set_serial_info(info, argp); unlock_kernel(); return ret; case TIOCSERCONFIG: /* do not reconfigure after initial configuration */ return 0; case TIOCSERGWILD: return put_user(0L, (unsigned long __user *)argp); case TIOCSERGETLSR: /* Get line status register */ return get_lsr_info(info, argp); case TIOCSERSWILD: if (!capable(CAP_SYS_ADMIN)) return -EPERM; return 0; /* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change * - mask passed in arg for lines of interest Loading Loading @@ -1841,7 +1824,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, cprev = cnow; } /* NOTREACHED */ /* * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) * Return: write counters to the user passed counter struct Loading @@ -1858,7 +1840,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, put_user(cnow.rng, &p_cuser->rng) || put_user(cnow.dcd, &p_cuser->dcd)) return -EFAULT; return 0; case TIOCGHAYESESP: return get_esp_config(info, argp); Loading @@ -1875,7 +1856,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; change_speed(info); Loading Loading @@ -1921,7 +1902,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) */ static void rs_close(struct tty_struct *tty, struct file *filp) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (!info || serial_paranoia_check(info, tty->name, "rs_close")) Loading @@ -1935,9 +1916,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp) } #ifdef SERIAL_DEBUG_OPEN printk("rs_close ttys%d, count = %d\n", info->line, info->count); printk(KERN_DEBUG "rs_close ttys%d, count = %d\n", info->line, info->count); #endif if ((tty->count == 1) && (info->count != 1)) { if (tty->count == 1 && info->count != 1) { /* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always Loading @@ -1945,12 +1927,11 @@ static void rs_close(struct tty_struct *tty, struct file * filp) * one, we've got real problems, since it means the * serial port won't be shutdown. */ printk("rs_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count); printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count); info->count = 1; } if (--info->count < 0) { printk("rs_close: bad serial port count for ttys%d: %d\n", printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n", info->line, info->count); info->count = 0; } Loading Loading @@ -2003,9 +1984,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp) info->tty = NULL; if (info->blocked_open) { if (info->close_delay) { if (info->close_delay) msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); } info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); Loading @@ -2018,7 +1998,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) static void rs_wait_until_sent(struct tty_struct *tty, int timeout) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long orig_jiffies, char_time; unsigned long flags; Loading Loading @@ -2060,7 +2040,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) */ static void esp_hangup(struct tty_struct *tty) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; if (serial_paranoia_check(info, tty->name, "esp_hangup")) return; Loading Loading @@ -2127,7 +2107,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, retval = 0; add_wait_queue(&info->open_wait, &wait); #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready before block: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n", info->line, info->count); #endif spin_lock_irqsave(&info->lock, flags); Loading Loading @@ -2172,7 +2152,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, break; } #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready blocking: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n", info->line, info->count); #endif spin_unlock_irqrestore(&info->lock, flags); Loading @@ -2186,7 +2166,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, info->blocked_open--; spin_unlock_irqrestore(&info->lock, flags); #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready after blocking: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n", info->line, info->count); #endif if (retval) Loading Loading @@ -2224,7 +2204,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp) } #ifdef SERIAL_DEBUG_OPEN printk("esp_open %s, count = %d\n", tty->name, info->count); printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count); #endif spin_lock_irqsave(&info->lock, flags); info->count++; Loading @@ -2243,14 +2223,13 @@ static int esp_open(struct tty_struct *tty, struct file * filp) retval = block_til_ready(tty, filp, info); if (retval) { #ifdef SERIAL_DEBUG_OPEN printk("esp_open returning after block_til_ready with %d\n", printk(KERN_DEBUG "esp_open returning after block_til_ready with %d\n", retval); #endif return retval; } #ifdef SERIAL_DEBUG_OPEN printk("esp_open %s successful...", tty->name); printk(KERN_DEBUG "esp_open %s successful...", tty->name); #endif return 0; } Loading @@ -2269,7 +2248,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp) * driver. */ static inline void show_serial_version(void) static void show_serial_version(void) { printk(KERN_INFO "%s version %s (DMA %u)\n", serial_name, serial_version, dma); Loading @@ -2279,7 +2258,7 @@ static inline void show_serial_version(void) * This routine is called by espserial_init() to initialize a specific serial * port. */ static inline int autoconfig(struct esp_struct * info) static int autoconfig(struct esp_struct *info) { int port_detected = 0; unsigned long flags; Loading Loading @@ -2407,10 +2386,11 @@ static int __init espserial_init(void) esp_driver->init_termios = tty_std_termios; esp_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; esp_driver->init_termios.c_ispeed = 9600; esp_driver->init_termios.c_ospeed = 9600; esp_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(esp_driver, &esp_ops); if (tty_register_driver(esp_driver)) { if (tty_register_driver(esp_driver)) { printk(KERN_ERR "Couldn't register esp serial driver"); put_tty_driver(esp_driver); return 1; Loading @@ -2418,8 +2398,7 @@ static int __init espserial_init(void) info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); if (!info) { if (!info) { printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); tty_unregister_driver(esp_driver); put_tty_driver(esp_driver); Loading Loading @@ -2482,10 +2461,8 @@ static int __init espserial_init(void) info->stat_flags |= ESP_STAT_NEVER_DMA; info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); if (!info) { if (!info) { printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); /* allow use of the already detected ports */ return 0; } Loading Loading @@ -2515,16 +2492,14 @@ static void __exit espserial_exit(void) struct esp_struct *temp_async; struct esp_pio_buffer *pio_buf; /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ if ((e1 = tty_unregister_driver(esp_driver))) printk("SERIAL: failed to unregister serial driver (%d)\n", e1); e1 = tty_unregister_driver(esp_driver); if (e1) printk(KERN_ERR "esp: failed to unregister driver (%d)\n", e1); put_tty_driver(esp_driver); while (ports) { if (ports->port) { if (ports->port) release_region(ports->port, REGION_SIZE); } temp_async = ports->next_port; kfree(ports); ports = temp_async; Loading Loading
drivers/char/esp.c +283 −308 Original line number Diff line number Diff line Loading @@ -61,11 +61,11 @@ #include <linux/bitops.h> #include <asm/system.h> #include <asm/io.h> #include <linux/io.h> #include <asm/dma.h> #include <linux/slab.h> #include <asm/uaccess.h> #include <linux/uaccess.h> #include <linux/hayesesp.h> Loading Loading @@ -127,8 +127,10 @@ static struct tty_driver *esp_driver; #undef SERIAL_DEBUG_FLOW #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ tty->name, (info->flags), serial_driver.refcount,info->count,tty->count,s) #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ tty->name, info->flags, \ serial_driver.refcount, \ info->count, tty->count, s) #else #define DBG_CNT(s) #endif Loading Loading @@ -189,7 +191,7 @@ static inline void serial_out(struct esp_struct *info, int offset, */ static void rs_stop(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_stop")) Loading @@ -206,7 +208,7 @@ static void rs_stop(struct tty_struct *tty) static void rs_start(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_start")) Loading Loading @@ -325,8 +327,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) flag = TTY_BREAK; if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (err_buf->data[i] & 0x02) } else if (err_buf->data[i] & 0x02) flag = TTY_FRAME; else if (err_buf->data[i] & 0x01) flag = TTY_PARITY; Loading @@ -341,22 +342,28 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) release_pio_buffer(err_buf); } static inline void receive_chars_dma(struct esp_struct *info, int num_bytes) static void program_isa_dma(int dma, int dir, unsigned long addr, int len) { unsigned long flags; info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; dma_bytes = num_bytes; info->stat_flags |= ESP_STAT_DMA_RX; flags = claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_READ); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); set_dma_mode(dma, dir); set_dma_addr(dma, addr); set_dma_count(dma, len); enable_dma(dma); release_dma_lock(flags); } static void receive_chars_dma(struct esp_struct *info, int num_bytes) { info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; dma_bytes = num_bytes; info->stat_flags |= ESP_STAT_DMA_RX; program_isa_dma(dma, DMA_MODE_READ, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX); } Loading Loading @@ -393,13 +400,13 @@ static inline void receive_chars_dma_done(struct esp_struct *info, do_SAK(tty); } else if (status & 0x08) { statflag = TTY_FRAME; (info->icount.frame)++; } else if (status & 0x04) { info->icount.frame++; } else if (status & 0x04) { statflag = TTY_PARITY; (info->icount.parity)++; info->icount.parity++; } tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); } tty_schedule_flip(tty); } Loading Loading @@ -484,8 +491,6 @@ static inline void transmit_chars_pio(struct esp_struct *info, /* Caller must hold info->lock */ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) { unsigned long flags; dma_bytes = num_bytes; if (info->xmit_tail + dma_bytes <= ESP_XMIT_SIZE) { Loading Loading @@ -518,15 +523,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) info->stat_flags |= ESP_STAT_DMA_TX; flags=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_WRITE); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); enable_dma(dma); release_dma_lock(flags); program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); } Loading @@ -535,7 +533,6 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) int num_bytes; unsigned long flags; flags = claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); Loading @@ -548,14 +545,8 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) dma_bytes -= num_bytes; memmove(dma_buffer, dma_buffer + num_bytes, dma_bytes); flags=claim_dma_lock(); disable_dma(dma); clear_dma_ff(dma); set_dma_mode(dma, DMA_MODE_WRITE); set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); set_dma_count(dma, dma_bytes); enable_dma(dma); release_dma_lock(flags); program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer), dma_bytes); serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); } else { Loading @@ -564,7 +555,7 @@ static inline void transmit_chars_dma_done(struct esp_struct *info) } } static inline void check_modem_status(struct esp_struct *info) static void check_modem_status(struct esp_struct *info) { int status; Loading Loading @@ -722,7 +713,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id) * --------------------------------------------------------------- */ static inline void esp_basic_init(struct esp_struct * info) static void esp_basic_init(struct esp_struct *info) { /* put ESPC in enhanced mode */ serial_out(info, UART_ESI_CMD1, ESI_SET_MODE); Loading Loading @@ -802,7 +793,8 @@ static int startup(struct esp_struct * info) } #ifdef SERIAL_DEBUG_OPEN printk("starting up ttys%d (irq %d)...", info->line, info->irq); printk(KERN_DEBUG "starting up ttys%d (irq %d)...", info->line, info->irq); #endif /* Flush the RX buffer. Using the ESI flush command may cause */ Loading Loading @@ -1037,14 +1029,12 @@ static void change_speed(struct esp_struct *info) if (cflag & CMSPAR) cval |= UART_LCR_SPAR; #endif baud = tty_get_baud_rate(info->tty); if (baud == 38400 && ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) quot = info->custom_divisor; else { if (baud == 134) /* Special case since 134 is really 134.5 */ if (baud == 134) /* Special case since 134 is really 134.5 */ quot = (2*BASE_BAUD / 269); else if (baud) quot = BASE_BAUD / baud; Loading @@ -1053,6 +1043,11 @@ static void change_speed(struct esp_struct *info) if (!quot) quot = BASE_BAUD / 9600; if (baud) { /* Actual rate */ baud = BASE_BAUD/quot; tty_encode_baud_rate(info->tty, baud, baud); } info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50); /* CTS flow control flag and modem status interrupts */ Loading @@ -1066,10 +1061,8 @@ static void change_speed(struct esp_struct *info) info->flags &= ~ASYNC_CTS_FLOW; if (cflag & CLOCAL) info->flags &= ~ASYNC_CHECK_CD; else { else info->flags |= ASYNC_CHECK_CD; /* info->IER |= UART_IER_MSI; */ } /* * Set up parity check flag Loading Loading @@ -1158,7 +1151,7 @@ static void change_speed(struct esp_struct *info) static int rs_put_char(struct tty_struct *tty, unsigned char ch) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; int ret = 0; Loading @@ -1181,7 +1174,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch) static void rs_flush_chars(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) Loading @@ -1205,7 +1198,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) { int c, t, ret = 0; struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_write")) Loading Loading @@ -1255,7 +1248,7 @@ static int rs_write(struct tty_struct * tty, static int rs_write_room(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; int ret; unsigned long flags; Loading @@ -1273,7 +1266,7 @@ static int rs_write_room(struct tty_struct *tty) static int rs_chars_in_buffer(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) return 0; Loading @@ -1282,7 +1275,7 @@ static int rs_chars_in_buffer(struct tty_struct *tty) static void rs_flush_buffer(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) Loading @@ -1303,13 +1296,13 @@ static void rs_flush_buffer(struct tty_struct *tty) */ static void rs_throttle(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; #ifdef SERIAL_DEBUG_THROTTLE char buf[64]; printk("throttle %s: %d....\n", tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty)); tty_chars_in_buffer(tty)); #endif if (serial_paranoia_check(info, tty->name, "rs_throttle")) Loading @@ -1326,13 +1319,13 @@ static void rs_throttle(struct tty_struct * tty) static void rs_unthrottle(struct tty_struct *tty) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; #ifdef SERIAL_DEBUG_THROTTLE char buf[64]; printk("unthrottle %s: %d....\n", tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty)); printk(KERN_DEBUG "unthrottle %s: %d....\n", tty_name(tty, buf), tty_chars_in_buffer(tty)); #endif if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) Loading Loading @@ -1557,7 +1550,6 @@ static int set_esp_config(struct esp_struct * info, if (new_config.dma_channel) { /* PIO mode to DMA mode transition OR */ /* change current DMA channel */ current_async = ports; while (current_async) { Loading @@ -1567,8 +1559,7 @@ static int set_esp_config(struct esp_struct * info, } else if (current_async->count) return -EBUSY; current_async = current_async->next_port; current_async = current_async->next_port; } shutdown(info); Loading @@ -1587,7 +1578,6 @@ static int set_esp_config(struct esp_struct * info, spin_unlock_irqrestore(&info->lock, flags); } else { /* DMA mode to PIO mode only */ if (info->count > 1) return -EBUSY; Loading Loading @@ -1677,7 +1667,7 @@ static int get_lsr_info(struct esp_struct * info, unsigned int __user *value) static int esp_tiocmget(struct tty_struct *tty, struct file *file) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned char control, status; unsigned long flags; Loading @@ -1704,7 +1694,7 @@ static int esp_tiocmget(struct tty_struct *tty, struct file *file) static int esp_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, __FUNCTION__)) Loading Loading @@ -1737,7 +1727,7 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file, */ static void esp_break(struct tty_struct *tty, int break_state) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (serial_paranoia_check(info, tty->name, "esp_break")) Loading @@ -1762,7 +1752,7 @@ static void esp_break(struct tty_struct *tty, int break_state) static int rs_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; struct async_icount cprev, cnow; /* kernel counter temps */ struct serial_icounter_struct __user *p_cuser; /* user space */ void __user *argp = (void __user *)arg; Loading @@ -1789,21 +1779,14 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, ret = set_serial_info(info, argp); unlock_kernel(); return ret; case TIOCSERCONFIG: /* do not reconfigure after initial configuration */ return 0; case TIOCSERGWILD: return put_user(0L, (unsigned long __user *)argp); case TIOCSERGETLSR: /* Get line status register */ return get_lsr_info(info, argp); case TIOCSERSWILD: if (!capable(CAP_SYS_ADMIN)) return -EPERM; return 0; /* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change * - mask passed in arg for lines of interest Loading Loading @@ -1841,7 +1824,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, cprev = cnow; } /* NOTREACHED */ /* * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) * Return: write counters to the user passed counter struct Loading @@ -1858,7 +1840,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, put_user(cnow.rng, &p_cuser->rng) || put_user(cnow.dcd, &p_cuser->dcd)) return -EFAULT; return 0; case TIOCGHAYESESP: return get_esp_config(info, argp); Loading @@ -1875,7 +1856,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; change_speed(info); Loading Loading @@ -1921,7 +1902,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) */ static void rs_close(struct tty_struct *tty, struct file *filp) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long flags; if (!info || serial_paranoia_check(info, tty->name, "rs_close")) Loading @@ -1935,9 +1916,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp) } #ifdef SERIAL_DEBUG_OPEN printk("rs_close ttys%d, count = %d\n", info->line, info->count); printk(KERN_DEBUG "rs_close ttys%d, count = %d\n", info->line, info->count); #endif if ((tty->count == 1) && (info->count != 1)) { if (tty->count == 1 && info->count != 1) { /* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always Loading @@ -1945,12 +1927,11 @@ static void rs_close(struct tty_struct *tty, struct file * filp) * one, we've got real problems, since it means the * serial port won't be shutdown. */ printk("rs_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count); printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count); info->count = 1; } if (--info->count < 0) { printk("rs_close: bad serial port count for ttys%d: %d\n", printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n", info->line, info->count); info->count = 0; } Loading Loading @@ -2003,9 +1984,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp) info->tty = NULL; if (info->blocked_open) { if (info->close_delay) { if (info->close_delay) msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); } info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); Loading @@ -2018,7 +1998,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) static void rs_wait_until_sent(struct tty_struct *tty, int timeout) { struct esp_struct *info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; unsigned long orig_jiffies, char_time; unsigned long flags; Loading Loading @@ -2060,7 +2040,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) */ static void esp_hangup(struct tty_struct *tty) { struct esp_struct * info = (struct esp_struct *)tty->driver_data; struct esp_struct *info = tty->driver_data; if (serial_paranoia_check(info, tty->name, "esp_hangup")) return; Loading Loading @@ -2127,7 +2107,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, retval = 0; add_wait_queue(&info->open_wait, &wait); #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready before block: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n", info->line, info->count); #endif spin_lock_irqsave(&info->lock, flags); Loading Loading @@ -2172,7 +2152,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, break; } #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready blocking: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n", info->line, info->count); #endif spin_unlock_irqrestore(&info->lock, flags); Loading @@ -2186,7 +2166,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, info->blocked_open--; spin_unlock_irqrestore(&info->lock, flags); #ifdef SERIAL_DEBUG_OPEN printk("block_til_ready after blocking: ttys%d, count = %d\n", printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n", info->line, info->count); #endif if (retval) Loading Loading @@ -2224,7 +2204,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp) } #ifdef SERIAL_DEBUG_OPEN printk("esp_open %s, count = %d\n", tty->name, info->count); printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count); #endif spin_lock_irqsave(&info->lock, flags); info->count++; Loading @@ -2243,14 +2223,13 @@ static int esp_open(struct tty_struct *tty, struct file * filp) retval = block_til_ready(tty, filp, info); if (retval) { #ifdef SERIAL_DEBUG_OPEN printk("esp_open returning after block_til_ready with %d\n", printk(KERN_DEBUG "esp_open returning after block_til_ready with %d\n", retval); #endif return retval; } #ifdef SERIAL_DEBUG_OPEN printk("esp_open %s successful...", tty->name); printk(KERN_DEBUG "esp_open %s successful...", tty->name); #endif return 0; } Loading @@ -2269,7 +2248,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp) * driver. */ static inline void show_serial_version(void) static void show_serial_version(void) { printk(KERN_INFO "%s version %s (DMA %u)\n", serial_name, serial_version, dma); Loading @@ -2279,7 +2258,7 @@ static inline void show_serial_version(void) * This routine is called by espserial_init() to initialize a specific serial * port. */ static inline int autoconfig(struct esp_struct * info) static int autoconfig(struct esp_struct *info) { int port_detected = 0; unsigned long flags; Loading Loading @@ -2407,10 +2386,11 @@ static int __init espserial_init(void) esp_driver->init_termios = tty_std_termios; esp_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; esp_driver->init_termios.c_ispeed = 9600; esp_driver->init_termios.c_ospeed = 9600; esp_driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(esp_driver, &esp_ops); if (tty_register_driver(esp_driver)) { if (tty_register_driver(esp_driver)) { printk(KERN_ERR "Couldn't register esp serial driver"); put_tty_driver(esp_driver); return 1; Loading @@ -2418,8 +2398,7 @@ static int __init espserial_init(void) info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); if (!info) { if (!info) { printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); tty_unregister_driver(esp_driver); put_tty_driver(esp_driver); Loading Loading @@ -2482,10 +2461,8 @@ static int __init espserial_init(void) info->stat_flags |= ESP_STAT_NEVER_DMA; info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); if (!info) { if (!info) { printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); /* allow use of the already detected ports */ return 0; } Loading Loading @@ -2515,16 +2492,14 @@ static void __exit espserial_exit(void) struct esp_struct *temp_async; struct esp_pio_buffer *pio_buf; /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ if ((e1 = tty_unregister_driver(esp_driver))) printk("SERIAL: failed to unregister serial driver (%d)\n", e1); e1 = tty_unregister_driver(esp_driver); if (e1) printk(KERN_ERR "esp: failed to unregister driver (%d)\n", e1); put_tty_driver(esp_driver); while (ports) { if (ports->port) { if (ports->port) release_region(ports->port, REGION_SIZE); } temp_async = ports->next_port; kfree(ports); ports = temp_async; Loading