X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Fcyclades.c;h=cc7acf877dc0ff92c4b55b1d2314ac4f0461e306;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=7ed0e09ceeef9a28c406f0c03c3769cea18ff92c;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 7ed0e09ce..cc7acf877 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -281,7 +281,7 @@ static char rcsid[] = * make sure "cyc" appears in all kernel messages; all soft interrupts * handled by same routine; recognize out-of-band reception; comment * out some diagnostic messages; leave RTS/CTS flow control to hardware; - * fix race condition in -Z buffer management; only -Y needs to explictly + * fix race condition in -Z buffer management; only -Y needs to explicitly * flush chars; tidy up some startup messages; * * Revision 1.36.4.18 1996/07/25 18:57:31 bentson @@ -641,6 +641,7 @@ static char rcsid[] = #include #include #include +#include #include #include #include @@ -652,12 +653,12 @@ static char rcsid[] = #include #include #include +#include #include #include #include #include -#include #define CY_LOCK(info,flags) \ do { \ @@ -676,39 +677,23 @@ static char rcsid[] = #include #include -#define cy_put_user put_user - static void cy_throttle (struct tty_struct *tty); static void cy_send_xchar (struct tty_struct *tty, char ch); -static unsigned long -cy_get_user(unsigned long *addr) -{ - unsigned long result = 0; - int error = get_user (result, addr); - if (error) - printk ("cyclades: cy_get_user: error == %d\n", error); - return result; -} - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - #define IS_CYC_Z(card) ((card).num_chips == -1) #define Z_FPGA_CHECK(card) \ - ((cy_readl(&((struct RUNTIME_9060 *) \ + ((cy_readl(&((struct RUNTIME_9060 __iomem *) \ ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) -#define ISZLOADED(card) (((ZO_V1==cy_readl(&((struct RUNTIME_9060 *) \ +#define ISZLOADED(card) (((ZO_V1==cy_readl(&((struct RUNTIME_9060 __iomem *) \ ((card).ctl_addr))->mail_box_0)) || \ Z_FPGA_CHECK(card)) && \ - (ZFIRM_ID==cy_readl(&((struct FIRM_ID *) \ + (ZFIRM_ID==cy_readl(&((struct FIRM_ID __iomem *) \ ((card).base_addr+ID_ADDRESS))->signature))) #ifndef SERIAL_XMIT_SIZE -#define SERIAL_XMIT_SIZE (MIN(PAGE_SIZE, 4096)) +#define SERIAL_XMIT_SIZE (min(PAGE_SIZE, 4096)) #endif #define WAKEUP_CHARS 256 @@ -728,25 +713,25 @@ static struct tty_driver *cy_serial_driver; boot options line. The form is "cyclades=address,address..." */ -static unsigned char *cy_isa_addresses[] = { - (unsigned char *) 0xD0000, - (unsigned char *) 0xD2000, - (unsigned char *) 0xD4000, - (unsigned char *) 0xD6000, - (unsigned char *) 0xD8000, - (unsigned char *) 0xDA000, - (unsigned char *) 0xDC000, - (unsigned char *) 0xDE000, +static unsigned int cy_isa_addresses[] = { + 0xD0000, + 0xD2000, + 0xD4000, + 0xD6000, + 0xD8000, + 0xDA000, + 0xDC000, + 0xDE000, 0,0,0,0,0,0,0,0 }; -#define NR_ISA_ADDRS (sizeof(cy_isa_addresses)/sizeof(unsigned char*)) +#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) #ifdef MODULE static long maddr[NR_CARDS] = { 0, }; static int irq[NR_CARDS] = { 0, }; -MODULE_PARM(maddr, "1-" __MODULE_STRING(NR_CARDS) "l"); -MODULE_PARM(irq, "1-" __MODULE_STRING(NR_CARDS) "i"); +module_param_array(maddr, long, NULL, 0); +module_param_array(irq, int, NULL, 0); #endif #endif /* CONFIG_ISA */ @@ -774,7 +759,6 @@ static int cy_next_channel; /* next minor available */ * allocated when the first cy_open occurs. */ static unsigned char *tmp_buf; -DECLARE_MUTEX(tmp_buf_sem); /* * This is used to look up the divisor speeds and the timeouts @@ -870,7 +854,7 @@ static void cy_start(struct tty_struct *); static void set_line_char(struct cyclades_port *); static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong); #ifdef CONFIG_ISA -static unsigned detect_isa_irq (volatile ucchar *); +static unsigned detect_isa_irq(void __iomem *); #endif /* CONFIG_ISA */ static int cyclades_get_proc_info(char *, char **, off_t , int , int *, void *); @@ -882,7 +866,7 @@ static void cyz_poll(unsigned long); static long cyz_polling_cycle = CZ_DEF_POLL; static int cyz_timeron = 0; -static struct timer_list cyz_timerlist = TIMER_INITIALIZER(cyz_poll, 0, 0); +static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0); #else /* CONFIG_CYZ_INTR */ static void cyz_rx_restart(unsigned long); @@ -986,10 +970,7 @@ do_softint(void *private_) wake_up_interruptible(&info->delta_msr_wait); } if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) { - if((tty->flags & (1<< TTY_DO_WRITE_WAKEUP)) - && tty->ldisc.write_wakeup){ - (tty->ldisc.write_wakeup)(tty); - } + tty_wakeup(tty); wake_up_interruptible(&tty->write_wait); } #ifdef Z_WAKE @@ -1011,7 +992,7 @@ do_softint(void *private_) This function is only called from inside spinlock-protected code. */ static int -cyy_issue_cmd(volatile ucchar *base_addr, u_char cmd, int index) +cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index) { volatile int i; @@ -1027,7 +1008,7 @@ cyy_issue_cmd(volatile ucchar *base_addr, u_char cmd, int index) if (i == 100) return (-1); /* Issue the new command */ - cy_writeb((u_long)base_addr+(CyCCR< 0)? irq : 0; @@ -1095,7 +1076,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) int status; struct cyclades_card *cinfo; struct cyclades_port *info; - volatile unsigned char *base_addr, *card_base_addr; + void __iomem *base_addr, *card_base_addr; int chip; int save_xir, channel, save_car; char data; @@ -1106,7 +1087,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) int had_work; int mdm_change; int mdm_status; - + int len; if((cinfo = (struct cyclades_card *)dev_id) == 0){ #ifdef CY_DEBUG_INTERRUPTS printk("cyy_interrupt: spurious interrupt %d\n\r", irq); @@ -1114,7 +1095,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_NONE; /* spurious interrupt */ } - card_base_addr = (unsigned char *)cinfo->base_addr; + card_base_addr = cinfo->base_addr; index = cinfo->bus_index; @@ -1126,8 +1107,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) do{ had_work = 0; for ( chip = 0 ; chip < cinfo->num_chips ; chip ++) { - base_addr = (unsigned char *) - (cinfo->base_addr + (cy_chip_offset[chip]<base_addr + (cy_chip_offset[chip]<last_active = jiffies; save_car = cy_readb(base_addr+(CyCAR<tty == 0){ @@ -1184,63 +1164,43 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) info->icount.rx++; continue; } - if (tty->flip.count < TTY_FLIPBUF_SIZE){ - tty->flip.count++; + if (tty_buffer_request_room(tty, 1)) { if (data & info->read_status_mask){ if(data & CyBREAK){ - *tty->flip.flag_buf_ptr++ = - TTY_BREAK; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; if (info->flags & ASYNC_SAK){ do_SAK(tty); } }else if(data & CyFRAME){ - *tty->flip.flag_buf_ptr++ = - TTY_FRAME; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.frame_errs++; }else if(data & CyPARITY){ - *tty->flip.flag_buf_ptr++ = - TTY_PARITY; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.parity_errs++; }else if(data & CyOVERRUN){ - *tty->flip.flag_buf_ptr++ = - TTY_OVERRUN; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); info->icount.rx++; /* If the flip buffer itself is overflowing, we still lose the next incoming character. */ - if(tty->flip.count - < TTY_FLIPBUF_SIZE){ - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = - TTY_NORMAL; - *tty->flip.char_buf_ptr++ = - cy_readb(base_addr+(CyRDSR<icount.rx++; - } + tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<icount.rx++; info->idle_stats.overruns++; /* These two conditions may imply */ /* a normal read should be done. */ /* }else if(data & CyTIMEOUT){ */ /* }else if(data & CySPECHAR){ */ - }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; - info->icount.rx++; + }else { + tty_insert_flip_char(tty, 0, TTY_NORMAL); + info->icount.rx++; } }else{ - *tty->flip.flag_buf_ptr++ = 0; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_NORMAL); info->icount.rx++; } }else{ @@ -1261,14 +1221,10 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) info->mon.char_max = char_count; info->mon.char_last = char_count; #endif - while(char_count--){ - if (tty->flip.count >= TTY_FLIPBUF_SIZE){ - break; - } - tty->flip.count++; + len = tty_buffer_request_room(tty, char_count); + while(len--){ data = cy_readb(base_addr+(CyRDSR<flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; #ifdef CY_16Y_HACK @@ -1277,11 +1233,11 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) } info->idle_stats.recv_idle = jiffies; } - schedule_delayed_work(&tty->flip.work, 1); + tty_schedule_flip(tty); } /* end of service */ - cy_writeb((u_long)base_addr+(CyRIR<card_lock); } @@ -1300,18 +1256,18 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) channel = (u_short ) (save_xir & CyIRChannel); i = channel + chip * 4 + cinfo->first_line; save_car = cy_readb(base_addr+(CyCAR<last_active = jiffies; if(info->tty == 0){ - cy_writeb((u_long)base_addr+(CySRER<x_char) { /* send special char */ outch = info->x_char; - cy_writeb((u_long)base_addr+(CyTDR<icount.tx++; info->x_char = 0; @@ -1329,14 +1285,14 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (info->breakon || info->breakoff) { if (info->breakon) { - cy_writeb((u_long)base_addr + (CyTDR<breakon = 0; char_count -= 2; } if (info->breakoff) { - cy_writeb((u_long)base_addr + (CyTDR<breakoff = 0; char_count -= 2; } @@ -1345,11 +1301,11 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) while (char_count-- > 0){ if (!info->xmit_cnt){ if (cy_readb(base_addr+(CySRER<xmit_buf == 0){ - cy_writeb((u_long)base_addr+(CySRER<tty->stopped || info->tty->hw_stopped){ - cy_writeb((u_long)base_addr+(CySRER<xmit_cnt--; info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); - cy_writeb((u_long)base_addr+(CyTDR<icount.tx++; }else{ if(char_count > 1){ info->xmit_cnt--; info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); - cy_writeb((u_long)base_addr+(CyTDR<icount.tx++; char_count--; }else{ @@ -1407,9 +1363,9 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) } txend: /* end of service */ - cy_writeb((u_long)base_addr+(CyTIR<card_lock); } @@ -1423,7 +1379,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) + cinfo->first_line]; info->last_active = jiffies; save_car = cy_readb(base_addr+(CyCAR<tty->hw_stopped = 0; - cy_writeb((u_long)base_addr+(CySRER<tty->hw_stopped = 1; - cy_writeb((u_long)base_addr+(CySRER<card_lock); } } /* end while status != 0 */ @@ -1492,7 +1448,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* clear interrupts */ spin_lock(&cinfo->card_lock); - cy_writeb((u_long)card_base_addr + (Cy_ClrIntr<card_lock); return IRQ_HANDLED; @@ -1507,27 +1463,25 @@ static int cyz_fetch_msg( struct cyclades_card *cinfo, uclong *channel, ucchar *cmd, uclong *param) { - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; unsigned long loc_doorbell; - firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS); + firm_id = cinfo->base_addr + ID_ADDRESS; if (!ISZLOADED(*cinfo)){ return (-1); } - zfw_ctrl = (struct ZFW_CTRL *) - (cinfo->base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; - loc_doorbell = cy_readl(&((struct RUNTIME_9060 *) + loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->loc_doorbell); if (loc_doorbell){ *cmd = (char)(0xff & loc_doorbell); *channel = cy_readl(&board_ctrl->fwcmd_channel); *param = (uclong)cy_readl(&board_ctrl->fwcmd_param); - cy_writel(&((struct RUNTIME_9060 *)(cinfo->ctl_addr))->loc_doorbell, + cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->loc_doorbell, 0xffffffff); return 1; } @@ -1538,44 +1492,43 @@ static int cyz_issue_cmd( struct cyclades_card *cinfo, uclong channel, ucchar cmd, uclong param) { - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; - volatile uclong *pci_doorbell; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; + unsigned long __iomem *pci_doorbell; int index; - firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS); + firm_id = cinfo->base_addr + ID_ADDRESS; if (!ISZLOADED(*cinfo)){ return (-1); } - zfw_ctrl = (struct ZFW_CTRL *) - (cinfo->base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; index = 0; - pci_doorbell = (uclong *)(&((struct RUNTIME_9060 *) - (cinfo->ctl_addr))->pci_doorbell); + pci_doorbell = &((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->pci_doorbell; while( (cy_readl(pci_doorbell) & 0xff) != 0){ if (index++ == 1000){ return((int)(cy_readl(pci_doorbell) & 0xff)); } udelay(50L); } - cy_writel((u_long)&board_ctrl->hcmd_channel, channel); - cy_writel((u_long)&board_ctrl->hcmd_param , param); - cy_writel((u_long)pci_doorbell, (long)cmd); + cy_writel(&board_ctrl->hcmd_channel, channel); + cy_writel(&board_ctrl->hcmd_param , param); + cy_writel(pci_doorbell, (long)cmd); return(0); } /* cyz_issue_cmd */ static void -cyz_handle_rx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, - volatile struct BUF_CTRL *buf_ctrl) +cyz_handle_rx(struct cyclades_port *info, + volatile struct CH_CTRL __iomem *ch_ctrl, + volatile struct BUF_CTRL __iomem *buf_ctrl) { struct cyclades_card *cinfo = &cy_card[info->card]; struct tty_struct *tty = info->tty; volatile int char_count; + int len; #ifdef BLOCKMOVE int small_count; #else @@ -1631,18 +1584,11 @@ cyz_handle_rx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, tty->flip.count += small_count; } #else - while(char_count--){ - if (tty->flip.count >= N_TTY_BUF_SIZE - tty->read_cnt) - break; - - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - + len = tty_buffer_request_room(tty, char_count); + while(len--){ data = cy_readb(cinfo->base_addr + rx_bufaddr + new_rx_get); new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1); - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_NORMAL; - *tty->flip.char_buf_ptr++ = data; + tty_insert_flip_char(tty, data, TTY_NORMAL); info->idle_stats.recv_bytes++; info->icount.rx++; } @@ -1660,7 +1606,7 @@ cyz_handle_rx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, } #endif info->idle_stats.recv_idle = jiffies; - schedule_delayed_work(&tty->flip.work, 1); + tty_schedule_flip(tty); } /* Update rx_get */ cy_writel(&buf_ctrl->rx_get, new_rx_get); @@ -1668,8 +1614,9 @@ cyz_handle_rx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, } static void -cyz_handle_tx(struct cyclades_port *info, volatile struct CH_CTRL *ch_ctrl, - volatile struct BUF_CTRL *buf_ctrl) +cyz_handle_tx(struct cyclades_port *info, + volatile struct CH_CTRL __iomem *ch_ctrl, + volatile struct BUF_CTRL __iomem *buf_ctrl) { struct cyclades_card *cinfo = &cy_card[info->card]; struct tty_struct *tty = info->tty; @@ -1756,11 +1703,11 @@ cyz_handle_cmd(struct cyclades_card *cinfo) { struct tty_struct *tty; struct cyclades_port *info; - static volatile struct FIRM_ID *firm_id; - static volatile struct ZFW_CTRL *zfw_ctrl; - static volatile struct BOARD_CTRL *board_ctrl; - static volatile struct CH_CTRL *ch_ctrl; - static volatile struct BUF_CTRL *buf_ctrl; + static volatile struct FIRM_ID __iomem *firm_id; + static volatile struct ZFW_CTRL __iomem *zfw_ctrl; + static volatile struct BOARD_CTRL __iomem *board_ctrl; + static volatile struct CH_CTRL __iomem *ch_ctrl; + static volatile struct BUF_CTRL __iomem *buf_ctrl; uclong channel; ucchar cmd; uclong param; @@ -1768,13 +1715,11 @@ cyz_handle_cmd(struct cyclades_card *cinfo) int special_count; int delta_count; - firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS); - zfw_ctrl = (struct ZFW_CTRL *) - (cinfo->base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); - board_ctrl = &(zfw_ctrl->board_ctrl); + firm_id = cinfo->base_addr + ID_ADDRESS; + zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); + board_ctrl = &zfw_ctrl->board_ctrl; fw_ver = cy_readl(&board_ctrl->fw_version); - hw_ver = cy_readl(&((struct RUNTIME_9060 *)(cinfo->ctl_addr))->mail_box_0); + hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->mail_box_0); while(cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) { @@ -1789,23 +1734,17 @@ cyz_handle_cmd(struct cyclades_card *cinfo) switch(cmd) { case C_CM_PR_ERROR: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_PARITY; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_PARITY); info->icount.rx++; special_count++; break; case C_CM_FR_ERROR: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_FRAME; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_FRAME); info->icount.rx++; special_count++; break; case C_CM_RXBRK: - tty->flip.count++; - *tty->flip.flag_buf_ptr++ = TTY_BREAK; - *tty->flip.char_buf_ptr++ = 0; + tty_insert_flip_char(tty, 0, TTY_BREAK); info->icount.rx++; special_count++; break; @@ -1870,7 +1809,7 @@ cyz_handle_cmd(struct cyclades_card *cinfo) if(delta_count) cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); if(special_count) - schedule_delayed_work(&tty->flip.work, 1); + tty_schedule_flip(tty); } } @@ -1941,10 +1880,8 @@ cyz_poll(unsigned long arg) if (!IS_CYC_Z(*cinfo)) continue; if (!ISZLOADED(*cinfo)) continue; - firm_id = (struct FIRM_ID *)(cinfo->base_addr + ID_ADDRESS); - zfw_ctrl = (struct ZFW_CTRL *) - (cinfo->base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + firm_id = cinfo->base_addr + ID_ADDRESS; + zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &(zfw_ctrl->board_ctrl); /* Skip first polling cycle to avoid racing conditions with the FW */ @@ -1988,7 +1925,7 @@ startup(struct cyclades_port * info) { unsigned long flags; int retval = 0; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; unsigned long page; @@ -2027,8 +1964,7 @@ startup(struct cyclades_port * info) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr + (cy_chip_offset[chip]<default_timeout + cy_writeb(base_addr+(CyRTPR<default_timeout ? info->default_timeout : 0x02)); /* 10ms rx timeout */ cyy_issue_cmd(base_addr,CyCHAN_CTL|CyENB_RCVR|CyENB_XMTR,index); - cy_writeb((ulong)base_addr+(CyCAR<flags |= ASYNC_INITIALIZED; @@ -2072,22 +2008,20 @@ startup(struct cyclades_port * info) CY_UNLOCK(info, flags); } else { - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; - struct CH_CTRL *ch_ctrl; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; + struct CH_CTRL __iomem *ch_ctrl; int retval; - base_addr = (unsigned char*) (cy_card[card].base_addr); + base_addr = cy_card[card].base_addr; - firm_id = (struct FIRM_ID *) (base_addr + ID_ADDRESS); + firm_id = base_addr + ID_ADDRESS; if (!ISZLOADED(cy_card[card])){ return -ENODEV; } - zfw_ctrl = (struct ZFW_CTRL *) - (cy_card[card].base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; @@ -2179,7 +2113,7 @@ static void start_xmit( struct cyclades_port *info ) { unsigned long flags; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; card = info->card; @@ -2188,13 +2122,11 @@ start_xmit( struct cyclades_port *info ) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<flags & ASYNC_INITIALIZED)){ @@ -2235,9 +2167,7 @@ shutdown(struct cyclades_port * info) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<xmit_buf){ unsigned char * temp; temp = info->xmit_buf; - info->xmit_buf = 0; + info->xmit_buf = NULL; free_page((unsigned long) temp); } - cy_writeb((u_long)base_addr+(CyCAR<tty || (info->tty->termios->c_cflag & HUPCL)) { - cy_writeb((u_long)base_addr+(CyMSVR1<flags &= ~ASYNC_INITIALIZED; CY_UNLOCK(info, flags); } else { - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; - struct CH_CTRL *ch_ctrl; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; + struct CH_CTRL __iomem *ch_ctrl; int retval; - base_addr = (unsigned char*) (cy_card[card].base_addr); + base_addr = cy_card[card].base_addr; #ifdef CY_DEBUG_OPEN printk("cyc shutdown Z card %d, channel %d, base_addr %lx\n", card, channel, (long)base_addr); #endif - firm_id = (struct FIRM_ID *) (base_addr + ID_ADDRESS); + firm_id = base_addr + ID_ADDRESS; if (!ISZLOADED(cy_card[card])) { return; } - zfw_ctrl = (struct ZFW_CTRL *) - (cy_card[card].base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); - board_ctrl = &(zfw_ctrl->board_ctrl); + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); + board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; CY_LOCK(info, flags); @@ -2304,12 +2232,12 @@ shutdown(struct cyclades_port * info) if (info->xmit_buf){ unsigned char * temp; temp = info->xmit_buf; - info->xmit_buf = 0; + info->xmit_buf = NULL; free_page((unsigned long) temp); } if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { - cy_writel((u_long)&ch_ctrl[channel].rs_control, + cy_writel(&ch_ctrl[channel].rs_control, (uclong)(cy_readl(&ch_ctrl[channel].rs_control) & ~(C_RS_RTS | C_RS_DTR))); retval = cyz_issue_cmd(&cy_card[info->card], @@ -2353,7 +2281,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp, unsigned long flags; int chip, channel,index; int retval; - char *base_addr; + void __iomem *base_addr; cinfo = &cy_card[info->card]; channel = info->line - cinfo->first_line; @@ -2406,15 +2334,14 @@ block_til_ready(struct tty_struct *tty, struct file * filp, chip = channel>>2; channel &= 0x03; index = cinfo->bus_index; - base_addr = (char *)(cinfo->base_addr - + (cy_chip_offset[chip]<base_addr + (cy_chip_offset[chip]<termios->c_cflag & CBAUD)){ - cy_writeb((u_long)base_addr+(CyCAR<flags & ASYNC_CLOSING) && (C_CLOCAL(tty) || (cy_readb(base_addr+(CyMSVR1<base_addr); - firm_id = (struct FIRM_ID *) - (base_addr + ID_ADDRESS); + base_addr = cinfo->base_addr; + firm_id = base_addr + ID_ADDRESS; if (!ISZLOADED(*cinfo)){ current->state = TASK_RUNNING; remove_wait_queue(&info->open_wait, &wait); return -EINVAL; } - zfw_ctrl = (struct ZFW_CTRL *) - (base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; @@ -2559,11 +2484,10 @@ cy_open(struct tty_struct *tty, struct file * filp) */ if (IS_CYC_Z(cy_card[info->card])) { struct cyclades_card *cinfo = &cy_card[info->card]; - struct FIRM_ID *firm_id = (struct FIRM_ID *) - (cinfo->base_addr + ID_ADDRESS); + struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; if (!ISZLOADED(*cinfo)) { - if (((ZE_V1 ==cy_readl(&((struct RUNTIME_9060 *) + if (((ZE_V1 ==cy_readl(&((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->mail_box_0)) && Z_FPGA_CHECK (*cinfo)) && (ZFIRM_HLT == cy_readl (&firm_id->signature))) @@ -2580,12 +2504,10 @@ cy_open(struct tty_struct *tty, struct file * filp) interrupts should be enabled as soon as the first open happens to one of its ports. */ if (!cinfo->intr_enabled) { - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; - zfw_ctrl = (struct ZFW_CTRL *) - (cinfo->base_addr + - (cy_readl (&firm_id->zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cinfo->base_addr + (cy_readl (&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; @@ -2677,10 +2599,10 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout) { struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; unsigned long orig_jiffies; - signed long char_time; + int char_time; if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent")) return; @@ -2705,7 +2627,7 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) if (timeout < 0) timeout = 0; if (timeout) - char_time = MIN(char_time, timeout); + char_time = min(char_time, timeout); /* * If the transmitter hasn't cleared in twice the approximate * amount of time to send the entire FIFO, it probably won't @@ -2727,26 +2649,21 @@ cy_wait_until_sent(struct tty_struct *tty, int timeout) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char *) - (cy_card[card].base_addr + (cy_chip_offset[chip]<state = TASK_INTERRUPTIBLE; - schedule_timeout(char_time); - if (signal_pending(current)) + if (msleep_interruptible(jiffies_to_msecs(char_time))) break; if (timeout && time_after(jiffies, orig_jiffies + timeout)) break; } - current->state = TASK_RUNNING; } else { // Nothing to do! } /* Run one more char cycle */ - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(char_time * 5); + msleep_interruptible(jiffies_to_msecs(char_time * 5)); #ifdef CY_DEBUG_WAIT_UNTIL_SENT printk("Clean (jiff=%lu)...done\n", jiffies); #endif @@ -2821,13 +2738,11 @@ cy_close(struct tty_struct *tty, struct file *filp) if (!IS_CYC_Z(cy_card[info->card])) { int channel = info->line - cy_card[info->card].first_line; int index = cy_card[info->card].bus_index; - unsigned char *base_addr = (unsigned char *) - (cy_card[info->card].base_addr + - (cy_chip_offset[channel>>2] <card].base_addr + (cy_chip_offset[channel>>2] << index); /* Stop accepting input */ channel &= 0x03; - cy_writeb((ulong)base_addr+(CyCAR<flags & ASYNC_INITIALIZED) { /* Waiting for on-board buffers to be empty before closing @@ -2839,12 +2754,10 @@ cy_close(struct tty_struct *tty, struct file *filp) } else { #ifdef Z_WAKE /* Waiting for on-board buffers to be empty before closing the port */ - unsigned char *base_addr = (unsigned char *) - cy_card[info->card].base_addr; - struct FIRM_ID *firm_id = (struct FIRM_ID *) (base_addr + ID_ADDRESS); - struct ZFW_CTRL *zfw_ctrl = (struct ZFW_CTRL *) - (base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); - struct CH_CTRL *ch_ctrl = zfw_ctrl->ch_ctrl; + void __iomem *base_addr = cy_card[info->card].base_addr; + struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; + struct ZFW_CTRL __iomem *zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); + struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl; int channel = info->line - cy_card[info->card].first_line; int retval; @@ -2866,18 +2779,16 @@ cy_close(struct tty_struct *tty, struct file *filp) shutdown(info); if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); + tty_ldisc_flush(tty); CY_LOCK(info, flags); tty->closing = 0; info->event = 0; - info->tty = 0; + info->tty = NULL; if (info->blocked_open) { CY_UNLOCK(info, flags); if (info->close_delay) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(info->close_delay); + msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); CY_LOCK(info, flags); @@ -2908,8 +2819,7 @@ cy_close(struct tty_struct *tty, struct file *filp) * */ static int -cy_write(struct tty_struct * tty, int from_user, - const unsigned char *buf, int count) +cy_write(struct tty_struct * tty, const unsigned char *buf, int count) { struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; unsigned long flags; @@ -2927,56 +2837,22 @@ cy_write(struct tty_struct * tty, int from_user, return 0; } - if (from_user) { - down(&tmp_buf_sem); - while (1) { - int c1; - - c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - if (c <= 0) - break; - - c -= copy_from_user(tmp_buf, buf, c); - if (!c) { - if (!ret) { - ret = -EFAULT; - } - break; - } - CY_LOCK(info, flags); - c1 = MIN(c, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); - - if (c1 < c) - c = c1; - memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c); - info->xmit_head = ((info->xmit_head + c) & (SERIAL_XMIT_SIZE-1)); - info->xmit_cnt += c; - CY_UNLOCK(info, flags); - buf += c; - count -= c; - ret += c; - } - up(&tmp_buf_sem); - } else { - CY_LOCK(info, flags); - while (1) { - c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, - SERIAL_XMIT_SIZE - info->xmit_head)); + CY_LOCK(info, flags); + while (1) { + c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1), + (int)(SERIAL_XMIT_SIZE - info->xmit_head))); - if (c <= 0) - break; + if (c <= 0) + break; - memcpy(info->xmit_buf + info->xmit_head, buf, c); - info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); - info->xmit_cnt += c; - buf += c; - count -= c; - ret += c; - } - CY_UNLOCK(info, flags); + memcpy(info->xmit_buf + info->xmit_head, buf, c); + info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); + info->xmit_cnt += c; + buf += c; + count -= c; + ret += c; } + CY_UNLOCK(info, flags); info->idle_stats.xmit_bytes += ret; info->idle_stats.xmit_idle = jiffies; @@ -3104,10 +2980,8 @@ cy_chars_in_buffer(struct tty_struct *tty) int char_count; volatile uclong tx_put, tx_get, tx_bufsize; - firm_id = (struct FIRM_ID *)(cy_card[card].base_addr + ID_ADDRESS); - zfw_ctrl = (struct ZFW_CTRL *) - (cy_card[card].base_addr + - (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff)); + firm_id = cy_card[card].base_addr + ID_ADDRESS; + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); @@ -3167,7 +3041,7 @@ static void set_line_char(struct cyclades_port * info) { unsigned long flags; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; unsigned cflag, iflag; unsigned short chip_number; @@ -3319,76 +3193,74 @@ set_line_char(struct cyclades_port * info) chip = channel>>2; channel &= 0x03; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<tco); - cy_writeb((u_long)base_addr+(CyTBPR<tbpr); - cy_writeb((u_long)base_addr+(CyRCOR<rco); - cy_writeb((u_long)base_addr+(CyRBPR<rbpr); + cy_writeb(base_addr+(CyTCOR<tco); + cy_writeb(base_addr+(CyTBPR<tbpr); + cy_writeb(base_addr+(CyRCOR<rco); + cy_writeb(base_addr+(CyRBPR<rbpr); /* set line characteristics according configuration */ - cy_writeb((u_long)base_addr+(CySCHR1<tty)); - cy_writeb((u_long)base_addr+(CySCHR2<tty)); - cy_writeb((u_long)base_addr+(CyCOR1<cor1); - cy_writeb((u_long)base_addr+(CyCOR2<cor2); - cy_writeb((u_long)base_addr+(CyCOR3<cor3); - cy_writeb((u_long)base_addr+(CyCOR4<cor4); - cy_writeb((u_long)base_addr+(CyCOR5<cor5); + cy_writeb(base_addr+(CyCOR1<cor1); + cy_writeb(base_addr+(CyCOR2<cor2); + cy_writeb(base_addr+(CyCOR3<cor3); + cy_writeb(base_addr+(CyCOR4<cor4); + cy_writeb(base_addr+(CyCOR5<cor5); cyy_issue_cmd(base_addr, CyCOR_CHANGE|CyCOR1ch|CyCOR2ch|CyCOR3ch,index); - cy_writeb((u_long)base_addr+(CyCAR<default_timeout + cy_writeb(base_addr+(CyRTPR<default_timeout ? info->default_timeout : 0x02)); /* 10ms rx timeout */ if (C_CLOCAL(info->tty)) { /* without modem intr */ - cy_writeb((u_long)base_addr+(CySRER<0 modem transitions */ if ((cflag & CRTSCTS) && info->rflow) { - cy_writeb((u_long)base_addr+(CyMCOR1<1 modem transitions */ - cy_writeb((u_long)base_addr+(CyMCOR2<0 modem transitions */ if ((cflag & CRTSCTS) && info->rflow) { - cy_writeb((u_long)base_addr+(CyMCOR1<1 modem transitions */ - cy_writeb((u_long)base_addr+(CyMCOR2<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; @@ -3550,7 +3419,7 @@ set_line_char(struct cyclades_port * info) static int get_serial_info(struct cyclades_port * info, - struct serial_struct * retinfo) + struct serial_struct __user * retinfo) { struct serial_struct tmp; struct cyclades_card *cinfo = &cy_card[info->card]; @@ -3573,7 +3442,7 @@ get_serial_info(struct cyclades_port * info, static int set_serial_info(struct cyclades_port * info, - struct serial_struct * new_info) + struct serial_struct __user * new_info) { struct serial_struct new_serial; struct cyclades_port old_info; @@ -3627,13 +3496,13 @@ check_and_exit: * transmit holding register is empty. This functionality * allows an RS485 driver to be written in user space. */ -static int get_lsr_info(struct cyclades_port *info, unsigned int *value) +static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value) { int card, chip, channel, index; unsigned char status; unsigned int result; unsigned long flags; - unsigned char *base_addr; + void __iomem *base_addr; card = info->card; channel = (info->line) - (cy_card[card].first_line); @@ -3641,8 +3510,7 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int *value) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char *) - (cy_card[card].base_addr + (cy_chip_offset[chip]<driver_data; int card,chip,channel,index; - unsigned char *base_addr; + void __iomem *base_addr; unsigned long flags; unsigned char status; unsigned long lstatus; unsigned int result; - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; - struct CH_CTRL *ch_ctrl; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; + struct CH_CTRL __iomem *ch_ctrl; if (serial_paranoia_check(info, tty->name, __FUNCTION__)) return -ENODEV; @@ -3679,12 +3547,10 @@ cy_tiocmget(struct tty_struct *tty, struct file *file) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; lstatus = cy_readl(&ch_ctrl[channel].rs_status); @@ -3738,12 +3601,12 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, { struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; int card,chip,channel,index; - unsigned char *base_addr; + void __iomem *base_addr; unsigned long flags; - struct FIRM_ID *firm_id; - struct ZFW_CTRL *zfw_ctrl; - struct BOARD_CTRL *board_ctrl; - struct CH_CTRL *ch_ctrl; + struct FIRM_ID __iomem *firm_id; + struct ZFW_CTRL __iomem *zfw_ctrl; + struct BOARD_CTRL __iomem *board_ctrl; + struct CH_CTRL __iomem *ch_ctrl; int retval; if (serial_paranoia_check(info, tty->name, __FUNCTION__)) @@ -3755,37 +3618,35 @@ cy_tiocmset(struct tty_struct *tty, struct file *file, chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR1<zfwctrl_addr) & 0xfffff)); + zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); board_ctrl = &zfw_ctrl->board_ctrl; ch_ctrl = zfw_ctrl->ch_ctrl; @@ -3930,7 +3788,7 @@ cy_break(struct tty_struct *tty, int break_state) } /* cy_break */ static int -get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon) +get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) { if(copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) @@ -3946,7 +3804,7 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon) static int set_threshold(struct cyclades_port * info, unsigned long value) { - unsigned char *base_addr; + void __iomem *base_addr; int card,channel,chip,index; unsigned long flags; @@ -3956,15 +3814,13 @@ set_threshold(struct cyclades_port * info, unsigned long value) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<cor3 &= ~CyREC_FIFO; info->cor3 |= value & CyREC_FIFO; CY_LOCK(info, flags); - cy_writeb((u_long)base_addr+(CyCOR3<cor3); + cy_writeb(base_addr+(CyCOR3<cor3); cyy_issue_cmd(base_addr,CyCOR_CHANGE|CyCOR3ch,index); CY_UNLOCK(info, flags); } else { @@ -3975,9 +3831,9 @@ set_threshold(struct cyclades_port * info, unsigned long value) static int -get_threshold(struct cyclades_port * info, unsigned long *value) +get_threshold(struct cyclades_port * info, unsigned long __user *value) { - unsigned char *base_addr; + void __iomem *base_addr; int card,channel,chip,index; unsigned long tmp; @@ -3987,12 +3843,10 @@ get_threshold(struct cyclades_port * info, unsigned long *value) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<default_threshold,value); + return put_user(info->default_threshold,value); }/* get_default_threshold */ static int set_timeout(struct cyclades_port * info, unsigned long value) { - unsigned char *base_addr; + void __iomem *base_addr; int card,channel,chip,index; unsigned long flags; @@ -4028,12 +3882,10 @@ set_timeout(struct cyclades_port * info, unsigned long value) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<default_timeout,value); + return put_user(info->default_timeout,value); }/* get_default_timeout */ /* @@ -4093,9 +3943,10 @@ cy_ioctl(struct tty_struct *tty, struct file * file, { struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; struct cyclades_icount cprev, cnow; /* kernel counter temps */ - struct serial_icounter_struct *p_cuser; /* user space */ + struct serial_icounter_struct __user *p_cuser; /* user space */ int ret_val = 0; unsigned long flags; + void __user *argp = (void __user *)arg; if (serial_paranoia_check(info, tty->name, "cy_ioctl")) return -ENODEV; @@ -4107,31 +3958,31 @@ cy_ioctl(struct tty_struct *tty, struct file * file, switch (cmd) { case CYGETMON: - ret_val = get_mon_info(info, (struct cyclades_monitor *)arg); + ret_val = get_mon_info(info, argp); break; case CYGETTHRESH: - ret_val = get_threshold(info, (unsigned long *)arg); + ret_val = get_threshold(info, argp); break; case CYSETTHRESH: - ret_val = set_threshold(info, (unsigned long)arg); + ret_val = set_threshold(info, arg); break; case CYGETDEFTHRESH: - ret_val = get_default_threshold(info, (unsigned long *)arg); + ret_val = get_default_threshold(info, argp); break; case CYSETDEFTHRESH: - ret_val = set_default_threshold(info, (unsigned long)arg); + ret_val = set_default_threshold(info, arg); break; case CYGETTIMEOUT: - ret_val = get_timeout(info, (unsigned long *)arg); + ret_val = get_timeout(info, argp); break; case CYSETTIMEOUT: - ret_val = set_timeout(info, (unsigned long)arg); + ret_val = set_timeout(info, arg); break; case CYGETDEFTIMEOUT: - ret_val = get_default_timeout(info, (unsigned long *)arg); + ret_val = get_default_timeout(info, argp); break; case CYSETDEFTIMEOUT: - ret_val = set_default_timeout(info, (unsigned long)arg); + ret_val = set_default_timeout(info, arg); break; case CYSETRFLOW: info->rflow = (int)arg; @@ -4148,7 +3999,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ret_val = info->rtsdtr_inv; break; case CYGETCARDINFO: - if (copy_to_user((void *)arg, (void *)&cy_card[info->card], + if (copy_to_user(argp, &cy_card[info->card], sizeof (struct cyclades_card))) { ret_val = -EFAULT; break; @@ -4175,13 +4026,13 @@ cy_ioctl(struct tty_struct *tty, struct file * file, ret_val = info->closing_wait / (HZ/100); break; case TIOCGSERIAL: - ret_val = get_serial_info(info, (struct serial_struct *) arg); + ret_val = get_serial_info(info, argp); break; case TIOCSSERIAL: - ret_val = set_serial_info(info, (struct serial_struct *) arg); + ret_val = set_serial_info(info, argp); break; case TIOCSERGETLSR: /* Get line status register */ - ret_val = get_lsr_info(info, (unsigned int *) arg); + ret_val = get_lsr_info(info, argp); break; /* * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change @@ -4229,7 +4080,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file, CY_LOCK(info, flags); cnow = info->icount; CY_UNLOCK(info, flags); - p_cuser = (struct serial_icounter_struct *) arg; + p_cuser = argp; ret_val = put_user(cnow.cts, &p_cuser->cts); if (ret_val) return ret_val; ret_val = put_user(cnow.dsr, &p_cuser->dsr); @@ -4344,7 +4195,7 @@ cy_throttle(struct tty_struct * tty) { struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; unsigned long flags; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; #ifdef CY_DEBUG_THROTTLE @@ -4374,16 +4225,14 @@ cy_throttle(struct tty_struct * tty) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<driver_data; unsigned long flags; - unsigned char *base_addr; + void __iomem *base_addr; int card,chip,channel,index; #ifdef CY_DEBUG_THROTTLE @@ -4434,16 +4283,14 @@ cy_unthrottle(struct tty_struct * tty) chip = channel>>2; channel &= 0x03; index = cy_card[card].bus_index; - base_addr = (unsigned char*) - (cy_card[card].base_addr - + (cy_chip_offset[chip]<rtsdtr_inv) { - cy_writeb((u_long)base_addr+(CyMSVR2<driver_data; - unsigned char *base_addr; + void __iomem *base_addr; int chip,channel,index; unsigned long flags; @@ -4480,14 +4327,12 @@ cy_stop(struct tty_struct *tty) index = cinfo->bus_index; chip = channel>>2; channel &= 0x03; - base_addr = (unsigned char*) - (cy_card[info->card].base_addr - + (cy_chip_offset[chip]<card].base_addr + (cy_chip_offset[chip]<driver_data; - unsigned char *base_addr; + void __iomem *base_addr; int chip,channel,index; unsigned long flags; @@ -4520,14 +4365,12 @@ cy_start(struct tty_struct *tty) if (!IS_CYC_Z(*cinfo)) { chip = channel>>2; channel &= 0x03; - base_addr = (unsigned char*) - (cy_card[info->card].base_addr - + (cy_chip_offset[chip]<card].base_addr + (cy_chip_offset[chip]<write_wait); - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) - && tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); } /* cy_flush_buffer */ @@ -4598,7 +4439,7 @@ cy_hangup(struct tty_struct *tty) #ifdef CY_DEBUG_COUNT printk("cyc:cy_hangup (%d): setting count to 0\n", current->pid); #endif - info->tty = 0; + info->tty = NULL; info->flags &= ~ASYNC_NORMAL_ACTIVE; wake_up_interruptible(&info->open_wait); } /* cy_hangup */ @@ -4615,20 +4456,19 @@ cy_hangup(struct tty_struct *tty) /* initialize chips on Cyclom-Y card -- return number of valid chips (which is number of ports/4) */ static unsigned short __init -cyy_init_card(volatile ucchar *true_base_addr,int index) +cyy_init_card(void __iomem *true_base_addr,int index) { unsigned int chip_number; - volatile ucchar* base_addr; + void __iomem *base_addr; - cy_writeb((u_long)true_base_addr+(Cy_HwReset<= CD1400_REV_J){ /* It is a CD1400 rev. J or later */ /* Impossible to reach 5ms with this chip. Changed to 2ms instead (f = 500 Hz). */ - cy_writeb((u_long)base_addr+(CyPPR<mail_box_0); if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { @@ -5052,7 +4891,7 @@ cy_detect_pci(void) } if (mailbox == ZE_V1) { - cy_pci_addr2 = (ulong)ioremap(cy_pci_phys2, CyPCI_Ze_win); + cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ze_win); if (ZeIndex == NR_CARDS) { printk("Cyclades-Ze/PCI found at 0x%lx ", (ulong)cy_pci_phys2); @@ -5070,7 +4909,7 @@ cy_detect_pci(void) i--; continue; } else { - cy_pci_addr2 = (ulong)ioremap(cy_pci_phys2, CyPCI_Zwin); + cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Zwin); } #ifdef CY_PCI_DEBUG @@ -5097,7 +4936,7 @@ cy_detect_pci(void) */ PAUSE if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) - cy_writel((ulong)(cy_pci_addr2+ID_ADDRESS), 0L); + cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L); /* This must be a Cyclades-8Zo/PCI. The extendable version will have a different device_id and will @@ -5187,7 +5026,7 @@ cy_detect_pci(void) Ze_pdev[j] = Ze_pdev[j+1]; } ZeIndex--; - mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 *) + mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) cy_pci_addr0)->mail_box_0); #ifdef CY_PCI_DEBUG printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", @@ -5428,7 +5267,7 @@ cy_init(void) for (i = 0; i < NR_CARDS; i++) { /* base_addr=0 indicates board not found */ - cy_card[i].base_addr = 0; + cy_card[i].base_addr = NULL; } /* the code below is responsible to find the boards. Each different @@ -5450,7 +5289,7 @@ cy_init(void) for (i = 0 ; i < NR_CARDS ; i++) { if (cy_card[i].base_addr == 0) { cy_card[i].first_line = -1; - cy_card[i].ctl_addr = 0; + cy_card[i].ctl_addr = NULL; cy_card[i].irq = 0; cy_card[i].bus_index = 0; cy_card[i].first_line = 0; @@ -5468,7 +5307,7 @@ cy_init(void) cinfo = &cy_card[board]; if (cinfo->num_chips == -1) { /* Cyclades-Z */ number_z_boards++; - mailbox = cy_readl(&((struct RUNTIME_9060 *) + mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *) cy_card[board].ctl_addr)->mail_box_0); nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; cinfo->intr_enabled = 0; @@ -5486,7 +5325,7 @@ cy_init(void) info->line = port; info->chip_rev = 0; info->flags = STD_COM_FLAGS; - info->tty = 0; + info->tty = NULL; if (mailbox == ZO_V1) info->xmit_fifo_size = CYZ_FIFO_SIZE; else @@ -5548,7 +5387,7 @@ cy_init(void) info->card = board; info->line = port; info->flags = STD_COM_FLAGS; - info->tty = 0; + info->tty = NULL; info->xmit_fifo_size = CyMAX_CHAR_FIFO; info->cor1 = CyPARITY_NONE|Cy_1_STOP|Cy_8_BITS; info->cor2 = CyETC; @@ -5638,18 +5477,20 @@ cy_cleanup_module(void) put_tty_driver(cy_serial_driver); for (i = 0; i < NR_CARDS; i++) { - if (cy_card[i].base_addr != 0) { - iounmap((void *)cy_card[i].base_addr); - if (cy_card[i].ctl_addr != 0) - iounmap((void *)cy_card[i].ctl_addr); + if (cy_card[i].base_addr) { + iounmap(cy_card[i].base_addr); + if (cy_card[i].ctl_addr) + iounmap(cy_card[i].ctl_addr); if (cy_card[i].irq #ifndef CONFIG_CYZ_INTR && cy_card[i].num_chips != -1 /* not a Z card */ #endif /* CONFIG_CYZ_INTR */ ) free_irq(cy_card[i].irq, &cy_card[i]); +#ifdef CONFIG_PCI if (cy_card[i].pdev) pci_release_regions(cy_card[i].pdev); +#endif } } if (tmp_buf) { @@ -5661,24 +5502,4 @@ cy_cleanup_module(void) module_init(cy_init); module_exit(cy_cleanup_module); -#ifndef MODULE -/* called by linux/init/main.c to parse command line options */ -void -cy_setup(char *str, int *ints) -{ -#ifdef CONFIG_ISA - int i, j; - - for (i = 0 ; i < NR_ISA_ADDRS ; i++) { - if (cy_isa_addresses[i] == 0) break; - } - for (j = 1; j <= ints[0]; j++){ - if ( i < NR_ISA_ADDRS ){ - cy_isa_addresses[i++] = (unsigned char *)(ints[j]); - } - } -#endif /* CONFIG_ISA */ -} /* cy_setup */ -#endif /* MODULE */ - MODULE_LICENSE("GPL");