Char: cyclades, remove bottom half processing
PATCH 1/4 Char: cyclades, remove bottom half processing
cyclades, remove bottom half processing
The work done in bottom half doesn't cost much cpu time (e.g. tty_hangup itself schedules its own bottom half), it's possible to do the work in isr directly and save hence some .text.
---
commit 3fc1c2f3f8414d72e12e8d6aed1c36ddb1f19567
tree 071c1c5998332b01ac34ad262b55c2334d6e2392
parent f0d76dfb19957f269687e89a62ba75ecd7339e03
author Jiri Slaby <[email protected]> Sat, 28 Jul 2007 10:32:14 +0200 committer Jiri Slaby <[email protected]> Sat, 28 Jul 2007 10:32:14 +0200
drivers/char/cyclades.c | 111 ++++++++-------------------------------------- include/linux/cyclades.h | 15 ------ 2 files changed, 20 insertions(+), 106 deletions(-)
drivers/char/cyclades.c +20 -91
@@ -897,71 +897,6 @@ static inline int serial_paranoia_check(struct cyclades_port *info,return 0 ; }/* serial_paranoia_check */ -/* -* This routine is used by the interrupt handler to schedule -* processing in the software interrupt portion of the driver -* (also known as the "bottom half"). This can be called any -* number of times for any channel without harm. -*/ -static inline void cy_sched_event (struct cyclades_port *info,int event) -{ - info->event |=1 << event;/* remember what kind of event and who */ -schedule_work (&info->tqueue); -}/* cy_sched_event */ - -/* -* This routine is used to handle the "bottom half" processing for the -* serial driver, known also the "software interrupt" processing. -* This processing is done at the kernel interrupt level, after the -* cy#/_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This -* is where time-consuming activities which can not be done in the -* interrupt driver proper are done; the interrupt driver schedules -* them using cy_sched_event(), and they get done here. -* -* This is done through one level of indirection--the task queue. -* When a hardware interrupt service routine wants service by the -* driver's bottom half, it enqueues the appropriate tq_struct (one -* per port) to the keventd work queue and sets a request flag -* that the work queue be processed. -* -* Although this may seem unwieldy, it gives the system a way to -* pass an argument (in this case the pointer to the cyclades_port -* structure) to the bottom half of the driver. Previous kernels -* had to poll every port to see if that port needed servicing. -*/ -static void -do_softint (struct work_struct *work) -{ -struct cyclades_port *info = - container_of(work, struct cyclades_port, tqueue); -struct tty_struct *tty; - - tty = info->tty; -if (!tty) -return ; - -if (test_and_clear_bit (Cy_EVENT_HANGUP, &info->event)) { -tty_hangup (info->tty); -wake_up_interruptible (&info->open_wait); - info->flags &= ~ASYNC_NORMAL_ACTIVE ; - } -if (test_and_clear_bit (Cy_EVENT_OPEN_WAKEUP, &info->event)) -wake_up_interruptible (&info->open_wait); -#ifdef CONFIG_CYZ_INTR -if (test_and_clear_bit (Cy_EVENT_Z_RX_FULL, &info->event) && - !timer_pending (&cyz_rx_full_timer[info->line])) -mod_timer (&cyz_rx_full_timer[info->line], jiffies +1 ); -#endif -if (test_and_clear_bit (Cy_EVENT_DELTA_WAKEUP, &info->event)) -wake_up_interruptible (&info->delta_msr_wait); -tty_wakeup (tty); -#ifdef Z_WAKE -if (test_and_clear_bit (Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) -complete (&info->shutdown_wait); -#endif -}/* do_softint */ - -/***********************************************************/ /********* Start of block of Cyclom-Y specific code ********/
@@ -1243,7 +1178,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyTxRdy); - goto txdone; + goto txend; }/* load the on-chip space for outbound data */
@@ -1334,9 +1269,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, } txdone: -if (info->xmit_cnt <WAKEUP_CHARS ) { -cy_sched_event (info, Cy_EVENT_WRITE_WAKEUP); - } +tty_wakeup (info->tty); txend:/* end of service */ cy_writeb (base_addr + (CyTIR << index), (save_xir &0x3f ));
@@ -1369,17 +1302,16 @@ txend:if (mdm_change & CyRI) info->icount.rng++; -cy_sched_event (info, Cy_EVENT_DELTA_WAKEUP); +wake_up_interruptible (&info->delta_msr_wait); }if ((mdm_change & CyDCD) && (info->flags &ASYNC_CHECK_CD )) { -if (mdm_status & CyDCD) { -cy_sched_event (info, - Cy_EVENT_OPEN_WAKEUP); - }else { -cy_sched_event (info, Cy_EVENT_HANGUP); +if (!(mdm_status & CyDCD)) { +tty_hangup (info->tty); + info->flags &= ~ASYNC_NORMAL_ACTIVE ; } +wake_up_interruptible (&info->open_wait); }if ((mdm_change & CyCTS) && (info->flags &ASYNC_CTS_FLOW )) {
@@ -1394,8 +1326,7 @@ txend: (CySRER << index))| CyTxRdy); -cy_sched_event (info, - Cy_EVENT_WRITE_WAKEUP); +tty_wakeup (info->tty); } }else {if (!(mdm_status & CyCTS)) {
@@ -1633,9 +1564,11 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, char_count = rx_put - rx_get; else char_count = rx_put - rx_get + rx_bufsize; -if (char_count >= (int )readl (&buf_ctrl->rx_threshold)) { -cy_sched_event (info, Cy_EVENT_Z_RX_FULL); - } +if (char_count >= (int )readl (&buf_ctrl->rx_threshold) && + !timer_pending (&cyz_rx_full_timer[ + info->line])) +mod_timer (&cyz_rx_full_timer[info->line], + jiffies +1 );#endif info->idle_stats.recv_idle = jiffies;tty_schedule_flip (tty);
@@ -1717,9 +1650,7 @@ cyz_handle_tx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, }#endif ztxdone: -if (info->xmit_cnt <WAKEUP_CHARS ) { -cy_sched_event (info, Cy_EVENT_WRITE_WAKEUP); - } +tty_wakeup (tty);/* Update tx_put */ cy_writel (&buf_ctrl->tx_put, tx_put); }
@@ -1781,10 +1712,11 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)if ((fw_ver >241 ? ((u_long ) param) :readl (&ch_ctrl->rs_status)) &C_RS_DCD ) { -cy_sched_event (info, - Cy_EVENT_OPEN_WAKEUP); +wake_up_interruptible (&info->open_wait); }else { -cy_sched_event (info, Cy_EVENT_HANGUP); +tty_hangup (info->tty); +wake_up_interruptible (&info->open_wait); + info->flags &= ~ASYNC_NORMAL_ACTIVE ; } }break ;
@@ -1802,7 +1734,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)break ;#ifdef Z_WAKE case C_CM_IOCTLW : -cy_sched_event (info, Cy_EVENT_SHUTDOWN_WAKEUP); +complete (&info->shutdown_wait);break ;#endif #ifdef CONFIG_CYZ_INTR
@@ -1834,7 +1766,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)break ; }if (delta_count) -cy_sched_event (info, Cy_EVENT_DELTA_WAKEUP); +wake_up_interruptible (&info->delta_msr_wait);if (special_count)tty_schedule_flip (tty); }
@@ -2812,7 +2744,6 @@ static void cy_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&card->card_lock, flags); tty->closing =0 ; - info->event =0 ; info->tty =NULL ;if (info->blocked_open) {spin_unlock_irqrestore (&card->card_lock, flags);
@@ -4444,7 +4375,6 @@ static void cy_hangup(struct tty_struct *tty)cy_flush_buffer (tty);shutdown (info); - info->event =0 ; info->count =0 ;#ifdef CY_DEBUG_COUNT printk(KERN_DEBUG "cyc:cy_hangup (%d): setting count to 0\n",
@@ -4502,7 +4432,6 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) info->closing_wait =CLOSING_WAIT_DELAY ; info->close_delay =5 *HZ /10 ; -INIT_WORK (&info->tqueue, do_softint);init_waitqueue_head (&info->open_wait);init_waitqueue_head (&info->close_wait);init_completion (&info->shutdown_wait);
include/linux/cyclades.h +0 -15
@@ -569,7 +569,6 @@ struct cyclades_port {int x_char;/* to be pushed out ASAP */ int close_delay;unsigned short closing_wait; -unsigned long event;int count;/* # of fd on device */ int breakon;int breakoff;
@@ -584,7 +583,6 @@ struct cyclades_port {struct cyclades_monitor mon;struct cyclades_idle_stats idle_stats;struct cyclades_icount icount; -struct work_struct tqueue;wait_queue_head_t open_wait;wait_queue_head_t close_wait;struct completion shutdown_wait;
@@ -592,19 +590,6 @@ struct cyclades_port {int throttle; }; -/* -* Events are used to schedule things to happen at timer-interrupt -* time, instead of at cy interrupt time. -*/ -#define Cy_EVENT_READ_PROCESS 0 -#define Cy_EVENT_WRITE_WAKEUP 1 -#define Cy_EVENT_HANGUP 2 -#define Cy_EVENT_BREAK 3 -#define Cy_EVENT_OPEN_WAKEUP 4 -#define Cy_EVENT_SHUTDOWN_WAKEUP 5 -#define Cy_EVENT_DELTA_WAKEUP 6 -#define Cy_EVENT_Z_RX_FULL 7 -#define CLOSING_WAIT_DELAY 30*HZ#define CY_CLOSING_WAIT_NONE 65535#define CY_CLOSING_WAIT_INF 0
PATCH 2/4 Char: cyclades, make the isr code readable
cyclades, make the isr code readable
due to large indent the code was wrapped and unreadable. Create 3 function instead of one and reorder the code, so it is readable now.
---
commit 681fc4c7f1aa79a001d5ebe5f09bc7b63fa9dd16
tree ebc2e2807988e00b7a2aa0cff3bccfdbd51e201a
parent 3fc1c2f3f8414d72e12e8d6aed1c36ddb1f19567
author Jiri Slaby <[email protected]> Sat, 28 Jul 2007 11:08:53 +0200 committer Jiri Slaby <[email protected]> Sat, 28 Jul 2007 11:08:53 +0200
drivers/char/cyclades.c | 617 ++++++++++++++++++++++------------------------- 1 files changed, 292 insertions(+), 325 deletions(-)
drivers/char/cyclades.c +292 -325
@@ -980,378 +980,342 @@ static unsigned detect_isa_irq(void __iomem * address) }#endif /* CONFIG_ISA */ -static void cyy_intr_chip (struct cyclades_card *cinfo,int chip, -void __iomem * base_addr,int status,int index) +static void cyy_chip_rx (struct cyclades_card *cinfo,int chip, +void __iomem *base_addr) {struct cyclades_port *info;struct tty_struct *tty;int char_count; -int j, len, mdm_change, mdm_status, outch; +int j, len, index = cinfo->bus_index;int save_xir, channel, save_car;char data; -if (status & CySRReceive) {/* reception interrupt */ #ifdef CY_DEBUG_INTERRUPTS -printk (KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n" , chip); +printk (KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n" , chip);#endif -/* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); - save_xir = (u_char )readb (base_addr + (CyRIR << index)); - channel = (u_short) (save_xir & CyIRChannel); - info = &cinfo->ports[channel + chip *4 ]; - save_car =readb (base_addr + (CyCAR << index)); -cy_writeb (base_addr + (CyCAR << index), save_xir); - -/* if there is nowhere to put the data, discard it */ -if (info->tty ==NULL ) { - j = (readb (base_addr + (CyRIVR << index)) & - CyIVRMask); -if (j == CyIVRRxEx) {/* exception */ - data =readb (base_addr + (CyRDSR << index)); - }else {/* normal character reception */ - char_count =readb (base_addr + - (CyRDCR << index)); -while (char_count--) { - data =readb (base_addr + - (CyRDSR << index)); - } - } - }else {/* there is an open port for this data */ - tty = info->tty; - j = (readb (base_addr + (CyRIVR << index)) & - CyIVRMask); -if (j == CyIVRRxEx) {/* exception */ +/* determine the channel & change to that context */ +spin_lock (&cinfo->card_lock); + save_xir = (u_char )readb (base_addr + (CyRIR << index)); + channel = (u_short) (save_xir & CyIRChannel); + info = &cinfo->ports[channel + chip *4 ]; + save_car =readb (base_addr + (CyCAR << index)); +cy_writeb (base_addr + (CyCAR << index), save_xir); + +/* if there is nowhere to put the data, discard it */ +if (info->tty ==NULL ) { + j = (readb (base_addr + (CyRIVR << index)) & CyIVRMask); +if (j == CyIVRRxEx) {/* exception */ + data =readb (base_addr + (CyRDSR << index)); + }else {/* normal character reception */ + char_count =readb (base_addr + (CyRDCR << index)); +while (char_count--) data =readb (base_addr + (CyRDSR << index)); - -/* For statistics only */ -if (data & CyBREAK) - info->icount.brk++; -else if (data & CyFRAME) - info->icount.frame++; -else if (data & CyPARITY) - info->icount.parity++; -else if (data & CyOVERRUN) - info->icount.overrun++; - -if (data & info->ignore_status_mask) { + } + goto end; + } +/* there is an open port for this data */ + tty = info->tty; + j =readb (base_addr + (CyRIVR << index)) & CyIVRMask; +if (j == CyIVRRxEx) {/* exception */ + data =readb (base_addr + (CyRDSR << index)); + +/* For statistics only */ +if (data & CyBREAK) + info->icount.brk++; +else if (data & CyFRAME) + info->icount.frame++; +else if (data & CyPARITY) + info->icount.parity++; +else if (data & CyOVERRUN) + info->icount.overrun++; + +if (data & info->ignore_status_mask) { + info->icount.rx++; +spin_unlock (&cinfo->card_lock); +return ; + } +if (tty_buffer_request_room (tty,1 )) { +if (data & info->read_status_mask) { +if (data & CyBREAK) { +tty_insert_flip_char (tty, +readb (base_addr + (CyRDSR << + index)),TTY_BREAK ); + info->icount.rx++; +if (info->flags &ASYNC_SAK ) +do_SAK (tty); + }else if (data & CyFRAME) { +tty_insert_flip_char ( tty, +readb (base_addr + (CyRDSR << + index)),TTY_FRAME ); + info->icount.rx++; + info->idle_stats.frame_errs++; + }else if (data & CyPARITY) { +/* Pieces of seven... */ +tty_insert_flip_char (tty, +readb (base_addr + (CyRDSR << + index)),TTY_PARITY ); + info->icount.rx++; + info->idle_stats.parity_errs++; + }else if (data & CyOVERRUN) { +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. +*/ +tty_insert_flip_char (tty, +readb (base_addr + (CyRDSR << + index)),TTY_FRAME ); info->icount.rx++; -spin_unlock (&cinfo->card_lock); -return ; - } -if (tty_buffer_request_room (tty,1 )) { -if (data & info->read_status_mask) { -if (data & CyBREAK) { -tty_insert_flip_char ( - tty, -readb ( - base_addr + - (CyRDSR << - index)), -TTY_BREAK ); - info->icount.rx++; -if (info->flags & -ASYNC_SAK ) { -do_SAK (tty); - } - }else if (data & CyFRAME) { -tty_insert_flip_char ( - tty, -readb ( - base_addr + - (CyRDSR << - index)), -TTY_FRAME ); - info->icount.rx++; - info->idle_stats. - frame_errs++; - }else if (data & CyPARITY) { -/* Pieces of seven... */ -tty_insert_flip_char ( - tty, -readb ( - base_addr + - (CyRDSR << - index)), -TTY_PARITY ); - info->icount.rx++; - info->idle_stats. - parity_errs++; - }else if (data & CyOVERRUN) { -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. -*/ -tty_insert_flip_char ( - tty, -readb ( - base_addr + - (CyRDSR << - index)), -TTY_FRAME ); - info->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_insert_flip_char ( - tty,0 , -TTY_NORMAL ); - info->icount.rx++; - } - }else { -tty_insert_flip_char (tty,0 , -TTY_NORMAL ); - info->icount.rx++; - } - }else { -/* there was a software buffer -overrun and nothing could be -done about it!!! */ - info->icount.buf_overrun++; 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_insert_flip_char (tty,0 , +TTY_NORMAL ); + info->icount.rx++; } - }else {/* normal character reception */ -/* load # chars available from the chip */ - char_count =readb (base_addr + - (CyRDCR << index)); + }else { +tty_insert_flip_char (tty,0 ,TTY_NORMAL ); + info->icount.rx++; + } + }else { +/* there was a software buffer overrun and nothing +* could be done about it!!! */ + info->icount.buf_overrun++; + info->idle_stats.overruns++; + } + }else {/* normal character reception */ +/* load # chars available from the chip */ + char_count =readb (base_addr + (CyRDCR << index));#ifdef CY_ENABLE_MONITORING - ++info->mon.int_count; - info->mon.char_count += char_count; -if (char_count > info->mon.char_max) - info->mon.char_max = char_count; - info->mon.char_last = char_count; + ++info->mon.int_count; + info->mon.char_count += char_count; +if (char_count > info->mon.char_max) + info->mon.char_max = char_count; + info->mon.char_last = char_count;#endif - len =tty_buffer_request_room (tty, char_count); -while (len--) { - data =readb (base_addr + - (CyRDSR << index)); -tty_insert_flip_char (tty, data, -TTY_NORMAL ); - info->idle_stats.recv_bytes++; - info->icount.rx++; + len =tty_buffer_request_room (tty, char_count); +while (len--) { + data =readb (base_addr + (CyRDSR << index)); +tty_insert_flip_char (tty, data,TTY_NORMAL ); + info->idle_stats.recv_bytes++; + info->icount.rx++;#ifdef CY_16Y_HACK -udelay (10L ); +udelay (10L );#endif - } - info->idle_stats.recv_idle = jiffies; - } -tty_schedule_flip (tty); } -/* end of service */ -cy_writeb (base_addr + (CyRIR << index), (save_xir &0x3f )); -cy_writeb (base_addr + (CyCAR << index), (save_car)); -spin_unlock (&cinfo->card_lock); + info->idle_stats.recv_idle = jiffies; } +tty_schedule_flip (tty); +end: +/* end of service */ +cy_writeb (base_addr + (CyRIR << index), save_xir &0x3f ); +cy_writeb (base_addr + (CyCAR << index), save_car); +spin_unlock (&cinfo->card_lock); +} + +static void cyy_chip_tx (struct cyclades_card *cinfo,int chip, +void __iomem *base_addr) +{ +struct cyclades_port *info; +int char_count; +int outch; +int save_xir, channel, save_car, index = cinfo->bus_index; -if (status & CySRTransmit) {/* transmission interrupt */ -/* Since we only get here when the transmit buffer -is empty, we know we can always stuff a dozen -characters. */ +/* Since we only get here when the transmit buffer +is empty, we know we can always stuff a dozen +characters. */ #ifdef CY_DEBUG_INTERRUPTS -printk (KERN_DEBUG "cyy_interrupt: xmit intr, chip %d\n" , chip); +printk (KERN_DEBUG "cyy_interrupt: xmit intr, chip %d\n" , chip);#endif -/* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); - save_xir = (u_char )readb (base_addr + (CyTIR << index)); - channel = (u_short) (save_xir & CyIRChannel); - save_car =readb (base_addr + (CyCAR << index)); -cy_writeb (base_addr + (CyCAR << index), save_xir); +/* determine the channel & change to that context */ +spin_lock (&cinfo->card_lock); + save_xir = (u_char )readb (base_addr + (CyTIR << index)); + channel = (u_short) (save_xir & CyIRChannel); + save_car =readb (base_addr + (CyCAR << index)); +cy_writeb (base_addr + (CyCAR << index), save_xir); -/* validate the port# (as configured and open) */ -if (channel + chip *4 >= cinfo->nports) { -cy_writeb (base_addr + (CySRER << index), -readb (base_addr + (CySRER << index)) & - ~CyTxRdy); - goto txend; - } - info = &cinfo->ports[channel + chip *4 ]; -if (info->tty ==NULL ) { -cy_writeb (base_addr + (CySRER << index), -readb (base_addr + (CySRER << index)) & - ~CyTxRdy); - goto txend; - } +/* validate the port# (as configured and open) */ +if (channel + chip *4 >= cinfo->nports) { +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & ~CyTxRdy); + goto end; + } + info = &cinfo->ports[channel + chip *4 ]; +if (info->tty ==NULL ) { +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & ~CyTxRdy); + goto end; + } -/* load the on-chip space for outbound data */ - char_count = info->xmit_fifo_size; +/* load the on-chip space for outbound data */ + char_count = info->xmit_fifo_size; -if (info->x_char) {/* send special char */ - outch = info->x_char; -cy_writeb (base_addr + (CyTDR << index), outch); - char_count--; - info->icount.tx++; - info->x_char =0 ; - } +if (info->x_char) {/* send special char */ + outch = info->x_char; +cy_writeb (base_addr + (CyTDR << index), outch); + char_count--; + info->icount.tx++; + info->x_char =0 ; + } -if (info->breakon || info->breakoff) { -if (info->breakon) { -cy_writeb (base_addr + (CyTDR << index),0 ); -cy_writeb (base_addr + (CyTDR << index),0x81 ); - info->breakon =0 ; - char_count -=2 ; - } -if (info->breakoff) { -cy_writeb (base_addr + (CyTDR << index),0 ); -cy_writeb (base_addr + (CyTDR << index),0x83 ); - info->breakoff =0 ; - char_count -=2 ; - } +if (info->breakon || info->breakoff) { +if (info->breakon) { +cy_writeb (base_addr + (CyTDR << index),0 ); +cy_writeb (base_addr + (CyTDR << index),0x81 ); + info->breakon =0 ; + char_count -=2 ; + } +if (info->breakoff) { +cy_writeb (base_addr + (CyTDR << index),0 ); +cy_writeb (base_addr + (CyTDR << index),0x83 ); + info->breakoff =0 ; + char_count -=2 ; } + } -while (char_count-- >0 ) { -if (!info->xmit_cnt) { -if (readb (base_addr + (CySRER << index)) & - CyTxMpty) { -cy_writeb (base_addr + (CySRER << index), -readb (base_addr + - (CySRER << index)) & +while (char_count-- >0 ) { +if (!info->xmit_cnt) { +if (readb (base_addr + (CySRER << index)) & CyTxMpty) { +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & ~CyTxMpty); - }else { -cy_writeb (base_addr + (CySRER << index), - (readb (base_addr + - (CySRER << index)) & + }else { +cy_writeb (base_addr + (CySRER << index), + (readb (base_addr + (CySRER << index)) & ~CyTxRdy) | CyTxMpty); - } - goto txdone; } -if (info->xmit_buf ==NULL ) { -cy_writeb (base_addr + (CySRER << index), -readb (base_addr + (CySRER << index)) & + goto done; + } +if (info->xmit_buf ==NULL ) { +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & ~CyTxRdy); - goto txdone; - } -if (info->tty->stopped || info->tty->hw_stopped) { -cy_writeb (base_addr + (CySRER << index), -readb (base_addr + (CySRER << index)) & + goto done; + } +if (info->tty->stopped || info->tty->hw_stopped) { +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & ~CyTxRdy); - goto txdone; - } -/* Because the Embedded Transmit Commands have -been enabled, we must check to see if the -escape character, NULL, is being sent. If it -is, we must ensure that there is room for it -to be doubled in the output stream. Therefore -we no longer advance the pointer when the -character is fetched, but rather wait until -after the check for a NULL output character. -This is necessary because there may not be -room for the two chars needed to send a NULL.) -*/ - outch = info->xmit_buf[info->xmit_tail]; -if (outch) { + goto done; + } +/* Because the Embedded Transmit Commands have been enabled, +* we must check to see if the escape character, NULL, is being +* sent. If it is, we must ensure that there is room for it to +* be doubled in the output stream. Therefore we no longer +* advance the pointer when the character is fetched, but +* rather wait until after the check for a NULL output +* character. This is necessary because there may not be room +* for the two chars needed to send a NULL.) +*/ + outch = info->xmit_buf[info->xmit_tail]; +if (outch) { + info->xmit_cnt--; + info->xmit_tail = (info->xmit_tail +1 ) & + (SERIAL_XMIT_SIZE -1 ); +cy_writeb (base_addr + (CyTDR << index), outch); + info->icount.tx++; + }else { +if (char_count >1 ) { info->xmit_cnt--; info->xmit_tail = (info->xmit_tail +1 ) & - (SERIAL_XMIT_SIZE -1 ); + (SERIAL_XMIT_SIZE -1 );cy_writeb (base_addr + (CyTDR << index), outch); +cy_writeb (base_addr + (CyTDR << index),0 ); info->icount.tx++; - }else { -if (char_count >1 ) { - info->xmit_cnt--; - info->xmit_tail = (info->xmit_tail +1 )& - (SERIAL_XMIT_SIZE -1 ); -cy_writeb (base_addr + (CyTDR << index), - outch); -cy_writeb (base_addr + (CyTDR << index), -0 ); - info->icount.tx++; - char_count--; - } + char_count--; } } - -txdone: -tty_wakeup (info->tty); -txend: -/* end of service */ -cy_writeb (base_addr + (CyTIR << index), (save_xir &0x3f )); -cy_writeb (base_addr + (CyCAR << index), (save_car)); -spin_unlock (&cinfo->card_lock); } -if (status & CySRModem) {/* modem interrupt */ +done: +tty_wakeup (info->tty); +end: +/* end of service */ +cy_writeb (base_addr + (CyTIR << index), save_xir &0x3f ); +cy_writeb (base_addr + (CyCAR << index), save_car); +spin_unlock (&cinfo->card_lock); +} + +static void cyy_chip_modem (struct cyclades_card *cinfo,int chip, +void __iomem *base_addr) +{ +struct cyclades_port *info; +int mdm_change, mdm_status; +int save_xir, channel, save_car, index = cinfo->bus_index; -/* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); - save_xir = (u_char )readb (base_addr + (CyMIR << index)); - channel = (u_short) (save_xir & CyIRChannel); - info = &cinfo->ports[channel + chip *4 ]; - save_car =readb (base_addr + (CyCAR << index)); -cy_writeb (base_addr + (CyCAR << index), save_xir); +/* determine the channel & change to that context */ +spin_lock (&cinfo->card_lock); + save_xir = (u_char )readb (base_addr + (CyMIR << index)); + channel = (u_short) (save_xir & CyIRChannel); + info = &cinfo->ports[channel + chip *4 ]; + save_car =readb (base_addr + (CyCAR << index)); +cy_writeb (base_addr + (CyCAR << index), save_xir); - mdm_change =readb (base_addr + (CyMISR << index)); - mdm_status =readb (base_addr + (CyMSVR1 << index)); + mdm_change =readb (base_addr + (CyMISR << index)); + mdm_status =readb (base_addr + (CyMSVR1 << index)); -if (info->tty) { -if (mdm_change & CyANY_DELTA) { -/* For statistics only */ -if (mdm_change & CyDCD) - info->icount.dcd++; -if (mdm_change & CyCTS) - info->icount.cts++; -if (mdm_change & CyDSR) - info->icount.dsr++; -if (mdm_change & CyRI) - info->icount.rng++; - -wake_up_interruptible (&info->delta_msr_wait); - } +if (!info->tty) + goto end; -if ((mdm_change & CyDCD) && - (info->flags &ASYNC_CHECK_CD )) { -if (!(mdm_status & CyDCD)) { -tty_hangup (info->tty); - info->flags &= ~ASYNC_NORMAL_ACTIVE ; - } -wake_up_interruptible (&info->open_wait); - } -if ((mdm_change & CyCTS) && - (info->flags &ASYNC_CTS_FLOW )) { -if (info->tty->hw_stopped) { -if (mdm_status & CyCTS) { -/* cy_start isn't used -because... !!! */ - info->tty->hw_stopped =0 ; -cy_writeb (base_addr + - (CySRER << index), -readb (base_addr + - (CySRER << - index))| - CyTxRdy); -tty_wakeup (info->tty); - } - }else { -if (!(mdm_status & CyCTS)) { -/* cy_stop isn't used -because ... !!! */ - info->tty->hw_stopped =1 ; -cy_writeb (base_addr + - (CySRER << index), -readb (base_addr + - (CySRER << - index)) & - ~CyTxRdy); - } - } +if (mdm_change & CyANY_DELTA) { +/* For statistics only */ +if (mdm_change & CyDCD) + info->icount.dcd++; +if (mdm_change & CyCTS) + info->icount.cts++; +if (mdm_change & CyDSR) + info->icount.dsr++; +if (mdm_change & CyRI) + info->icount.rng++; + +wake_up_interruptible (&info->delta_msr_wait); + } + +if ((mdm_change & CyDCD) && (info->flags &ASYNC_CHECK_CD )) { +if (!(mdm_status & CyDCD)) { +tty_hangup (info->tty); + info->flags &= ~ASYNC_NORMAL_ACTIVE ; + } +wake_up_interruptible (&info->open_wait); + } +if ((mdm_change & CyCTS) && (info->flags &ASYNC_CTS_FLOW )) { +if (info->tty->hw_stopped) { +if (mdm_status & CyCTS) { +/* cy_start isn't used +because... !!! */ + info->tty->hw_stopped =0 ; +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) | + CyTxRdy); +tty_wakeup (info->tty); } -/* if (mdm_change & CyDSR) { + }else { +if (!(mdm_status & CyCTS)) { +/* cy_stop isn't used +because ... !!! */ + info->tty->hw_stopped =1 ; +cy_writeb (base_addr + (CySRER << index), +readb (base_addr + (CySRER << index)) & + ~CyTxRdy); } -if (mdm_change & CyRI) { -}*/ } -/* end of service */ -cy_writeb (base_addr + (CyMIR << index), (save_xir &0x3f )); -cy_writeb (base_addr + (CyCAR << index), save_car); -spin_unlock (&cinfo->card_lock); } +/* if (mdm_change & CyDSR) { +} +if (mdm_change & CyRI) { +}*/ +end: +/* end of service */ +cy_writeb (base_addr + (CyMIR << index), save_xir &0x3f ); +cy_writeb (base_addr + (CyCAR << index), save_car); +spin_unlock (&cinfo->card_lock); }/* The real interrupt service routine is called
@@ -1401,11 +1365,14 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)chips to be checked in a round-robin fashion (after draining each of a bunch (1000) of characters). */ -if (1000 < too_many++) { +if (1000 < too_many++)break ; - } -cyy_intr_chip (cinfo, chip, base_addr, status, - index); +if (status & CySRReceive)/* rx intr */ +cyy_chip_rx (cinfo, chip, base_addr); +if (status & CySRTransmit)/* tx intr */ +cyy_chip_tx (cinfo, chip, base_addr); +if (status & CySRModem)/* modem intr */ +cyy_chip_modem (cinfo, chip, base_addr); } } }while (had_work);
PATCH 3/4 Char: cyclades, move spin_lock to one place
In reply to Jiri Slabycyclades, move spin_lock to one place
lock whole processing in isr, avoid error-prone locking/unlocking in rx/tx esp. on fail paths (there was a bug in the past yet).
---
commit 93fc0dd73bb407b773506ec8d756317de9098d53
tree 6a1c1cfde015d095c6c94f21ea9b04e038787207
parent 681fc4c7f1aa79a001d5ebe5f09bc7b63fa9dd16
author Jiri Slaby <[email protected]> Sat, 28 Jul 2007 11:28:53 +0200 committer Jiri Slaby <[email protected]> Sat, 28 Jul 2007 11:28:53 +0200
drivers/char/cyclades.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/char/cyclades.c +2 -7
@@ -994,7 +994,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,printk (KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n" , chip);#endif /* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); save_xir = (u_char )readb (base_addr + (CyRIR << index)); channel = (u_short) (save_xir & CyIRChannel); info = &cinfo->ports[channel + chip *4 ];
@@ -1031,7 +1030,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,if (data & info->ignore_status_mask) { info->icount.rx++; -spin_unlock (&cinfo->card_lock);return ; }if (tty_buffer_request_room (tty,1 )) {
@@ -1116,7 +1114,6 @@ end:/* end of service */ cy_writeb (base_addr + (CyRIR << index), save_xir &0x3f );cy_writeb (base_addr + (CyCAR << index), save_car); -spin_unlock (&cinfo->card_lock); } static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,
@@ -1135,7 +1132,6 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,#endif /* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); save_xir = (u_char )readb (base_addr + (CyTIR << index)); channel = (u_short) (save_xir & CyIRChannel); save_car =readb (base_addr + (CyCAR << index));
@@ -1240,7 +1236,6 @@ end:/* end of service */ cy_writeb (base_addr + (CyTIR << index), save_xir &0x3f );cy_writeb (base_addr + (CyCAR << index), save_car); -spin_unlock (&cinfo->card_lock); } static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
@@ -1251,7 +1246,6 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,int save_xir, channel, save_car, index = cinfo->bus_index;/* determine the channel & change to that context */ -spin_lock (&cinfo->card_lock); save_xir = (u_char )readb (base_addr + (CyMIR << index)); channel = (u_short) (save_xir & CyIRChannel); info = &cinfo->ports[channel + chip *4 ];
@@ -1315,7 +1309,6 @@ end:/* end of service */ cy_writeb (base_addr + (CyMIR << index), save_xir &0x3f );cy_writeb (base_addr + (CyCAR << index), save_car); -spin_unlock (&cinfo->card_lock); }/* The real interrupt service routine is called
@@ -1367,12 +1360,14 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)*/ if (1000 < too_many++)break ; +spin_lock (&cinfo->card_lock);if (status & CySRReceive)/* rx intr */ cyy_chip_rx (cinfo, chip, base_addr);if (status & CySRTransmit)/* tx intr */ cyy_chip_tx (cinfo, chip, base_addr);if (status & CySRModem)/* modem intr */ cyy_chip_modem (cinfo, chip, base_addr); +spin_unlock (&cinfo->card_lock); } } }while (had_work);
PATCH 4/4 Char: cyclades, fix some -W warnings
In reply to Jiri Slabycyclades, fix some -W warnings
most of them are signedness, the rest unused function parameters.
---
commit c5b48bcb1d32983ffa85a351c6d24ee92c5b8446
tree dd74dc5d8fac41e70251b34a947f389e531a27cd
parent 93fc0dd73bb407b773506ec8d756317de9098d53
author Jiri Slaby <[email protected]> Sun, 29 Jul 2007 21:36:27 +0200 committer Jiri Slaby <[email protected]> Sun, 29 Jul 2007 21:36:27 +0200
drivers/char/cyclades.c | 84 ++++++++++++++++++++-------------------------- include/linux/cyclades.h | 12 +++---- 2 files changed, 43 insertions(+), 53 deletions(-)
drivers/char/cyclades.c +37 -47
@@ -662,7 +662,7 @@static void cy_throttle (struct tty_struct *tty);static void cy_send_xchar (struct tty_struct *tty,char ch); -#define IS_CYC_Z (card) ((card).num_chips == -1) +#define IS_CYC_Z (card) ((card).num_chips == (unsigned int)-1)#define Z_FPGA_CHECK (card) \ ((readl(&((struct RUNTIME_9060 __iomem *) \
@@ -985,25 +985,23 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, {struct cyclades_port *info;struct tty_struct *tty; -int char_count; -int j, len, index = cinfo->bus_index; -int save_xir, channel, save_car; -char data; +int len, index = cinfo->bus_index; +u8 save_xir, channel, save_car, data, char_count;#ifdef CY_DEBUG_INTERRUPTS printk (KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n" , chip);#endif /* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyRIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyRIR << index)); + channel = save_xir & CyIRChannel; info = &cinfo->ports[channel + chip *4 ]; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);/* if there is nowhere to put the data, discard it */ if (info->tty ==NULL ) { - j = (readb (base_addr + (CyRIVR << index)) & CyIVRMask); -if (j == CyIVRRxEx) {/* exception */ +if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == + CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index)); }else {/* normal character reception */ char_count =readb (base_addr + (CyRDCR << index));
@@ -1014,8 +1012,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, }/* there is an open port for this data */ tty = info->tty; - j =readb (base_addr + (CyRIVR << index)) & CyIVRMask; -if (j == CyIVRRxEx) {/* exception */ +if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == + CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index));/* For statistics only */
@@ -1116,13 +1114,12 @@ end:cy_writeb (base_addr + (CyCAR << index), save_car); } -static void cyy_chip_tx (struct cyclades_card *cinfo,int chip, +static void cyy_chip_tx (struct cyclades_card *cinfo,unsigned int chip,void __iomem *base_addr) {struct cyclades_port *info; -int char_count; -int outch; -int save_xir, channel, save_car, index = cinfo->bus_index; +int char_count, index = cinfo->bus_index; +u8 save_xir, channel, save_car, outch;/* Since we only get here when the transmit buffer is empty, we know we can always stuff a dozen
@@ -1132,8 +1129,8 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,#endif /* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyTIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyTIR << index)); + channel = save_xir & CyIRChannel; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);
@@ -1242,12 +1239,12 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip, void __iomem *base_addr) {struct cyclades_port *info; -int mdm_change, mdm_status; -int save_xir, channel, save_car, index = cinfo->bus_index; +int index = cinfo->bus_index; +u8 save_xir, channel, save_car, mdm_change, mdm_status;/* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyMIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyMIR << index)); + channel = save_xir & CyIRChannel; info = &cinfo->ports[channel + chip *4 ]; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);
@@ -1320,10 +1317,8 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)int status;struct cyclades_card *cinfo = dev_id;void __iomem *base_addr, *card_base_addr; -int chip; +unsigned int chip, too_many, had_work;int index; -int too_many; -int had_work;if (unlikely (cinfo ==NULL )) {#ifdef CY_DEBUG_INTERRUPTS
@@ -1422,7 +1417,7 @@ cyz_issue_cmd(struct cyclades_card *cinfo,struct ZFW_CTRL __iomem *zfw_ctrl;struct BOARD_CTRL __iomem *board_ctrl;__u32 __iomem *pci_doorbell; -int index; +unsigned int index; firm_id = cinfo->base_addr +ID_ADDRESS ;if (!ISZLOADED (*cinfo)) {
@@ -1447,13 +1442,12 @@ cyz_issue_cmd(struct cyclades_card *cinfo,return 0 ; }/* cyz_issue_cmd */ -static void -cyz_handle_rx (struct cyclades_port *info,struct CH_CTRL __iomem *ch_ctrl, +static void cyz_handle_rx (struct cyclades_port *info,struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card;struct tty_struct *tty = info->tty; -int char_count; +unsigned int char_count;int len;#ifdef BLOCKMOVE unsigned char *buf;
@@ -1526,7 +1520,7 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, char_count = rx_put - rx_get; else char_count = rx_put - rx_get + rx_bufsize; -if (char_count >= (int )readl (&buf_ctrl->rx_threshold) && +if (char_count >=readl (&buf_ctrl->rx_threshold) && !timer_pending (&cyz_rx_full_timer[ info->line])) mod_timer(&cyz_rx_full_timer[info->line],
@@ -1540,14 +1534,13 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, } } -static void -cyz_handle_tx (struct cyclades_port *info,struct CH_CTRL __iomem *ch_ctrl, +static void cyz_handle_tx (struct cyclades_port *info,struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card;struct tty_struct *tty = info->tty; -char data; -int char_count; +u8 data; +unsigned int char_count;#ifdef BLOCKMOVE int small_count;#endif
@@ -1787,10 +1780,9 @@ static void cyz_poll(unsigned long arg)struct FIRM_ID __iomem *firm_id;struct ZFW_CTRL __iomem *zfw_ctrl;struct BOARD_CTRL __iomem *board_ctrl; -struct CH_CTRL __iomem *ch_ctrl;struct BUF_CTRL __iomem *buf_ctrl;unsigned long expires = jiffies +HZ ; -int card, port; +unsigned int port, card;for (card =0 ; card <NR_CARDS ; card++) { cinfo = &cy_card[card];
@@ -1817,12 +1809,11 @@ static void cyz_poll(unsigned long arg)for (port =0 ; port < cinfo->nports; port++) { info = &cinfo->ports[port]; tty = info->tty; - ch_ctrl = &(zfw_ctrl->ch_ctrl[port]); buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);if (!info->throttle) -cyz_handle_rx (info, ch_ctrl, buf_ctrl); -cyz_handle_tx (info, ch_ctrl, buf_ctrl); +cyz_handle_rx (info, buf_ctrl); +cyz_handle_tx (info, buf_ctrl); }/* poll every 'cyz_polling_cycle' period */ expires = jiffies + cyz_polling_cycle;
@@ -2385,11 +2376,11 @@ block_til_ready(struct tty_struct *tty, struct file *filp,static int cy_open (struct tty_struct *tty,struct file *filp) {struct cyclades_port *info; -unsigned int i; -int retval, line; +unsigned int i, line; +int retval; line = tty->index; -if ((line <0 ) || (NR_PORTS <= line)) { +if ((tty->index <0 ) || (NR_PORTS <= line)) {return -ENODEV ; }for (i =0 ; i <NR_CARDS ; i++)
@@ -4359,9 +4350,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) {struct cyclades_port *info;u32 uninitialized_var (mailbox ); -unsigned int nports; +unsigned int nports, port;unsigned short chip_number; -int uninitialized_var (index ), port; +int uninitialized_var (index );spin_lock_init (&cinfo->card_lock);
@@ -5127,7 +5118,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, } }#endif /* CONFIG_CYZ_INTR */ - cy_card[card_no].num_chips =-1 ; + cy_card[card_no].num_chips = (unsigned int )-1 ; }/* set cy_card */
@@ -5387,7 +5378,7 @@ err: static void __exit cy_cleanup_module(void) {struct cyclades_card *card; -int i, e1; +unsigned int i, e1;#ifndef CONFIG_CYZ_INTR del_timer_sync (&cyz_timerlist);
@@ -5415,8 +5406,7 @@ static void __exit cy_cleanup_module(void)#endif /* CONFIG_CYZ_INTR */ )free_irq (card->irq, card); -for (e1 = card->first_line; - e1 < card->first_line + +for (e1 = card->first_line; e1 < card->first_line + card->nports; e1++)tty_unregister_device (cy_serial_driver, e1);kfree (card->ports);
include/linux/cyclades.h +6 -6
@@ -512,11 +512,11 @@ struct cyclades_card {void __iomem *base_addr;void __iomem *ctl_addr;int irq; -int num_chips;/* 0 if card absent, -1 if Z/PCI, else Y */ -int first_line;/* minor number of first channel on card */ -int nports;/* Number of ports in the card */ -int bus_index;/* address shift - 0 for ISA, 1 for PCI */ -int intr_enabled;/* FW Interrupt flag - 0 disabled, 1 enabled */ +unsigned int num_chips;/* 0 if card absent, -1 if Z/PCI, else Y */ +unsigned int first_line;/* minor number of first channel on card */ +unsigned int nports;/* Number of ports in the card */ +int bus_index;/* address shift - 0 for ISA, 1 for PCI */ +int intr_enabled;/* FW Interrupt flag - 0 disabled, 1 enabled */ spinlock_t card_lock;struct cyclades_port *ports; };
@@ -566,7 +566,7 @@ struct cyclades_port {int rtsdtr_inv;int chip_rev;int custom_divisor; -int x_char;/* to be pushed out ASAP */ +u8 x_char;/* to be pushed out ASAP */ int close_delay;unsigned short closing_wait;int count;/* # of fd on device */
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Char: cyclades, fix some -W warnings
Quoted 9 lines · Andrew Morton
Quoted 2 lines · On Sun, 29 Jul 2007 22:01:24 +0200 (CEST) Jiri Slaby <[email protected]>…
cyclades, fix some -W warnings
drivers/char/cyclades.c: In function 'cyz_handle_cmd':drivers/char/cyclades.c:1704: warning: passing argument 2 of 'cyz_handle_rx' from incompatible pointer typedrivers/char/cyclades.c:1704: error: too many arguments to function 'cyz_handle_rx'drivers/char/cyclades.c:1714: warning: passing argument 2 of 'cyz_handle_tx' from incompatible pointer typedrivers/char/cyclades.c:1714: error: too many arguments to function 'cyz_handle_tx'
Hum, all___config :(. I'm very sorry. #2 follows.
--
cyclades, fix some -W warnings
most of them are signedness, the rest unused function parameters.
---
commit 3919c1d3df1cd42f8a7c37d676c97798da89c15a
tree 746f7399699e280fed6a39e461c1972d5bc9908a
parent 93fc0dd73bb407b773506ec8d756317de9098d53
author Jiri Slaby <[email protected]> Tue, 31 Jul 2007 22:30:16 +0200 committer Jiri Slaby <[email protected]> Tue, 31 Jul 2007 22:30:16 +0200
drivers/char/cyclades.c | 88 ++++++++++++++++++++-------------------------- include/linux/cyclades.h | 12 +++--- 2 files changed, 45 insertions(+), 55 deletions(-)
drivers/char/cyclades.c +39 -49
@@ -662,7 +662,7 @@static void cy_throttle (struct tty_struct *tty);static void cy_send_xchar (struct tty_struct *tty,char ch); -#define IS_CYC_Z (card) ((card).num_chips == -1) +#define IS_CYC_Z (card) ((card).num_chips == (unsigned int)-1)#define Z_FPGA_CHECK (card) \ ((readl(&((struct RUNTIME_9060 __iomem *) \
@@ -985,25 +985,23 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, {struct cyclades_port *info;struct tty_struct *tty; -int char_count; -int j, len, index = cinfo->bus_index; -int save_xir, channel, save_car; -char data; +int len, index = cinfo->bus_index; +u8 save_xir, channel, save_car, data, char_count;#ifdef CY_DEBUG_INTERRUPTS printk (KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n" , chip);#endif /* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyRIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyRIR << index)); + channel = save_xir & CyIRChannel; info = &cinfo->ports[channel + chip *4 ]; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);/* if there is nowhere to put the data, discard it */ if (info->tty ==NULL ) { - j = (readb (base_addr + (CyRIVR << index)) & CyIVRMask); -if (j == CyIVRRxEx) {/* exception */ +if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == + CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index)); }else {/* normal character reception */ char_count =readb (base_addr + (CyRDCR << index));
@@ -1014,8 +1012,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, }/* there is an open port for this data */ tty = info->tty; - j =readb (base_addr + (CyRIVR << index)) & CyIVRMask; -if (j == CyIVRRxEx) {/* exception */ +if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == + CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index));/* For statistics only */
@@ -1116,13 +1114,12 @@ end:cy_writeb (base_addr + (CyCAR << index), save_car); } -static void cyy_chip_tx (struct cyclades_card *cinfo,int chip, +static void cyy_chip_tx (struct cyclades_card *cinfo,unsigned int chip,void __iomem *base_addr) {struct cyclades_port *info; -int char_count; -int outch; -int save_xir, channel, save_car, index = cinfo->bus_index; +int char_count, index = cinfo->bus_index; +u8 save_xir, channel, save_car, outch;/* Since we only get here when the transmit buffer is empty, we know we can always stuff a dozen
@@ -1132,8 +1129,8 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,#endif /* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyTIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyTIR << index)); + channel = save_xir & CyIRChannel; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);
@@ -1242,12 +1239,12 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip, void __iomem *base_addr) {struct cyclades_port *info; -int mdm_change, mdm_status; -int save_xir, channel, save_car, index = cinfo->bus_index; +int index = cinfo->bus_index; +u8 save_xir, channel, save_car, mdm_change, mdm_status;/* determine the channel & change to that context */ - save_xir = (u_char )readb (base_addr + (CyMIR << index)); - channel = (u_short) (save_xir & CyIRChannel); + save_xir =readb (base_addr + (CyMIR << index)); + channel = save_xir & CyIRChannel; info = &cinfo->ports[channel + chip *4 ]; save_car =readb (base_addr + (CyCAR << index));cy_writeb (base_addr + (CyCAR << index), save_xir);
@@ -1320,10 +1317,8 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)int status;struct cyclades_card *cinfo = dev_id;void __iomem *base_addr, *card_base_addr; -int chip; +unsigned int chip, too_many, had_work;int index; -int too_many; -int had_work;if (unlikely (cinfo ==NULL )) {#ifdef CY_DEBUG_INTERRUPTS
@@ -1422,7 +1417,7 @@ cyz_issue_cmd(struct cyclades_card *cinfo,struct ZFW_CTRL __iomem *zfw_ctrl;struct BOARD_CTRL __iomem *board_ctrl;__u32 __iomem *pci_doorbell; -int index; +unsigned int index; firm_id = cinfo->base_addr +ID_ADDRESS ;if (!ISZLOADED (*cinfo)) {
@@ -1447,13 +1442,12 @@ cyz_issue_cmd(struct cyclades_card *cinfo,return 0 ; }/* cyz_issue_cmd */ -static void -cyz_handle_rx (struct cyclades_port *info,struct CH_CTRL __iomem *ch_ctrl, +static void cyz_handle_rx (struct cyclades_port *info,struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card;struct tty_struct *tty = info->tty; -int char_count; +unsigned int char_count;int len;#ifdef BLOCKMOVE unsigned char *buf;
@@ -1526,7 +1520,7 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, char_count = rx_put - rx_get; else char_count = rx_put - rx_get + rx_bufsize; -if (char_count >= (int )readl (&buf_ctrl->rx_threshold) && +if (char_count >=readl (&buf_ctrl->rx_threshold) && !timer_pending (&cyz_rx_full_timer[ info->line])) mod_timer(&cyz_rx_full_timer[info->line],
@@ -1540,14 +1534,13 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl, } } -static void -cyz_handle_tx (struct cyclades_port *info,struct CH_CTRL __iomem *ch_ctrl, +static void cyz_handle_tx (struct cyclades_port *info,struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card;struct tty_struct *tty = info->tty; -char data; -int char_count; +u8 data; +unsigned int char_count;#ifdef BLOCKMOVE int small_count;#endif
@@ -1708,7 +1701,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)printk (KERN_DEBUG "cyz_interrupt: rcvd intr, card %d, " "port %ld\n" , info->card, channel);#endif -cyz_handle_rx (info, ch_ctrl, buf_ctrl); +cyz_handle_rx (info, buf_ctrl);break ;case C_CM_TXBEMPTY :case C_CM_TXLOWWM :
@@ -1718,7 +1711,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)printk (KERN_DEBUG "cyz_interrupt: xmit intr, card %d, " "port %ld\n" , info->card, channel);#endif -cyz_handle_tx (info, ch_ctrl, buf_ctrl); +cyz_handle_tx (info, buf_ctrl);break ;#endif /* CONFIG_CYZ_INTR */ case C_CM_FATAL :
@@ -1787,10 +1780,9 @@ static void cyz_poll(unsigned long arg)struct FIRM_ID __iomem *firm_id;struct ZFW_CTRL __iomem *zfw_ctrl;struct BOARD_CTRL __iomem *board_ctrl; -struct CH_CTRL __iomem *ch_ctrl;struct BUF_CTRL __iomem *buf_ctrl;unsigned long expires = jiffies +HZ ; -int card, port; +unsigned int port, card;for (card =0 ; card <NR_CARDS ; card++) { cinfo = &cy_card[card];
@@ -1817,12 +1809,11 @@ static void cyz_poll(unsigned long arg)for (port =0 ; port < cinfo->nports; port++) { info = &cinfo->ports[port]; tty = info->tty; - ch_ctrl = &(zfw_ctrl->ch_ctrl[port]); buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);if (!info->throttle) -cyz_handle_rx (info, ch_ctrl, buf_ctrl); -cyz_handle_tx (info, ch_ctrl, buf_ctrl); +cyz_handle_rx (info, buf_ctrl); +cyz_handle_tx (info, buf_ctrl); }/* poll every 'cyz_polling_cycle' period */ expires = jiffies + cyz_polling_cycle;
@@ -2385,11 +2376,11 @@ block_til_ready(struct tty_struct *tty, struct file *filp,static int cy_open (struct tty_struct *tty,struct file *filp) {struct cyclades_port *info; -unsigned int i; -int retval, line; +unsigned int i, line; +int retval; line = tty->index; -if ((line <0 ) || (NR_PORTS <= line)) { +if ((tty->index <0 ) || (NR_PORTS <= line)) {return -ENODEV ; }for (i =0 ; i <NR_CARDS ; i++)
@@ -4359,9 +4350,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) {struct cyclades_port *info;u32 uninitialized_var (mailbox ); -unsigned int nports; +unsigned int nports, port;unsigned short chip_number; -int uninitialized_var (index ), port; +int uninitialized_var (index );spin_lock_init (&cinfo->card_lock);
@@ -5127,7 +5118,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, } }#endif /* CONFIG_CYZ_INTR */ - cy_card[card_no].num_chips =-1 ; + cy_card[card_no].num_chips = (unsigned int )-1 ; }/* set cy_card */
@@ -5387,7 +5378,7 @@ err: static void __exit cy_cleanup_module(void) {struct cyclades_card *card; -int i, e1; +unsigned int i, e1;#ifndef CONFIG_CYZ_INTR del_timer_sync (&cyz_timerlist);
@@ -5415,8 +5406,7 @@ static void __exit cy_cleanup_module(void)#endif /* CONFIG_CYZ_INTR */ )free_irq (card->irq, card); -for (e1 = card->first_line; - e1 < card->first_line + +for (e1 = card->first_line; e1 < card->first_line + card->nports; e1++)tty_unregister_device (cy_serial_driver, e1);kfree (card->ports);
include/linux/cyclades.h +6 -6
@@ -512,11 +512,11 @@ struct cyclades_card {void __iomem *base_addr;void __iomem *ctl_addr;int irq; -int num_chips;/* 0 if card absent, -1 if Z/PCI, else Y */ -int first_line;/* minor number of first channel on card */ -int nports;/* Number of ports in the card */ -int bus_index;/* address shift - 0 for ISA, 1 for PCI */ -int intr_enabled;/* FW Interrupt flag - 0 disabled, 1 enabled */ +unsigned int num_chips;/* 0 if card absent, -1 if Z/PCI, else Y */ +unsigned int first_line;/* minor number of first channel on card */ +unsigned int nports;/* Number of ports in the card */ +int bus_index;/* address shift - 0 for ISA, 1 for PCI */ +int intr_enabled;/* FW Interrupt flag - 0 disabled, 1 enabled */ spinlock_t card_lock;struct cyclades_port *ports; };
@@ -566,7 +566,7 @@ struct cyclades_port {int rtsdtr_inv;int chip_rev;int custom_divisor; -int x_char;/* to be pushed out ASAP */ +u8 x_char;/* to be pushed out ASAP */ int close_delay;unsigned short closing_wait;int count;/* # of fd on device */