From: Paul Fulghum Add new character driver for SyncLink GT and SyncLink AC families of synchronous and asynchronous serial adapters. Signed-off-by: Paul Fulghum Signed-off-by: Andrew Morton --- drivers/char/synclink_gt.c | 624 +++++++++++++++++++++------------------------ include/linux/synclink.h | 4 2 files changed, 301 insertions(+), 327 deletions(-) diff -puN drivers/char/synclink_gt.c~new-char-driver-synclink_gt-2 drivers/char/synclink_gt.c --- devel/drivers/char/synclink_gt.c~new-char-driver-synclink_gt-2 2005-11-09 20:11:01.000000000 -0800 +++ devel-akpm/drivers/char/synclink_gt.c 2005-11-09 20:11:01.000000000 -0800 @@ -1,5 +1,5 @@ /* - * $Id: synclink_gt.c,v 4.13 2005/11/02 18:59:02 paulkf Exp $ + * $Id: synclink_gt.c,v 4.20 2005/11/08 19:51:55 paulkf Exp $ * * Device driver for Microgate SyncLink GT serial adapters. * @@ -93,7 +93,7 @@ * module identification */ static char *driver_name = "SyncLink GT"; -static char *driver_version = "$Revision: 4.13 $"; +static char *driver_version = "$Revision: 4.20 $"; static char *tty_driver_name = "synclink_gt"; static char *tty_dev_prefix = "ttySLG"; MODULE_LICENSE("GPL"); @@ -118,32 +118,29 @@ static struct pci_driver pci_driver = { .remove = __devexit_p(remove_one), }; -static int pci_registered = 0; - -/* - * compatibility and utility macros - */ -#define GET_USER(error,value,addr) error = get_user(value,addr) -#define COPY_FROM_USER(error,dest,src,size) error = copy_from_user(dest,src,size) ? -EFAULT : 0 -#define PUT_USER(error,value,addr) error = put_user(value,addr) -#define COPY_TO_USER(error,dest,src,size) error = copy_to_user(dest,src,size) ? -EFAULT : 0 +static int pci_registered; /* * module configuration and status */ -static struct _slgt_info *slgt_device_list = NULL; -static int slgt_device_count = 0; +static struct slgt_info *slgt_device_list; +static int slgt_device_count; -static int ttymajor=0; -static int debug_level = 0; -static int maxframe[MAX_DEVICES] = {0,}; -static int dosyncppp[MAX_DEVICES] = {0,}; +static int ttymajor; +static int debug_level; +static int maxframe[MAX_DEVICES]; +static int dosyncppp[MAX_DEVICES]; module_param(ttymajor, int, 0); module_param(debug_level, int, 0); module_param_array(maxframe, int, NULL, 0); module_param_array(dosyncppp, int, NULL, 0); +MODULE_PARM_DESC(ttymajor, "TTY major device number override: 0=auto assigned"); +MODULE_PARM_DESC(debug_level, "Debug syslog output: 0=disabled, 1 to 5=increasing detail"); +MODULE_PARM_DESC(maxframe, "Maximum frame size used by device (4096 to 65535)"); +MODULE_PARM_DESC(dosyncppp, "Enable synchronous net device, 0=disable 1=enable"); + /* * tty support and callbacks */ @@ -178,10 +175,10 @@ static void set_break(struct tty_struct */ #ifdef CONFIG_HDLC #define dev_to_port(D) (dev_to_hdlc(D)->priv) -static void hdlcdev_tx_done(struct _slgt_info *info); -static void hdlcdev_rx(struct _slgt_info *info, char *buf, int size); -static int hdlcdev_init(struct _slgt_info *info); -static void hdlcdev_exit(struct _slgt_info *info); +static void hdlcdev_tx_done(struct slgt_info *info); +static void hdlcdev_rx(struct slgt_info *info, char *buf, int size); +static int hdlcdev_init(struct slgt_info *info); +static void hdlcdev_exit(struct slgt_info *info); #endif @@ -195,7 +192,7 @@ static void hdlcdev_exit(struct _slgt_in /* * DMA buffer descriptor and access macros */ -typedef struct +struct slgt_desc { unsigned short count; unsigned short status; @@ -206,7 +203,7 @@ typedef struct char *buf; /* virtual address of data buffer */ unsigned int pdesc; /* physical address of this descriptor */ dma_addr_t buf_dma_addr; -} SLGT_DESC; +}; #define set_desc_buffer(a,b) (a).pbuf = cpu_to_le32((unsigned int)(b)) #define set_desc_next(a,b) (a).next = cpu_to_le32((unsigned int)(b)) @@ -234,10 +231,10 @@ struct _input_signal_events { /* * device instance data structure */ -typedef struct _slgt_info { +struct slgt_info { void *if_ptr; /* General purpose pointer (used by SPPP) */ - struct _slgt_info *next_device; /* device list link */ + struct slgt_info *next_device; /* device list link */ int magic; int flags; @@ -250,7 +247,7 @@ typedef struct _slgt_info { int port_num; /* port instance number */ /* array of pointers to port contexts on this adapter */ - struct _slgt_info *port_array[SLGT_MAX_PORTS]; + struct slgt_info *port_array[SLGT_MAX_PORTS]; int count; /* count of opens */ int line; /* tty line instance number */ @@ -331,12 +328,12 @@ typedef struct _slgt_info { dma_addr_t bufs_dma_addr; /* physical address of buffer descriptors */ unsigned int rbuf_count; - SLGT_DESC *rbufs; + struct slgt_desc *rbufs; unsigned int rbuf_current; unsigned int rbuf_index; unsigned int tbuf_count; - SLGT_DESC *tbufs; + struct slgt_desc *tbufs; unsigned int tbuf_current; unsigned int tbuf_start; @@ -352,22 +349,22 @@ typedef struct _slgt_info { struct net_device *netdev; #endif -} SLGT_INFO; +}; static MGSL_PARAMS default_params = { - MGSL_MODE_HDLC, /* unsigned long mode */ - 0, /* unsigned char loopback; */ - HDLC_FLAG_UNDERRUN_ABORT15, /* unsigned short flags; */ - HDLC_ENCODING_NRZI_SPACE, /* unsigned char encoding; */ - 0, /* unsigned long clock_speed; */ - 0xff, /* unsigned char addr_filter; */ - HDLC_CRC_16_CCITT, /* unsigned short crc_type; */ - HDLC_PREAMBLE_LENGTH_8BITS, /* unsigned char preamble_length; */ - HDLC_PREAMBLE_PATTERN_NONE, /* unsigned char preamble; */ - 9600, /* unsigned long data_rate; */ - 8, /* unsigned char data_bits; */ - 1, /* unsigned char stop_bits; */ - ASYNC_PARITY_NONE /* unsigned char parity; */ + .mode = MGSL_MODE_HDLC, + .loopback = 0, + .flags = HDLC_FLAG_UNDERRUN_ABORT15, + .encoding = HDLC_ENCODING_NRZI_SPACE, + .clock_speed = 0, + .addr_filter = 0xff, + .crc_type = HDLC_CRC_16_CCITT, + .preamble_length = HDLC_PREAMBLE_LENGTH_8BITS, + .preamble = HDLC_PREAMBLE_PATTERN_NONE, + .data_rate = 9600, + .data_bits = 8, + .stop_bits = 1, + .parity = ASYNC_PARITY_NONE }; @@ -422,70 +419,70 @@ static MGSL_PARAMS default_params = { #define slgt_irq_off(info, mask) \ wr_reg16((info), SCR, (unsigned short)(rd_reg16((info), SCR) & ~(mask))) -static __u8 rd_reg8(SLGT_INFO* info, unsigned int addr); -static void wr_reg8(SLGT_INFO* info, unsigned int addr, __u8 value); -static __u16 rd_reg16(SLGT_INFO* info, unsigned int addr); -static void wr_reg16(SLGT_INFO* info, unsigned int addr, __u16 value); -static __u32 rd_reg32(SLGT_INFO* info, unsigned int addr); -static void wr_reg32(SLGT_INFO* info, unsigned int addr, __u32 value); - -static void msc_set_vcr(SLGT_INFO* info); - -static int startup(SLGT_INFO *info); -static int block_til_ready(struct tty_struct *tty, struct file * filp,SLGT_INFO *info); -static void shutdown(SLGT_INFO *info); -static void program_hw(SLGT_INFO *info); -static void change_params(SLGT_INFO *info); - -static int register_test(SLGT_INFO *info); -static int irq_test(SLGT_INFO *info); -static int loopback_test(SLGT_INFO *info); -static int adapter_test(SLGT_INFO *info); - -static void reset_adapter(SLGT_INFO *info); -static void reset_port(SLGT_INFO *info); -static void async_mode(SLGT_INFO *info); -static void hdlc_mode(SLGT_INFO *info); - -static void rx_stop(SLGT_INFO *info); -static void rx_start(SLGT_INFO *info); -static void reset_rbufs(SLGT_INFO *info); -static void free_rbufs(SLGT_INFO *info, unsigned int first, unsigned int last); -static void rdma_reset(SLGT_INFO *info); -static int rx_get_frame(SLGT_INFO *info); -static int rx_get_buf(SLGT_INFO *info); - -static void tx_start(SLGT_INFO *info); -static void tx_stop(SLGT_INFO *info); -static void tx_set_idle(SLGT_INFO *info); -static unsigned int free_tbuf_count(SLGT_INFO *info); -static void reset_tbufs(SLGT_INFO *info); -static void tdma_reset(SLGT_INFO *info); -static void tx_load(SLGT_INFO *info, const char *buf, unsigned int count); - -static void get_signals(SLGT_INFO *info); -static void set_signals(SLGT_INFO *info); -static void enable_loopback(SLGT_INFO *info); -static void set_rate(SLGT_INFO *info, u32 data_rate); +static __u8 rd_reg8(struct slgt_info *info, unsigned int addr); +static void wr_reg8(struct slgt_info *info, unsigned int addr, __u8 value); +static __u16 rd_reg16(struct slgt_info *info, unsigned int addr); +static void wr_reg16(struct slgt_info *info, unsigned int addr, __u16 value); +static __u32 rd_reg32(struct slgt_info *info, unsigned int addr); +static void wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value); + +static void msc_set_vcr(struct slgt_info *info); + +static int startup(struct slgt_info *info); +static int block_til_ready(struct tty_struct *tty, struct file * filp,struct slgt_info *info); +static void shutdown(struct slgt_info *info); +static void program_hw(struct slgt_info *info); +static void change_params(struct slgt_info *info); + +static int register_test(struct slgt_info *info); +static int irq_test(struct slgt_info *info); +static int loopback_test(struct slgt_info *info); +static int adapter_test(struct slgt_info *info); + +static void reset_adapter(struct slgt_info *info); +static void reset_port(struct slgt_info *info); +static void async_mode(struct slgt_info *info); +static void hdlc_mode(struct slgt_info *info); + +static void rx_stop(struct slgt_info *info); +static void rx_start(struct slgt_info *info); +static void reset_rbufs(struct slgt_info *info); +static void free_rbufs(struct slgt_info *info, unsigned int first, unsigned int last); +static void rdma_reset(struct slgt_info *info); +static int rx_get_frame(struct slgt_info *info); +static int rx_get_buf(struct slgt_info *info); + +static void tx_start(struct slgt_info *info); +static void tx_stop(struct slgt_info *info); +static void tx_set_idle(struct slgt_info *info); +static unsigned int free_tbuf_count(struct slgt_info *info); +static void reset_tbufs(struct slgt_info *info); +static void tdma_reset(struct slgt_info *info); +static void tx_load(struct slgt_info *info, const char *buf, unsigned int count); + +static void get_signals(struct slgt_info *info); +static void set_signals(struct slgt_info *info); +static void enable_loopback(struct slgt_info *info); +static void set_rate(struct slgt_info *info, u32 data_rate); -static int bh_action(SLGT_INFO *info); +static int bh_action(struct slgt_info *info); static void bh_handler(void* context); -static void bh_transmit(SLGT_INFO *info); -static void isr_serial(SLGT_INFO *info); -static void isr_rdma(SLGT_INFO *info); -static void isr_txeom(SLGT_INFO * info, unsigned short status); -static void isr_tdma(SLGT_INFO *info); +static void bh_transmit(struct slgt_info *info); +static void isr_serial(struct slgt_info *info); +static void isr_rdma(struct slgt_info *info); +static void isr_txeom(struct slgt_info *info, unsigned short status); +static void isr_tdma(struct slgt_info *info); static irqreturn_t slgt_interrupt(int irq, void *dev_id, struct pt_regs * regs); -static int alloc_dma_bufs(SLGT_INFO *info); -static void free_dma_bufs(SLGT_INFO *info); -static int alloc_desc(SLGT_INFO *info); -static void free_desc(SLGT_INFO *info); -static int alloc_bufs(SLGT_INFO *info, SLGT_DESC *bufs, int count); -static void free_bufs(SLGT_INFO *info, SLGT_DESC *bufs, int count); +static int alloc_dma_bufs(struct slgt_info *info); +static void free_dma_bufs(struct slgt_info *info); +static int alloc_desc(struct slgt_info *info); +static void free_desc(struct slgt_info *info); +static int alloc_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count); +static void free_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count); -static int alloc_tmp_rbuf(SLGT_INFO *info); -static void free_tmp_rbuf(SLGT_INFO *info); +static int alloc_tmp_rbuf(struct slgt_info *info); +static void free_tmp_rbuf(struct slgt_info *info); static void tx_timeout(unsigned long context); static void rx_timeout(unsigned long context); @@ -493,30 +490,30 @@ static void rx_timeout(unsigned long con /* * ioctl handlers */ -static int get_stats(SLGT_INFO *info, struct mgsl_icount __user *user_icount); -static int get_params(SLGT_INFO *info, MGSL_PARAMS __user *params); -static int set_params(SLGT_INFO *info, MGSL_PARAMS __user *params); -static int get_txidle(SLGT_INFO *info, int __user *idle_mode); -static int set_txidle(SLGT_INFO *info, int idle_mode); -static int tx_enable(SLGT_INFO *info, int enable); -static int tx_abort(SLGT_INFO *info); -static int rx_enable(SLGT_INFO *info, int enable); -static int modem_input_wait(SLGT_INFO *info,int arg); -static int wait_mgsl_event(SLGT_INFO *info, int __user *mask_ptr); +static int get_stats(struct slgt_info *info, struct mgsl_icount __user *user_icount); +static int get_params(struct slgt_info *info, MGSL_PARAMS __user *params); +static int set_params(struct slgt_info *info, MGSL_PARAMS __user *params); +static int get_txidle(struct slgt_info *info, int __user *idle_mode); +static int set_txidle(struct slgt_info *info, int idle_mode); +static int tx_enable(struct slgt_info *info, int enable); +static int tx_abort(struct slgt_info *info); +static int rx_enable(struct slgt_info *info, int enable); +static int modem_input_wait(struct slgt_info *info,int arg); +static int wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr); static int tiocmget(struct tty_struct *tty, struct file *file); static int tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static void set_break(struct tty_struct *tty, int break_state); -static int get_interface(SLGT_INFO *info, int __user *if_mode); -static int set_interface(SLGT_INFO *info, int if_mode); +static int get_interface(struct slgt_info *info, int __user *if_mode); +static int set_interface(struct slgt_info *info, int if_mode); /* * driver functions */ -static void add_device(SLGT_INFO *info); +static void add_device(struct slgt_info *info); static void device_init(int adapter_num, struct pci_dev *pdev); -static int claim_resources(SLGT_INFO *info); -static void release_resources(SLGT_INFO *info); +static int claim_resources(struct slgt_info *info); +static void release_resources(struct slgt_info *info); /* * DEBUG OUTPUT CODE @@ -535,7 +532,7 @@ static void release_resources(SLGT_INFO #endif #ifdef DBGDATA -static void trace_block(SLGT_INFO *info, const char *data, int count, const char *label) +static void trace_block(struct slgt_info *info, const char *data, int count, const char *label) { int i; int linecount; @@ -562,7 +559,7 @@ static void trace_block(SLGT_INFO *info, #endif #ifdef DBGTBUF -static void dump_tbufs(SLGT_INFO *info) +static void dump_tbufs(struct slgt_info *info) { int i; printk("tbuf_current=%d\n", info->tbuf_current); @@ -576,7 +573,7 @@ static void dump_tbufs(SLGT_INFO *info) #endif #ifdef DBGRBUF -static void dump_rbufs(SLGT_INFO *info) +static void dump_rbufs(struct slgt_info *info) { int i; printk("rbuf_current=%d\n", info->rbuf_current); @@ -589,15 +586,15 @@ static void dump_rbufs(SLGT_INFO *info) #define DBGRBUF(info) #endif -static inline int sanity_check(SLGT_INFO *info, char *devname, const char *name) +static inline int sanity_check(struct slgt_info *info, char *devname, const char *name) { #ifdef SANITY_CHECK if (!info) { - printk("null SLGT_INFO for (%s) in %s\n", devname, name); + printk("null struct slgt_info for (%s) in %s\n", devname, name); return 1; } if (info->magic != MGSL_MAGIC) { - printk("bad magic number SLGT_INFO (%s) in %s\n", devname, name); + printk("bad magic number struct slgt_info (%s) in %s\n", devname, name); return 1; } #else @@ -633,7 +630,7 @@ static void ldisc_receive_buf(struct tty static int open(struct tty_struct *tty, struct file *filp) { - SLGT_INFO *info; + struct slgt_info *info; int retval, line; unsigned long flags; @@ -707,7 +704,7 @@ cleanup: static void close(struct tty_struct *tty, struct file *filp) { - SLGT_INFO * info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; if (sanity_check(info, tty->name, "close")) return; @@ -779,7 +776,7 @@ cleanup: static void hangup(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; if (sanity_check(info, tty->name, "hangup")) return; @@ -797,7 +794,7 @@ static void hangup(struct tty_struct *tt static void set_termios(struct tty_struct *tty, struct termios *old_termios) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; DBGINFO(("%s set_termios\n", tty->driver->name)); @@ -806,7 +803,7 @@ static void set_termios(struct tty_struc if ((tty->termios->c_cflag == old_termios->c_cflag) && (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) - return; + return; change_params(info); @@ -815,7 +812,7 @@ static void set_termios(struct tty_struc !(tty->termios->c_cflag & CBAUD)) { info->signals &= ~(SerialSignal_RTS + SerialSignal_DTR); spin_lock_irqsave(&info->lock,flags); - set_signals(info); + set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -844,7 +841,7 @@ static int write(struct tty_struct *tty, const unsigned char *buf, int count) { int ret = 0; - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "write")) @@ -899,7 +896,7 @@ cleanup: static void put_char(struct tty_struct *tty, unsigned char ch) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "put_char")) @@ -915,7 +912,7 @@ static void put_char(struct tty_struct * static void send_xchar(struct tty_struct *tty, char ch) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "send_xchar")) @@ -932,7 +929,7 @@ static void send_xchar(struct tty_struct static void wait_until_sent(struct tty_struct *tty, int timeout) { - SLGT_INFO * info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long orig_jiffies, char_time; if (!info ) @@ -975,7 +972,7 @@ exit: static int write_room(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; int ret; if (sanity_check(info, tty->name, "write_room")) @@ -987,7 +984,7 @@ static int write_room(struct tty_struct static void flush_chars(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "flush_chars")) @@ -1010,7 +1007,7 @@ static void flush_chars(struct tty_struc static void flush_buffer(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "flush_buffer")) @@ -1031,7 +1028,7 @@ static void flush_buffer(struct tty_stru */ static void tx_hold(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "tx_hold")) @@ -1048,7 +1045,7 @@ static void tx_hold(struct tty_struct *t */ static void tx_release(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "tx_release")) @@ -1077,8 +1074,7 @@ static void tx_release(struct tty_struct static int ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; - int error; + struct slgt_info *info = tty->driver_data; struct mgsl_icount cnow; /* kernel counter temps */ struct serial_icounter_struct __user *p_cuser; /* user space */ unsigned long flags; @@ -1124,28 +1120,18 @@ static int ioctl(struct tty_struct *tty, cnow = info->icount; spin_unlock_irqrestore(&info->lock,flags); p_cuser = argp; - PUT_USER(error,cnow.cts, &p_cuser->cts); - if (error) return error; - PUT_USER(error,cnow.dsr, &p_cuser->dsr); - if (error) return error; - PUT_USER(error,cnow.rng, &p_cuser->rng); - if (error) return error; - PUT_USER(error,cnow.dcd, &p_cuser->dcd); - if (error) return error; - PUT_USER(error,cnow.rx, &p_cuser->rx); - if (error) return error; - PUT_USER(error,cnow.tx, &p_cuser->tx); - if (error) return error; - PUT_USER(error,cnow.frame, &p_cuser->frame); - if (error) return error; - PUT_USER(error,cnow.overrun, &p_cuser->overrun); - if (error) return error; - PUT_USER(error,cnow.parity, &p_cuser->parity); - if (error) return error; - PUT_USER(error,cnow.brk, &p_cuser->brk); - if (error) return error; - PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun); - if (error) return error; + if (put_user(cnow.cts, &p_cuser->cts) || + put_user(cnow.dsr, &p_cuser->dsr) || + put_user(cnow.rng, &p_cuser->rng) || + put_user(cnow.dcd, &p_cuser->dcd) || + put_user(cnow.rx, &p_cuser->rx) || + put_user(cnow.tx, &p_cuser->tx) || + put_user(cnow.frame, &p_cuser->frame) || + put_user(cnow.overrun, &p_cuser->overrun) || + put_user(cnow.parity, &p_cuser->parity) || + put_user(cnow.brk, &p_cuser->brk) || + put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) + return -EFAULT; return 0; default: return -ENOIOCTLCMD; @@ -1156,19 +1142,19 @@ static int ioctl(struct tty_struct *tty, /* * proc fs support */ -static inline int line_info(char *buf, SLGT_INFO *info) +static inline int line_info(char *buf, struct slgt_info *info) { char stat_buf[30]; int ret; unsigned long flags; ret = sprintf(buf, "%s: IO=%08X IRQ=%d MaxFrameSize=%u\n", - info->device_name, info->phys_reg_addr, - info->irq_level, info->max_frame_size); + info->device_name, info->phys_reg_addr, + info->irq_level, info->max_frame_size); /* output current serial signal states */ spin_lock_irqsave(&info->lock,flags); - get_signals(info); + get_signals(info); spin_unlock_irqrestore(&info->lock,flags); stat_buf[0] = 0; @@ -1188,7 +1174,7 @@ static inline int line_info(char *buf, S if (info->params.mode != MGSL_MODE_ASYNC) { ret += sprintf(buf+ret, "\tHDLC txok:%d rxok:%d", - info->icount.txok, info->icount.rxok); + info->icount.txok, info->icount.rxok); if (info->icount.txunder) ret += sprintf(buf+ret, " txunder:%d", info->icount.txunder); if (info->icount.txabort) @@ -1203,7 +1189,7 @@ static inline int line_info(char *buf, S ret += sprintf(buf+ret, " rxcrc:%d", info->icount.rxcrc); } else { ret += sprintf(buf+ret, "\tASYNC tx:%d rx:%d", - info->icount.tx, info->icount.rx); + info->icount.tx, info->icount.rx); if (info->icount.frame) ret += sprintf(buf+ret, " fe:%d", info->icount.frame); if (info->icount.parity) @@ -1218,8 +1204,8 @@ static inline int line_info(char *buf, S ret += sprintf(buf+ret, " %s\n", stat_buf+1); ret += sprintf(buf+ret, "\ttxactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", - info->tx_active,info->bh_requested,info->bh_running, - info->pending_bh); + info->tx_active,info->bh_requested,info->bh_running, + info->pending_bh); return ret; } @@ -1227,11 +1213,11 @@ static inline int line_info(char *buf, S /* Called to print information about devices */ static int read_proc(char *page, char **start, off_t off, int count, - int *eof, void *data) + int *eof, void *data) { int len = 0, l; off_t begin = 0; - SLGT_INFO *info; + struct slgt_info *info; len += sprintf(page, "synclink_gt driver:%s\n", driver_version); @@ -1261,7 +1247,7 @@ done: */ static int chars_in_buffer(struct tty_struct *tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; if (sanity_check(info, tty->name, "chars_in_buffer")) return 0; DBGINFO(("%s chars_in_buffer()=%d\n", info->device_name, info->tx_count)); @@ -1273,7 +1259,7 @@ static int chars_in_buffer(struct tty_st */ static void throttle(struct tty_struct * tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "throttle")) @@ -1294,7 +1280,7 @@ static void throttle(struct tty_struct * */ static void unthrottle(struct tty_struct * tty) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "unthrottle")) @@ -1320,7 +1306,7 @@ static void unthrottle(struct tty_struct */ static void set_break(struct tty_struct *tty, int break_state) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned short value; unsigned long flags; @@ -1353,7 +1339,7 @@ static void set_break(struct tty_struct static int hdlcdev_attach(struct net_device *dev, unsigned short encoding, unsigned short parity) { - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); unsigned char new_encoding; unsigned short new_crctype; @@ -1401,7 +1387,7 @@ static int hdlcdev_attach(struct net_dev */ static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev) { - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); struct net_device_stats *stats = hdlc_stats(dev); unsigned long flags; @@ -1443,7 +1429,7 @@ static int hdlcdev_xmit(struct sk_buff * */ static int hdlcdev_open(struct net_device *dev) { - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); int rc; unsigned long flags; @@ -1498,7 +1484,7 @@ static int hdlcdev_open(struct net_devic */ static int hdlcdev_close(struct net_device *dev) { - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); unsigned long flags; DBGINFO(("%s hdlcdev_close\n", dev->name)); @@ -1531,7 +1517,7 @@ static int hdlcdev_ioctl(struct net_devi const size_t size = sizeof(sync_serial_settings); sync_serial_settings new_line; sync_serial_settings __user *line = ifr->ifr_settings.ifs_ifsu.sync; - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); unsigned int flags; DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); @@ -1626,7 +1612,7 @@ static int hdlcdev_ioctl(struct net_devi */ static void hdlcdev_tx_timeout(struct net_device *dev) { - SLGT_INFO *info = dev_to_port(dev); + struct slgt_info *info = dev_to_port(dev); struct net_device_stats *stats = hdlc_stats(dev); unsigned long flags; @@ -1648,7 +1634,7 @@ static void hdlcdev_tx_timeout(struct ne * * info pointer to device instance information */ -static void hdlcdev_tx_done(SLGT_INFO *info) +static void hdlcdev_tx_done(struct slgt_info *info) { if (netif_queue_stopped(info->netdev)) netif_wake_queue(info->netdev); @@ -1662,7 +1648,7 @@ static void hdlcdev_tx_done(SLGT_INFO *i * buf pointer to buffer contianing frame data * size count of data bytes in buf */ -static void hdlcdev_rx(SLGT_INFO *info, char *buf, int size) +static void hdlcdev_rx(struct slgt_info *info, char *buf, int size) { struct sk_buff *skb = dev_alloc_skb(size); struct net_device *dev = info->netdev; @@ -1696,7 +1682,7 @@ static void hdlcdev_rx(SLGT_INFO *info, * * returns 0 if success, otherwise error code */ -static int hdlcdev_init(SLGT_INFO *info) +static int hdlcdev_init(struct slgt_info *info) { int rc; struct net_device *dev; @@ -1744,7 +1730,7 @@ static int hdlcdev_init(SLGT_INFO *info) * * info pointer to device instance information */ -static void hdlcdev_exit(SLGT_INFO *info) +static void hdlcdev_exit(struct slgt_info *info) { unregister_hdlc_device(info->netdev); free_netdev(info->netdev); @@ -1756,14 +1742,14 @@ static void hdlcdev_exit(SLGT_INFO *info /* * get async data from rx DMA buffers */ -static void rx_async(SLGT_INFO *info) +static void rx_async(struct slgt_info *info) { struct tty_struct *tty = info->tty; struct mgsl_icount *icount = &info->icount; unsigned int start, end; unsigned char *p; unsigned char status; - SLGT_DESC *bufs = info->rbufs; + struct slgt_desc *bufs = info->rbufs; int i, count; start = end = info->rbuf_current; @@ -1834,7 +1820,7 @@ static void rx_async(SLGT_INFO *info) /* * return next bottom half action to perform */ -static int bh_action(SLGT_INFO *info) +static int bh_action(struct slgt_info *info) { unsigned long flags; int rc; @@ -1867,7 +1853,7 @@ static int bh_action(SLGT_INFO *info) */ static void bh_handler(void* context) { - SLGT_INFO *info = (SLGT_INFO*)context; + struct slgt_info *info = context; int action; if (!info) @@ -1911,7 +1897,7 @@ static void bh_handler(void* context) DBGBH(("%s bh_handler exit\n", info->device_name)); } -static void bh_transmit(SLGT_INFO *info) +static void bh_transmit(struct slgt_info *info) { struct tty_struct *tty = info->tty; @@ -1922,7 +1908,7 @@ static void bh_transmit(SLGT_INFO *info) } } -static void dsr_change(SLGT_INFO *info) +static void dsr_change(struct slgt_info *info) { get_signals(info); DBGISR(("dsr_change %s signals=%04X\n", info->device_name, info->signals)); @@ -1940,7 +1926,7 @@ static void dsr_change(SLGT_INFO *info) info->pending_bh |= BH_STATUS; } -static void cts_change(SLGT_INFO *info) +static void cts_change(struct slgt_info *info) { get_signals(info); DBGISR(("cts_change %s signals=%04X\n", info->device_name, info->signals)); @@ -1973,7 +1959,7 @@ static void cts_change(SLGT_INFO *info) } } -static void dcd_change(SLGT_INFO *info) +static void dcd_change(struct slgt_info *info) { get_signals(info); DBGISR(("dcd_change %s signals=%04X\n", info->device_name, info->signals)); @@ -1984,8 +1970,8 @@ static void dcd_change(SLGT_INFO *info) info->icount.dcd++; if (info->signals & SerialSignal_DCD) { info->input_signal_events.dcd_up++; - } else { - info->input_signal_events.dcd_down++; + } else { + info->input_signal_events.dcd_down++; } #ifdef CONFIG_HDLC if (info->netcount) @@ -2005,7 +1991,7 @@ static void dcd_change(SLGT_INFO *info) } } -static void ri_change(SLGT_INFO *info) +static void ri_change(struct slgt_info *info) { get_signals(info); DBGISR(("ri_change %s signals=%04X\n", info->device_name, info->signals)); @@ -2016,15 +2002,15 @@ static void ri_change(SLGT_INFO *info) info->icount.dcd++; if (info->signals & SerialSignal_RI) { info->input_signal_events.ri_up++; - } else { - info->input_signal_events.ri_down++; + } else { + info->input_signal_events.ri_down++; } wake_up_interruptible(&info->status_event_wait_q); wake_up_interruptible(&info->event_wait_q); info->pending_bh |= BH_STATUS; } -static void isr_serial(SLGT_INFO *info) +static void isr_serial(struct slgt_info *info) { unsigned short status = rd_reg16(info, SSR); @@ -2078,7 +2064,7 @@ static void isr_serial(SLGT_INFO *info) ri_change(info); } -static void isr_rdma(SLGT_INFO *info) +static void isr_rdma(struct slgt_info *info) { unsigned int status = rd_reg32(info, RDCSR); @@ -2104,7 +2090,7 @@ static void isr_rdma(SLGT_INFO *info) info->pending_bh |= BH_RECEIVE; } -static void isr_tdma(SLGT_INFO* info) +static void isr_tdma(struct slgt_info *info) { unsigned int status = rd_reg32(info, TDCSR); @@ -2129,7 +2115,7 @@ static void isr_tdma(SLGT_INFO* info) } } -static void isr_txeom(SLGT_INFO * info, unsigned short status) +static void isr_txeom(struct slgt_info *info, unsigned short status) { DBGISR(("%s txeom status=%04x\n", info->device_name, status)); @@ -2184,13 +2170,13 @@ static void isr_txeom(SLGT_INFO * info, */ static irqreturn_t slgt_interrupt(int irq, void *dev_id, struct pt_regs * regs) { - SLGT_INFO *info; + struct slgt_info *info; unsigned int gsr; unsigned int i; DBGISR(("slgt_interrupt irq=%d entry\n", irq)); - info = (SLGT_INFO *)dev_id; + info = dev_id; if (!info) return IRQ_NONE; @@ -2212,7 +2198,7 @@ static irqreturn_t slgt_interrupt(int ir } for(i=0; i < info->port_count ; i++) { - SLGT_INFO * port = info->port_array[i]; + struct slgt_info *port = info->port_array[i]; if (port && (port->count || port->netcount) && port->pending_bh && !port->bh_running && @@ -2229,7 +2215,7 @@ static irqreturn_t slgt_interrupt(int ir return IRQ_HANDLED; } -static int startup(SLGT_INFO * info) +static int startup(struct slgt_info *info) { DBGINFO(("%s startup\n", info->device_name)); @@ -2237,7 +2223,7 @@ static int startup(SLGT_INFO * info) return 0; if (!info->tx_buf) { - info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL); + info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); if (!info->tx_buf) { DBGERR(("%s can't allocate tx buffer\n", info->device_name)); return -ENOMEM; @@ -2262,7 +2248,7 @@ static int startup(SLGT_INFO * info) /* * called by close() and hangup() to shutdown hardware */ -static void shutdown(SLGT_INFO * info) +static void shutdown(struct slgt_info *info) { unsigned long flags; @@ -2276,13 +2262,11 @@ static void shutdown(SLGT_INFO * info) wake_up_interruptible(&info->status_event_wait_q); wake_up_interruptible(&info->event_wait_q); - del_timer(&info->tx_timer); - del_timer(&info->rx_timer); + del_timer_sync(&info->tx_timer); + del_timer_sync(&info->rx_timer); - if (info->tx_buf) { - kfree(info->tx_buf); - info->tx_buf = NULL; - } + kfree(info->tx_buf); + info->tx_buf = NULL; spin_lock_irqsave(&info->lock,flags); @@ -2304,7 +2288,7 @@ static void shutdown(SLGT_INFO * info) info->flags &= ~ASYNC_INITIALIZED; } -static void program_hw(SLGT_INFO *info) +static void program_hw(struct slgt_info *info) { unsigned long flags; @@ -2340,7 +2324,7 @@ static void program_hw(SLGT_INFO *info) /* * reconfigure adapter based on new parameters */ -static void change_params(SLGT_INFO *info) +static void change_params(struct slgt_info *info) { unsigned cflag; int bits_per_char; @@ -2420,39 +2404,33 @@ static void change_params(SLGT_INFO *inf program_hw(info); } -static int get_stats(SLGT_INFO * info, struct mgsl_icount __user *user_icount) +static int get_stats(struct slgt_info *info, struct mgsl_icount __user *user_icount) { - int err; DBGINFO(("%s get_stats\n", info->device_name)); if (!user_icount) { memset(&info->icount, 0, sizeof(info->icount)); } else { - COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); - if (err) + if (copy_to_user(user_icount, &info->icount, sizeof(struct mgsl_icount))) return -EFAULT; } return 0; } -static int get_params(SLGT_INFO * info, MGSL_PARAMS __user *user_params) +static int get_params(struct slgt_info *info, MGSL_PARAMS __user *user_params) { - int err; DBGINFO(("%s get_params\n", info->device_name)); - COPY_TO_USER(err,user_params, &info->params, sizeof(MGSL_PARAMS)); - if (err) + if (copy_to_user(user_params, &info->params, sizeof(MGSL_PARAMS))) return -EFAULT; return 0; } -static int set_params(SLGT_INFO * info, MGSL_PARAMS __user *new_params) +static int set_params(struct slgt_info *info, MGSL_PARAMS __user *new_params) { unsigned long flags; MGSL_PARAMS tmp_params; - int err; DBGINFO(("%s set_params\n", info->device_name)); - COPY_FROM_USER(err,&tmp_params, new_params, sizeof(MGSL_PARAMS)); - if (err) + if (copy_from_user(&tmp_params, new_params, sizeof(MGSL_PARAMS))) return -EFAULT; spin_lock_irqsave(&info->lock, flags); @@ -2464,17 +2442,15 @@ static int set_params(SLGT_INFO * info, return 0; } -static int get_txidle(SLGT_INFO * info, int __user *idle_mode) +static int get_txidle(struct slgt_info *info, int __user *idle_mode) { - int err; DBGINFO(("%s get_txidle=%d\n", info->device_name, info->idle_mode)); - COPY_TO_USER(err,idle_mode, &info->idle_mode, sizeof(int)); - if (err) + if (put_user(info->idle_mode, idle_mode)) return -EFAULT; return 0; } -static int set_txidle(SLGT_INFO * info, int idle_mode) +static int set_txidle(struct slgt_info *info, int idle_mode) { unsigned long flags; DBGINFO(("%s set_txidle(%d)\n", info->device_name, idle_mode)); @@ -2485,7 +2461,7 @@ static int set_txidle(SLGT_INFO * info, return 0; } -static int tx_enable(SLGT_INFO * info, int enable) +static int tx_enable(struct slgt_info *info, int enable) { unsigned long flags; DBGINFO(("%s tx_enable(%d)\n", info->device_name, enable)); @@ -2504,7 +2480,7 @@ static int tx_enable(SLGT_INFO * info, i /* * abort transmit HDLC frame */ -static int tx_abort(SLGT_INFO * info) +static int tx_abort(struct slgt_info *info) { unsigned long flags; DBGINFO(("%s tx_abort\n", info->device_name)); @@ -2514,7 +2490,7 @@ static int tx_abort(SLGT_INFO * info) return 0; } -static int rx_enable(SLGT_INFO *info, int enable) +static int rx_enable(struct slgt_info *info, int enable) { unsigned long flags; DBGINFO(("%s rx_enable(%d)\n", info->device_name, enable)); @@ -2533,7 +2509,7 @@ static int rx_enable(SLGT_INFO *info, in /* * wait for specified event to occur */ -static int wait_mgsl_event(SLGT_INFO *info, int __user *mask_ptr) +static int wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr) { unsigned long flags; int s; @@ -2544,10 +2520,8 @@ static int wait_mgsl_event(SLGT_INFO *in struct _input_signal_events oldsigs, newsigs; DECLARE_WAITQUEUE(wait, current); - COPY_FROM_USER(rc,&mask, mask_ptr, sizeof(int)); - if (rc) { - return -EFAULT; - } + if (get_user(mask, mask_ptr)) + return -EFAULT; DBGINFO(("%s wait_mgsl_event(%d)\n", info->device_name, mask)); @@ -2645,20 +2619,19 @@ static int wait_mgsl_event(SLGT_INFO *in } exit: if (rc == 0) - PUT_USER(rc, events, mask_ptr); + rc = put_user(events, mask_ptr); return rc; } -static int get_interface(SLGT_INFO *info, int __user *if_mode) +static int get_interface(struct slgt_info *info, int __user *if_mode) { - int err; - DBGINFO(("%s get_interface=%x\n", info->device_name, info->if_mode)); - COPY_TO_USER(err, if_mode, &info->if_mode, sizeof(int)); - return err ? -EFAULT : 0; + if (put_user(info->if_mode, if_mode)) + return -EFAULT; + return 0; } -static int set_interface(SLGT_INFO *info, int if_mode) +static int set_interface(struct slgt_info *info, int if_mode) { unsigned long flags; unsigned char val; @@ -2667,6 +2640,8 @@ static int set_interface(SLGT_INFO *info spin_lock_irqsave(&info->lock,flags); info->if_mode = if_mode; + msc_set_vcr(info); + /* TCR (tx control) 07 1=RTS driver control */ val = rd_reg16(info, TCR); if (info->if_mode & MGSL_INTERFACE_RTS_EN) @@ -2679,7 +2654,7 @@ static int set_interface(SLGT_INFO *info return 0; } -static int modem_input_wait(SLGT_INFO *info,int arg) +static int modem_input_wait(struct slgt_info *info,int arg) { unsigned long flags; int rc; @@ -2734,7 +2709,7 @@ static int modem_input_wait(SLGT_INFO *i */ static int tiocmget(struct tty_struct *tty, struct file *file) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned int result; unsigned long flags; @@ -2763,7 +2738,7 @@ static int tiocmget(struct tty_struct *t static int tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { - SLGT_INFO *info = (SLGT_INFO *)tty->driver_data; + struct slgt_info *info = tty->driver_data; unsigned long flags; DBGINFO(("%s tiocmset(%x,%x)\n", info->device_name, set, clear)); @@ -2787,7 +2762,7 @@ static int tiocmset(struct tty_struct *t * block current process until the device is ready to open */ static int block_til_ready(struct tty_struct *tty, struct file *filp, - SLGT_INFO *info) + struct slgt_info *info) { DECLARE_WAITQUEUE(wait, current); int retval; @@ -2871,7 +2846,7 @@ static int block_til_ready(struct tty_st return retval; } -static int alloc_tmp_rbuf(SLGT_INFO *info) +static int alloc_tmp_rbuf(struct slgt_info *info) { info->tmp_rbuf = kmalloc(info->max_frame_size, GFP_KERNEL); if (info->tmp_rbuf == NULL) @@ -2879,17 +2854,16 @@ static int alloc_tmp_rbuf(SLGT_INFO *inf return 0; } -static void free_tmp_rbuf(SLGT_INFO *info) +static void free_tmp_rbuf(struct slgt_info *info) { - if (info->tmp_rbuf) - kfree(info->tmp_rbuf); + kfree(info->tmp_rbuf); info->tmp_rbuf = NULL; } /* * allocate DMA descriptor lists. */ -static int alloc_desc(SLGT_INFO *info) +static int alloc_desc(struct slgt_info *info) { unsigned int i; unsigned int pbufs; @@ -2901,8 +2875,8 @@ static int alloc_desc(SLGT_INFO *info) memset(info->bufs, 0, DESC_LIST_SIZE); - info->rbufs = (SLGT_DESC*)info->bufs; - info->tbufs = ((SLGT_DESC*)info->bufs) + info->rbuf_count; + info->rbufs = (struct slgt_desc*)info->bufs; + info->tbufs = ((struct slgt_desc*)info->bufs) + info->rbuf_count; pbufs = (unsigned int)info->bufs_dma_addr; @@ -2912,31 +2886,31 @@ static int alloc_desc(SLGT_INFO *info) for (i=0; i < info->rbuf_count; i++) { /* physical address of this descriptor */ - info->rbufs[i].pdesc = pbufs + (i * sizeof(SLGT_DESC)); + info->rbufs[i].pdesc = pbufs + (i * sizeof(struct slgt_desc)); /* physical address of next descriptor */ if (i == info->rbuf_count - 1) info->rbufs[i].next = cpu_to_le32(pbufs); else - info->rbufs[i].next = cpu_to_le32(pbufs + ((i+1) * sizeof(SLGT_DESC))); + info->rbufs[i].next = cpu_to_le32(pbufs + ((i+1) * sizeof(struct slgt_desc))); set_desc_count(info->rbufs[i], DMABUFSIZE); } for (i=0; i < info->tbuf_count; i++) { /* physical address of this descriptor */ - info->tbufs[i].pdesc = pbufs + ((info->rbuf_count + i) * sizeof(SLGT_DESC)); + info->tbufs[i].pdesc = pbufs + ((info->rbuf_count + i) * sizeof(struct slgt_desc)); /* physical address of next descriptor */ if (i == info->tbuf_count - 1) - info->tbufs[i].next = cpu_to_le32(pbufs + info->rbuf_count * sizeof(SLGT_DESC)); + info->tbufs[i].next = cpu_to_le32(pbufs + info->rbuf_count * sizeof(struct slgt_desc)); else - info->tbufs[i].next = cpu_to_le32(pbufs + ((info->rbuf_count + i + 1) * sizeof(SLGT_DESC))); + info->tbufs[i].next = cpu_to_le32(pbufs + ((info->rbuf_count + i + 1) * sizeof(struct slgt_desc))); } return 0; } -static void free_desc(SLGT_INFO *info) +static void free_desc(struct slgt_info *info) { if (info->bufs != NULL) { pci_free_consistent(info->pdev, DESC_LIST_SIZE, info->bufs, info->bufs_dma_addr); @@ -2946,7 +2920,7 @@ static void free_desc(SLGT_INFO *info) } } -static int alloc_bufs(SLGT_INFO *info, SLGT_DESC *bufs, int count) +static int alloc_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count) { int i; for (i=0; i < count; i++) { @@ -2957,7 +2931,7 @@ static int alloc_bufs(SLGT_INFO *info, S return 0; } -static void free_bufs(SLGT_INFO *info, SLGT_DESC *bufs, int count) +static void free_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count) { int i; for (i=0; i < count; i++) { @@ -2968,7 +2942,7 @@ static void free_bufs(SLGT_INFO *info, S } } -static int alloc_dma_bufs(SLGT_INFO *info) +static int alloc_dma_bufs(struct slgt_info *info) { info->rbuf_count = 32; info->tbuf_count = 32; @@ -2984,7 +2958,7 @@ static int alloc_dma_bufs(SLGT_INFO *inf return 0; } -static void free_dma_bufs(SLGT_INFO *info) +static void free_dma_bufs(struct slgt_info *info) { if (info->bufs) { free_bufs(info, info->rbufs, info->rbuf_count); @@ -2994,7 +2968,7 @@ static void free_dma_bufs(SLGT_INFO *inf free_tmp_rbuf(info); } -static int claim_resources(SLGT_INFO *info) +static int claim_resources(struct slgt_info *info) { if (request_mem_region(info->phys_reg_addr, SLGT_REG_SIZE, "synclink_gt") == NULL) { DBGERR(("%s reg addr conflict, addr=%08X\n", @@ -3020,7 +2994,7 @@ errout: return -ENODEV; } -static void release_resources(SLGT_INFO *info) +static void release_resources(struct slgt_info *info) { if (info->irq_requested) { free_irq(info->irq_level, info); @@ -3041,7 +3015,7 @@ static void release_resources(SLGT_INFO /* Add the specified device instance data structure to the * global linked list of devices and increment the device count. */ -static void add_device(SLGT_INFO *info) +static void add_device(struct slgt_info *info) { char *devstr; @@ -3060,7 +3034,7 @@ static void add_device(SLGT_INFO *info) if (!slgt_device_list) slgt_device_list = info; else { - SLGT_INFO *current_dev = slgt_device_list; + struct slgt_info *current_dev = slgt_device_list; while(current_dev->next_device) current_dev = current_dev->next_device; current_dev->next_device = info; @@ -3097,17 +3071,17 @@ static void add_device(SLGT_INFO *info) /* * allocate device instance structure, return NULL on failure */ -static SLGT_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) +static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) { - SLGT_INFO *info; + struct slgt_info *info; - info = (SLGT_INFO *)kmalloc(sizeof(SLGT_INFO), GFP_KERNEL); + info = kmalloc(sizeof(struct slgt_info), GFP_KERNEL); if (!info) { DBGERR(("%s device alloc failed adapter=%d port=%d\n", driver_name, adapter_num, port_num)); } else { - memset(info, 0, sizeof(SLGT_INFO)); + memset(info, 0, sizeof(struct slgt_info)); info->magic = MGSL_MAGIC; INIT_WORK(&info->task, bh_handler, info); info->max_frame_size = 4096; @@ -3154,7 +3128,7 @@ static SLGT_INFO *alloc_dev(int adapter_ static void device_init(int adapter_num, struct pci_dev *pdev) { - SLGT_INFO *port_array[SLGT_MAX_PORTS]; + struct slgt_info *port_array[SLGT_MAX_PORTS]; int i; int port_count = 1; @@ -3252,8 +3226,8 @@ static struct tty_operations ops = { static void slgt_cleanup(void) { int rc; - SLGT_INFO *info; - SLGT_INFO *tmp; + struct slgt_info *info; + struct slgt_info *tmp; printk("unload %s %s\n", driver_name, driver_version); @@ -3365,43 +3339,43 @@ module_exit(slgt_exit); if (addr >= 0x80) \ reg_addr += (info->port_num) * 32; -static __u8 rd_reg8(SLGT_INFO *info, unsigned int addr) +static __u8 rd_reg8(struct slgt_info *info, unsigned int addr) { CALC_REGADDR(); return readb((void __iomem *)reg_addr); } -static void wr_reg8(SLGT_INFO *info, unsigned int addr, __u8 value) +static void wr_reg8(struct slgt_info *info, unsigned int addr, __u8 value) { CALC_REGADDR(); writeb(value, (void __iomem *)reg_addr); } -static __u16 rd_reg16(SLGT_INFO *info, unsigned int addr) +static __u16 rd_reg16(struct slgt_info *info, unsigned int addr) { CALC_REGADDR(); return readw((void __iomem *)reg_addr); } -static void wr_reg16(SLGT_INFO *info, unsigned int addr, __u16 value) +static void wr_reg16(struct slgt_info *info, unsigned int addr, __u16 value) { CALC_REGADDR(); writew(value, (void __iomem *)reg_addr); } -static __u32 rd_reg32(SLGT_INFO *info, unsigned int addr) +static __u32 rd_reg32(struct slgt_info *info, unsigned int addr) { CALC_REGADDR(); return readl((void __iomem *)reg_addr); } -static void wr_reg32(SLGT_INFO *info, unsigned int addr, __u32 value) +static void wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value) { CALC_REGADDR(); writel(value, (void __iomem *)reg_addr); } -static void rdma_reset(SLGT_INFO *info) +static void rdma_reset(struct slgt_info *info) { unsigned int i; @@ -3414,7 +3388,7 @@ static void rdma_reset(SLGT_INFO *info) break; } -static void tdma_reset(SLGT_INFO *info) +static void tdma_reset(struct slgt_info *info) { unsigned int i; @@ -3432,7 +3406,7 @@ static void tdma_reset(SLGT_INFO *info) * TxCLK and RxCLK are generated from BRG * and TxD is looped back to RxD internally. */ -static void enable_loopback(SLGT_INFO *info) +static void enable_loopback(struct slgt_info *info) { /* SCR (serial control) BIT2=looopback enable */ wr_reg16(info, SCR, (unsigned short)(rd_reg16(info, SCR) | BIT2)); @@ -3459,7 +3433,7 @@ static void enable_loopback(SLGT_INFO *i /* * set baud rate generator to specified rate */ -static void set_rate(SLGT_INFO *info, u32 rate) +static void set_rate(struct slgt_info *info, u32 rate) { unsigned int div; static unsigned int osc = 14745600; @@ -3478,7 +3452,7 @@ static void set_rate(SLGT_INFO *info, u3 } } -static void rx_stop(SLGT_INFO *info) +static void rx_stop(struct slgt_info *info) { unsigned short val; @@ -3498,7 +3472,7 @@ static void rx_stop(SLGT_INFO *info) info->rx_restart = 0; } -static void rx_start(SLGT_INFO *info) +static void rx_start(struct slgt_info *info) { unsigned short val; @@ -3535,7 +3509,7 @@ static void rx_start(SLGT_INFO *info) info->rx_enabled = 1; } -static void tx_start(SLGT_INFO *info) +static void tx_start(struct slgt_info *info) { if (!info->tx_enabled) { wr_reg16(info, TCR, @@ -3594,7 +3568,7 @@ static void tx_start(SLGT_INFO *info) } } -static void tx_stop(SLGT_INFO *info) +static void tx_stop(struct slgt_info *info) { unsigned short val; @@ -3618,7 +3592,7 @@ static void tx_stop(SLGT_INFO *info) info->tx_active = 0; } -static void reset_port(SLGT_INFO *info) +static void reset_port(struct slgt_info *info) { if (!info->reg_addr) return; @@ -3632,7 +3606,7 @@ static void reset_port(SLGT_INFO *info) slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); } -static void reset_adapter(SLGT_INFO *info) +static void reset_adapter(struct slgt_info *info) { int i; for (i=0; i < info->port_count; ++i) { @@ -3641,7 +3615,7 @@ static void reset_adapter(SLGT_INFO *inf } } -static void async_mode(SLGT_INFO *info) +static void async_mode(struct slgt_info *info) { unsigned short val; @@ -3775,7 +3749,7 @@ static void async_mode(SLGT_INFO *info) enable_loopback(info); } -static void hdlc_mode(SLGT_INFO *info) +static void hdlc_mode(struct slgt_info *info) { unsigned short val; @@ -3976,7 +3950,7 @@ static void hdlc_mode(SLGT_INFO *info) /* * set transmit idle mode */ -static void tx_set_idle(SLGT_INFO *info) +static void tx_set_idle(struct slgt_info *info) { unsigned char val = 0xff; @@ -3997,7 +3971,7 @@ static void tx_set_idle(SLGT_INFO *info) /* * get state of V24 status (input) signals */ -static void get_signals(SLGT_INFO *info) +static void get_signals(struct slgt_info *info) { unsigned short status = rd_reg16(info, SSR); @@ -4017,9 +3991,9 @@ static void get_signals(SLGT_INFO *info) /* * set V.24 Control Register based on current configuration */ -static void msc_set_vcr(SLGT_INFO* info) +static void msc_set_vcr(struct slgt_info *info) { - unsigned short val = 0; + unsigned char val = 0; /* VCR (V.24 control) * @@ -4030,7 +4004,7 @@ static void msc_set_vcr(SLGT_INFO* info) * 00 RL */ - switch(info->if_mode) + switch(info->if_mode & MGSL_INTERFACE_MASK) { case MGSL_INTERFACE_RS232: val |= BIT5; /* 0010 */ @@ -4041,25 +4015,23 @@ static void msc_set_vcr(SLGT_INFO* info) case MGSL_INTERFACE_RS422: val |= BIT6; /* 0100 */ break; - default: - break; } if (info->signals & SerialSignal_DTR) val |= BIT3; if (info->signals & SerialSignal_RTS) val |= BIT2; -// if (info->options.enable_local_loopback) -// val |= BIT1; -// if (info->options.enable_remote_loopback) -// val |= BIT0; - wr_reg8(info, VCR, (unsigned char)val); + if (info->if_mode & MGSL_INTERFACE_LL) + val |= BIT1; + if (info->if_mode & MGSL_INTERFACE_RL) + val |= BIT0; + wr_reg8(info, VCR, val); } /* * set state of V24 control (output) signals */ -static void set_signals(SLGT_INFO *info) +static void set_signals(struct slgt_info *info) { unsigned char val = rd_reg8(info, VCR); if (info->signals & SerialSignal_DTR) @@ -4076,7 +4048,7 @@ static void set_signals(SLGT_INFO *info) /* * free range of receive DMA buffers (i to last) */ -static void free_rbufs(SLGT_INFO *info, unsigned int i, unsigned int last) +static void free_rbufs(struct slgt_info *info, unsigned int i, unsigned int last) { int done = 0; @@ -4099,7 +4071,7 @@ static void free_rbufs(SLGT_INFO *info, /* * mark all receive DMA buffers as free */ -static void reset_rbufs(SLGT_INFO *info) +static void reset_rbufs(struct slgt_info *info) { free_rbufs(info, 0, info->rbuf_count - 1); } @@ -4109,7 +4081,7 @@ static void reset_rbufs(SLGT_INFO *info) * * return 1 if frame available, otherwise 0 */ -static int rx_get_frame(SLGT_INFO *info) +static int rx_get_frame(struct slgt_info *info) { unsigned int start, end; unsigned short status; @@ -4237,7 +4209,7 @@ cleanup: * pass receive buffer (RAW synchronous mode) to tty layer * return 1 if buffer available, otherwise 0 */ -static int rx_get_buf(SLGT_INFO *info) +static int rx_get_buf(struct slgt_info *info) { unsigned int i = info->rbuf_current; @@ -4251,7 +4223,7 @@ static int rx_get_buf(SLGT_INFO *info) return 1; } -static void reset_tbufs(SLGT_INFO *info) +static void reset_tbufs(struct slgt_info *info) { unsigned int i; info->tbuf_current = 0; @@ -4264,7 +4236,7 @@ static void reset_tbufs(SLGT_INFO *info) /* * return number of free transmit DMA buffers */ -static unsigned int free_tbuf_count(SLGT_INFO *info) +static unsigned int free_tbuf_count(struct slgt_info *info) { unsigned int count = 0; unsigned int i = info->tbuf_current; @@ -4288,11 +4260,11 @@ static unsigned int free_tbuf_count(SLGT /* * load transmit DMA buffer(s) with data */ -static void tx_load(SLGT_INFO *info, const char *buf, unsigned int size) +static void tx_load(struct slgt_info *info, const char *buf, unsigned int size) { unsigned short count; unsigned int i; - SLGT_DESC *d; + struct slgt_desc *d; if (size == 0) return; @@ -4323,7 +4295,7 @@ static void tx_load(SLGT_INFO *info, con info->tbuf_current = i; } -static int register_test(SLGT_INFO *info) +static int register_test(struct slgt_info *info) { static unsigned short patterns[] = {0x0000, 0xffff, 0xaaaa, 0x5555, 0x6969, 0x9696}; @@ -4345,7 +4317,7 @@ static int register_test(SLGT_INFO *info return rc; } -static int irq_test(SLGT_INFO *info) +static int irq_test(struct slgt_info *info) { unsigned long timeout; unsigned long flags; @@ -4387,7 +4359,7 @@ static int irq_test(SLGT_INFO *info) return info->irq_occurred ? 0 : -ENODEV; } -static int loopback_test_rx(SLGT_INFO *info) +static int loopback_test_rx(struct slgt_info *info) { unsigned char *src, *dest; int count; @@ -4411,7 +4383,7 @@ static int loopback_test_rx(SLGT_INFO *i return 0; } -static int loopback_test(SLGT_INFO *info) +static int loopback_test(struct slgt_info *info) { #define TESTFRAMESIZE 20 @@ -4473,7 +4445,7 @@ static int loopback_test(SLGT_INFO *info return rc; } -static int adapter_test(SLGT_INFO *info) +static int adapter_test(struct slgt_info *info) { DBGINFO(("testing %s\n", info->device_name)); if ((info->init_error = register_test(info)) < 0) { @@ -4493,7 +4465,7 @@ static int adapter_test(SLGT_INFO *info) */ static void tx_timeout(unsigned long context) { - SLGT_INFO *info = (SLGT_INFO*)context; + struct slgt_info *info = (struct slgt_info*)context; unsigned long flags; DBGINFO(("%s tx_timeout\n", info->device_name)); @@ -4518,7 +4490,7 @@ static void tx_timeout(unsigned long con */ static void rx_timeout(unsigned long context) { - SLGT_INFO *info = (SLGT_INFO*)context; + struct slgt_info *info = (struct slgt_info*)context; unsigned long flags; DBGINFO(("%s rx_timeout\n", info->device_name)); diff -puN include/linux/synclink.h~new-char-driver-synclink_gt-2 include/linux/synclink.h --- devel/include/linux/synclink.h~new-char-driver-synclink_gt-2 2005-11-09 20:11:01.000000000 -0800 +++ devel-akpm/include/linux/synclink.h 2005-11-09 20:11:01.000000000 -0800 @@ -1,7 +1,7 @@ /* * SyncLink Multiprotocol Serial Adapter Driver * - * $Id: synclink.h,v 3.9 2005/10/28 14:56:16 paulkf Exp $ + * $Id: synclink.h,v 3.10 2005/11/08 19:50:54 paulkf Exp $ * * Copyright (C) 1998-2000 by Microgate Corporation * @@ -134,6 +134,8 @@ #define MGSL_INTERFACE_V35 2 #define MGSL_INTERFACE_RS422 3 #define MGSL_INTERFACE_RTS_EN 0x10 +#define MGSL_INTERFACE_LL 0x20 +#define MGSL_INTERFACE_RL 0x40 typedef struct _MGSL_PARAMS { _