diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/Kconfig | 17 | ||||
-rw-r--r-- | drivers/char/apm-emulation.c | 2 | ||||
-rw-r--r-- | drivers/char/cyclades.c | 767 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 25 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 29 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 268 | ||||
-rw-r--r-- | drivers/char/isicom.c | 10 | ||||
-rw-r--r-- | drivers/char/moxa.c | 148 | ||||
-rw-r--r-- | drivers/char/mxser.c | 23 | ||||
-rw-r--r-- | drivers/char/mxser_new.c | 120 | ||||
-rw-r--r-- | drivers/char/pty.c | 24 | ||||
-rw-r--r-- | drivers/char/random.c | 2 | ||||
-rw-r--r-- | drivers/char/rocket.c | 91 | ||||
-rw-r--r-- | drivers/char/rocket_int.h | 7 | ||||
-rw-r--r-- | drivers/char/tty_ioctl.c | 11 | ||||
-rw-r--r-- | drivers/char/vt.c | 6 |
16 files changed, 733 insertions, 817 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 69f85185478..65491103e0f 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -36,23 +36,6 @@ config VT If unsure, say Y, or else you won't be able to do much with your new shiny Linux system :-) -config VT_UNICODE - bool "Virtual console is Unicode by default" - depends on VT - default n - ---help--- - If you say Y here, the virtual terminal will be in UTF-8 by default, - and the keyboard will run in unicode mode. - - If you say N here, the virtual terminal will not be in UTF-8 by - default, and the keyboard will run in XLATE mode. - - This can also be changed by passing 'default_utf8=<0|1>' on the - kernel command line. - - Historically, the kernel has defaulted to non-UTF8 and XLATE mode. - If unsure, say N here. - config VT_CONSOLE bool "Support for console on virtual terminal" if EMBEDDED depends on VT diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index ec116df919d..c99e43b837f 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c @@ -18,7 +18,7 @@ #include <linux/apm_bios.h> #include <linux/capability.h> #include <linux/sched.h> -#include <linux/pm.h> +#include <linux/suspend.h> #include <linux/apm-emulation.h> #include <linux/freezer.h> #include <linux/device.h> diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 9e0adfe27c1..d15234c5965 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -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 *) \ @@ -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 ********/ @@ -1045,382 +980,332 @@ 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 save_xir, channel, save_car; - char data; + int len, index = cinfo->bus_index; + u8 save_xir, channel, save_car, data, char_count; - 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 */ + /* determine the channel & change to that context */ + 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) { + 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)); + while (char_count--) 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 */ - 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; + if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) == + 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++; + 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); +} + +static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip, + void __iomem *base_addr) +{ + struct cyclades_port *info; + int char_count, index = cinfo->bus_index; + u8 save_xir, channel, save_car, outch; - 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 */ + 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); - /* 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 txdone; - } + /* 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: - if (info->xmit_cnt < WAKEUP_CHARS) { - cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); - } -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); +} - /* 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); +static void cyy_chip_modem(struct cyclades_card *cinfo, int chip, + void __iomem *base_addr) +{ + struct cyclades_port *info; + int index = cinfo->bus_index; + u8 save_xir, channel, save_car, mdm_change, mdm_status; - mdm_change = readb(base_addr + (CyMISR << index)); - mdm_status = readb(base_addr + (CyMSVR1 << index)); + /* determine the channel & change to that context */ + 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); - 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++; - - cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); - } + mdm_change = readb(base_addr + (CyMISR << index)); + mdm_status = readb(base_addr + (CyMSVR1 << index)); - 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_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); - cy_sched_event(info, - Cy_EVENT_WRITE_WAKEUP); - } - } 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 (!info->tty) + goto end; + + 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); } /* The real interrupt service routine is called @@ -1432,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 @@ -1470,11 +1353,16 @@ 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); + 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); @@ -1529,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)) { @@ -1554,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; @@ -1633,9 +1520,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 >= 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); @@ -1645,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 @@ -1717,9 +1605,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 +1667,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 +1689,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 @@ -1814,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: @@ -1824,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: @@ -1834,7 +1721,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); } @@ -1893,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]; @@ -1923,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; @@ -2491,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++) @@ -2812,7 +2697,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 +4328,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", @@ -4467,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); @@ -4502,7 +4385,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); @@ -5236,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 */ @@ -5480,13 +5362,13 @@ static int __init cy_init(void) #ifdef CONFIG_PCI /* look for pci boards */ retval = pci_register_driver(&cy_pci_driver); - if (retval && !nboards) - goto err_unr; + if (retval && !nboards) { + tty_unregister_driver(cy_serial_driver); + goto err_frtty; + } #endif return 0; -err_unr: - tty_unregister_driver(cy_serial_driver); err_frtty: put_tty_driver(cy_serial_driver); err: @@ -5496,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); @@ -5524,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); diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 8435fba73da..5dc1265ce1d 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -221,10 +221,8 @@ struct ipmi_smi void *send_info; #ifdef CONFIG_PROC_FS - /* A list of proc entries for this interface. This does not - need a lock, only one thread creates it and only one thread - destroys it. */ - spinlock_t proc_entry_lock; + /* A list of proc entries for this interface. */ + struct mutex proc_entry_lock; struct ipmi_proc_entry *proc_entries; #endif @@ -1891,11 +1889,11 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, file->write_proc = write_proc; file->owner = owner; - spin_lock(&smi->proc_entry_lock); + mutex_lock(&smi->proc_entry_lock); /* Stick it on the list. */ entry->next = smi->proc_entries; smi->proc_entries = entry; - spin_unlock(&smi->proc_entry_lock); + mutex_unlock(&smi->proc_entry_lock); } #endif /* CONFIG_PROC_FS */ @@ -1939,7 +1937,7 @@ static void remove_proc_entries(ipmi_smi_t smi) #ifdef CONFIG_PROC_FS struct ipmi_proc_entry *entry; - spin_lock(&smi->proc_entry_lock); + mutex_lock(&smi->proc_entry_lock); while (smi->proc_entries) { entry = smi->proc_entries; smi->proc_entries = entry->next; @@ -1948,7 +1946,7 @@ static void remove_proc_entries(ipmi_smi_t smi) kfree(entry->name); kfree(entry); } - spin_unlock(&smi->proc_entry_lock); + mutex_unlock(&smi->proc_entry_lock); remove_proc_entry(smi->proc_dir_name, proc_ipmi_root); #endif /* CONFIG_PROC_FS */ } @@ -2614,6 +2612,14 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) return; } +void ipmi_poll_interface(ipmi_user_t user) +{ + ipmi_smi_t intf = user->intf; + + if (intf->handlers->poll) + intf->handlers->poll(intf->send_info); +} + int ipmi_register_smi(struct ipmi_smi_handlers *handlers, void *send_info, struct ipmi_device_id *device_id, @@ -2671,7 +2677,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, } intf->curr_seq = 0; #ifdef CONFIG_PROC_FS - spin_lock_init(&intf->proc_entry_lock); + mutex_init(&intf->proc_entry_lock); #endif spin_lock_init(&intf->waiting_msgs_lock); INIT_LIST_HEAD(&intf->waiting_msgs); @@ -4166,6 +4172,7 @@ EXPORT_SYMBOL(ipmi_destroy_user); EXPORT_SYMBOL(ipmi_get_version); EXPORT_SYMBOL(ipmi_request_settime); EXPORT_SYMBOL(ipmi_request_supply_msgs); +EXPORT_SYMBOL(ipmi_poll_interface); EXPORT_SYMBOL(ipmi_register_smi); EXPORT_SYMBOL(ipmi_unregister_smi); EXPORT_SYMBOL(ipmi_register_for_cmd); diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index c1222e98525..4f560d0bb80 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -675,7 +675,8 @@ static void handle_transaction_done(struct smi_info *smi_info) } /* Called on timeouts and events. Timeouts should pass the elapsed - time, interrupts should pass in zero. */ + time, interrupts should pass in zero. Must be called with + si_lock held and interrupts disabled. */ static enum si_sm_result smi_event_handler(struct smi_info *smi_info, int time) { @@ -892,13 +893,16 @@ static int ipmi_thread(void *data) static void poll(void *send_info) { struct smi_info *smi_info = send_info; + unsigned long flags; /* * Make sure there is some delay in the poll loop so we can * drive time forward and timeout things. */ udelay(10); + spin_lock_irqsave(&smi_info->si_lock, flags); smi_event_handler(smi_info, 10); + spin_unlock_irqrestore(&smi_info->si_lock, flags); } static void request_events(void *send_info) @@ -1006,6 +1010,10 @@ static int smi_start_processing(void *send_info, new_smi->intf = intf; + /* Try to claim any interrupts. */ + if (new_smi->irq_setup) + new_smi->irq_setup(new_smi); + /* Set up the timer that drives the interface. */ setup_timer(&new_smi->si_timer, smi_timeout, (long)new_smi); new_smi->last_timeout_jiffies = jiffies; @@ -2372,20 +2380,9 @@ static int try_get_dev_id(struct smi_info *smi_info) /* Otherwise, we got some data. */ resp_len = smi_info->handlers->get_result(smi_info->si_sm, resp, IPMI_MAX_MSG_LENGTH); - if (resp_len < 14) { - /* That's odd, it should be longer. */ - rv = -EINVAL; - goto out; - } - if ((resp[1] != IPMI_GET_DEVICE_ID_CMD) || (resp[2] != 0)) { - /* That's odd, it shouldn't be able to fail. */ - rv = -EINVAL; - goto out; - } - - /* Record info from the get device id, in case we need it. */ - ipmi_demangle_device_id(resp+3, resp_len-3, &smi_info->device_id); + /* Check and record info from the get device id, in case we need it. */ + rv = ipmi_demangle_device_id(resp, resp_len, &smi_info->device_id); out: kfree(resp); @@ -2765,10 +2762,6 @@ static int try_smi_init(struct smi_info *new_smi) setup_oem_data_handler(new_smi); setup_xaction_handlers(new_smi); - /* Try to claim any interrupts. */ - if (new_smi->irq_setup) - new_smi->irq_setup(new_smi); - INIT_LIST_HEAD(&(new_smi->xmit_msgs)); INIT_LIST_HEAD(&(new_smi->hp_xmit_msgs)); new_smi->curr_msg = NULL; diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 41f78e2c158..e686fc92516 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -50,10 +50,19 @@ #include <linux/poll.h> #include <linux/string.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <asm/atomic.h> -#ifdef CONFIG_X86_LOCAL_APIC -#include <asm/apic.h> +#ifdef CONFIG_X86 +/* This is ugly, but I've determined that x86 is the only architecture + that can reasonably support the IPMI NMI watchdog timeout at this + time. If another architecture adds this capability somehow, it + will have to be a somewhat different mechanism and I have no idea + how it will work. So in the unlikely event that another + architecture supports this, we can figure out a good generic + mechanism for it at that time. */ +#include <asm/kdebug.h> +#define HAVE_DIE_NMI #endif #define PFX "IPMI Watchdog: " @@ -166,8 +175,6 @@ static char expect_close; static int ifnum_to_use = -1; -static DECLARE_RWSEM(register_sem); - /* Parameters to ipmi_set_timeout */ #define IPMI_SET_TIMEOUT_NO_HB 0 #define IPMI_SET_TIMEOUT_HB_IF_NECESSARY 1 @@ -193,11 +200,9 @@ static int set_param_int(const char *val, struct kernel_param *kp) if (endp == val) return -EINVAL; - down_read(®ister_sem); *((int *)kp->arg) = l; if (watchdog_user) rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); - up_read(®ister_sem); return rv; } @@ -226,17 +231,15 @@ static int set_param_str(const char *val, struct kernel_param *kp) s = strstrip(valcp); - down_read(®ister_sem); rv = fn(s, NULL); if (rv) - goto out_unlock; + goto out; check_parms(); if (watchdog_user) rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); - out_unlock: - up_read(®ister_sem); + out: return rv; } @@ -319,9 +322,12 @@ static unsigned char ipmi_version_minor; /* If a pretimeout occurs, this is used to allow only one panic to happen. */ static atomic_t preop_panic_excl = ATOMIC_INIT(-1); -static int ipmi_heartbeat(void); -static void panic_halt_ipmi_heartbeat(void); +#ifdef HAVE_DIE_NMI +static int testing_nmi; +static int nmi_handler_registered; +#endif +static int ipmi_heartbeat(void); /* We use a mutex to make sure that only one thing can send a set timeout at one time, because we only have one copy of the data. @@ -360,6 +366,9 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, int hbnow = 0; + /* These can be cleared as we are setting the timeout. */ + pretimeout_since_last_heartbeat = 0; + data[0] = 0; WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); @@ -434,31 +443,75 @@ static int ipmi_set_timeout(int do_heartbeat) wait_for_completion(&set_timeout_wait); + mutex_unlock(&set_timeout_lock); + if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) || ((send_heartbeat_now) && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) - { rv = ipmi_heartbeat(); - } - mutex_unlock(&set_timeout_lock); out: return rv; } -static void dummy_smi_free(struct ipmi_smi_msg *msg) +static atomic_t panic_done_count = ATOMIC_INIT(0); + +static void panic_smi_free(struct ipmi_smi_msg *msg) { + atomic_dec(&panic_done_count); } -static void dummy_recv_free(struct ipmi_recv_msg *msg) +static void panic_recv_free(struct ipmi_recv_msg *msg) { + atomic_dec(&panic_done_count); +} + +static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = +{ + .done = panic_smi_free +}; +static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = +{ + .done = panic_recv_free +}; + +static void panic_halt_ipmi_heartbeat(void) +{ + struct kernel_ipmi_msg msg; + struct ipmi_system_interface_addr addr; + int rv; + + /* Don't reset the timer if we have the timer turned off, that + re-enables the watchdog. */ + if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) + return; + + addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + addr.channel = IPMI_BMC_CHANNEL; + addr.lun = 0; + + msg.netfn = 0x06; + msg.cmd = IPMI_WDOG_RESET_TIMER; + msg.data = NULL; + msg.data_len = 0; + rv = ipmi_request_supply_msgs(watchdog_user, + (struct ipmi_addr *) &addr, + 0, + &msg, + NULL, + &panic_halt_heartbeat_smi_msg, + &panic_halt_heartbeat_recv_msg, + 1); + if (!rv) + atomic_add(2, &panic_done_count); } + static struct ipmi_smi_msg panic_halt_smi_msg = { - .done = dummy_smi_free + .done = panic_smi_free }; static struct ipmi_recv_msg panic_halt_recv_msg = { - .done = dummy_recv_free + .done = panic_recv_free }; /* Special call, doesn't claim any locks. This is only to be called @@ -470,13 +523,21 @@ static void panic_halt_ipmi_set_timeout(void) int send_heartbeat_now; int rv; + /* Wait for the messages to be free. */ + while (atomic_read(&panic_done_count) != 0) + ipmi_poll_interface(watchdog_user); rv = i_ipmi_set_timeout(&panic_halt_smi_msg, &panic_halt_recv_msg, &send_heartbeat_now); if (!rv) { + atomic_add(2, &panic_done_count); if (send_heartbeat_now) panic_halt_ipmi_heartbeat(); - } + } else + printk(KERN_WARNING PFX + "Unable to extend the watchdog timeout."); + while (atomic_read(&panic_done_count) != 0) + ipmi_poll_interface(watchdog_user); } /* We use a semaphore to make sure that only one thing can send a @@ -505,24 +566,14 @@ static struct ipmi_recv_msg heartbeat_recv_msg = .done = heartbeat_free_recv }; -static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = -{ - .done = dummy_smi_free -}; -static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = -{ - .done = dummy_recv_free -}; - static int ipmi_heartbeat(void) { struct kernel_ipmi_msg msg; int rv; struct ipmi_system_interface_addr addr; - if (ipmi_ignore_heartbeat) { + if (ipmi_ignore_heartbeat) return 0; - } if (ipmi_start_timer_on_heartbeat) { ipmi_start_timer_on_heartbeat = 0; @@ -533,7 +584,6 @@ static int ipmi_heartbeat(void) We don't want to set the action, though, we want to leave that alone (thus it can't be combined with the above operation. */ - pretimeout_since_last_heartbeat = 0; return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); } @@ -586,35 +636,6 @@ static int ipmi_heartbeat(void) return rv; } -static void panic_halt_ipmi_heartbeat(void) -{ - struct kernel_ipmi_msg msg; - struct ipmi_system_interface_addr addr; - - - /* Don't reset the timer if we have the timer turned off, that - re-enables the watchdog. */ - if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) - return; - - addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - addr.channel = IPMI_BMC_CHANNEL; - addr.lun = 0; - - msg.netfn = 0x06; - msg.cmd = IPMI_WDOG_RESET_TIMER; - msg.data = NULL; - msg.data_len = 0; - ipmi_request_supply_msgs(watchdog_user, - (struct ipmi_addr *) &addr, - 0, - &msg, - NULL, - &panic_halt_heartbeat_smi_msg, - &panic_halt_heartbeat_recv_msg, - 1); -} - static struct watchdog_info ident = { .options = 0, /* WDIOF_SETTIMEOUT, */ @@ -895,7 +916,6 @@ static void ipmi_register_watchdog(int ipmi_intf) { int rv = -EBUSY; - down_write(®ister_sem); if (watchdog_user) goto out; @@ -921,15 +941,56 @@ static void ipmi_register_watchdog(int ipmi_intf) printk(KERN_CRIT PFX "Unable to register misc device\n"); } - out: - up_write(®ister_sem); +#ifdef HAVE_DIE_NMI + if (nmi_handler_registered) { + int old_pretimeout = pretimeout; + int old_timeout = timeout; + int old_preop_val = preop_val; + + /* Set the pretimeout to go off in a second and give + ourselves plenty of time to stop the timer. */ + ipmi_watchdog_state = WDOG_TIMEOUT_RESET; + preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ + pretimeout = 99; + timeout = 100; + + testing_nmi = 1; + + rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); + if (rv) { + printk(KERN_WARNING PFX "Error starting timer to" + " test NMI: 0x%x. The NMI pretimeout will" + " likely not work\n", rv); + rv = 0; + goto out_restore; + } + + msleep(1500); + if (testing_nmi != 2) { + printk(KERN_WARNING PFX "IPMI NMI didn't seem to" + " occur. The NMI pretimeout will" + " likely not work\n"); + } + out_restore: + testing_nmi = 0; + preop_val = old_preop_val; + pretimeout = old_pretimeout; + timeout = old_timeout; + } +#endif + + out: if ((start_now) && (rv == 0)) { /* Run from startup, so start the timer now. */ start_now = 0; /* Disable this function after first startup. */ ipmi_watchdog_state = action_val; ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); printk(KERN_INFO PFX "Starting now!\n"); + } else { + /* Stop the timer now. */ + ipmi_watchdog_state = WDOG_TIMEOUT_NONE; + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); } } @@ -937,8 +998,6 @@ static void ipmi_unregister_watchdog(int ipmi_intf) { int rv; - down_write(®ister_sem); - if (!watchdog_user) goto out; @@ -963,20 +1022,44 @@ static void ipmi_unregister_watchdog(int ipmi_intf) watchdog_user = NULL; out: - up_write(®ister_sem); + return; } -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI static int -ipmi_nmi(void *dev_id, int cpu, int handled) +ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) { + struct die_args *args = data; + + if (val != DIE_NMI) + return NOTIFY_OK; + + /* Hack, if it's a memory or I/O error, ignore it. */ + if (args->err & 0xc0) + return NOTIFY_OK; + + /* + * If we get here, it's an NMI that's not a memory or I/O + * error. We can't truly tell if it's from IPMI or not + * without sending a message, and sending a message is almost + * impossible because of locking. + */ + + if (testing_nmi) { + testing_nmi = 2; + return NOTIFY_STOP; + } + /* If we are not expecting a timeout, ignore it. */ if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) - return NOTIFY_DONE; + return NOTIFY_OK; + + if (preaction_val != WDOG_PRETIMEOUT_NMI) + return NOTIFY_OK; /* If no one else handled the NMI, we assume it was the IPMI watchdog. */ - if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) { + if (preop_val == WDOG_PREOP_PANIC) { /* On some machines, the heartbeat will give an error and not work unless we re-enable the timer. So do so. */ @@ -985,18 +1068,12 @@ ipmi_nmi(void *dev_id, int cpu, int handled) panic(PFX "pre-timeout"); } - return NOTIFY_DONE; + return NOTIFY_STOP; } -static struct nmi_handler ipmi_nmi_handler = -{ - .link = LIST_HEAD_INIT(ipmi_nmi_handler.link), - .dev_name = "ipmi_watchdog", - .dev_id = NULL, - .handler = ipmi_nmi, - .priority = 0, /* Call us last. */ +static struct notifier_block ipmi_nmi_handler = { + .notifier_call = ipmi_nmi }; -int nmi_handler_registered; #endif static int wdog_reboot_handler(struct notifier_block *this, @@ -1009,7 +1086,7 @@ static int wdog_reboot_handler(struct notifier_block *this, /* Make sure we only do this once. */ reboot_event_handled = 1; - if (code == SYS_DOWN || code == SYS_HALT) { + if (code == SYS_POWER_OFF || code == SYS_HALT) { /* Disable the WDT if we are shutting down. */ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; panic_halt_ipmi_set_timeout(); @@ -1113,7 +1190,7 @@ static int preaction_op(const char *inval, char *outval) preaction_val = WDOG_PRETIMEOUT_NONE; else if (strcmp(inval, "pre_smi") == 0) preaction_val = WDOG_PRETIMEOUT_SMI; -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI else if (strcmp(inval, "pre_nmi") == 0) preaction_val = WDOG_PRETIMEOUT_NMI; #endif @@ -1147,7 +1224,7 @@ static int preop_op(const char *inval, char *outval) static void check_parms(void) { -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI int do_nmi = 0; int rv; @@ -1160,20 +1237,9 @@ static void check_parms(void) preop_op("preop_none", NULL); do_nmi = 0; } -#ifdef CONFIG_X86_LOCAL_APIC - if (nmi_watchdog == NMI_IO_APIC) { - printk(KERN_WARNING PFX "nmi_watchdog is set to IO APIC" - " mode (value is %d), that is incompatible" - " with using NMI in the IPMI watchdog." - " Disabling IPMI nmi pretimeout.\n", - nmi_watchdog); - preaction_val = WDOG_PRETIMEOUT_NONE; - do_nmi = 0; - } -#endif } if (do_nmi && !nmi_handler_registered) { - rv = request_nmi(&ipmi_nmi_handler); + rv = register_die_notifier(&ipmi_nmi_handler); if (rv) { printk(KERN_WARNING PFX "Can't register nmi handler\n"); @@ -1181,7 +1247,7 @@ static void check_parms(void) } else nmi_handler_registered = 1; } else if (!do_nmi && nmi_handler_registered) { - release_nmi(&ipmi_nmi_handler); + unregister_die_notifier(&ipmi_nmi_handler); nmi_handler_registered = 0; } #endif @@ -1217,9 +1283,9 @@ static int __init ipmi_wdog_init(void) rv = ipmi_smi_watcher_register(&smi_watcher); if (rv) { -#ifdef HAVE_NMI_HANDLER - if (preaction_val == WDOG_PRETIMEOUT_NMI) - release_nmi(&ipmi_nmi_handler); +#ifdef HAVE_DIE_NMI + if (nmi_handler_registered) + unregister_die_notifier(&ipmi_nmi_handler); #endif atomic_notifier_chain_unregister(&panic_notifier_list, &wdog_panic_notifier); @@ -1238,9 +1304,9 @@ static void __exit ipmi_wdog_exit(void) ipmi_smi_watcher_unregister(&smi_watcher); ipmi_unregister_watchdog(watchdog_ifnum); -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI if (nmi_handler_registered) - release_nmi(&ipmi_nmi_handler); + unregister_die_notifier(&ipmi_nmi_handler); #endif atomic_notifier_chain_unregister(&panic_notifier_list, diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 77a7a4a0662..85d596a3c18 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -1529,7 +1529,7 @@ static int __devinit reset_card(struct pci_dev *pdev, portcount = inw(base + 0x2); if (!inw(base + 0xe) & 0x1 || (portcount != 0 && portcount != 4 && portcount != 8 && portcount != 16)) { - dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.", + dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.\n", card + 1); retval = -EIO; goto end; @@ -1622,7 +1622,9 @@ static int __devinit load_firmware(struct pci_dev *pdev, if ((status = inw(base + 0x4)) != 0) { dev_warn(&pdev->dev, "Card%d rejected load header:\n" - "Address:0x%x\nCount:0x%x\nStatus:0x%x\n", + KERN_WARNING "Address:0x%x\n" + KERN_WARNING "Count:0x%x\n" + KERN_WARNING "Status:0x%x\n", index + 1, frame->addr, frame->count, status); goto errrelfw; } @@ -1666,7 +1668,9 @@ static int __devinit load_firmware(struct pci_dev *pdev, if ((status = inw(base + 0x4)) != 0) { dev_warn(&pdev->dev, "Card%d rejected verify header:\n" - "Address:0x%x\nCount:0x%x\nStatus: 0x%x\n", + KERN_WARNING "Address:0x%x\n" + KERN_WARNING "Count:0x%x\n" + KERN_WARNING "Status: 0x%x\n", index + 1, frame->addr, frame->count, status); goto errrelfw; } diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index ed76f0a127f..2fc255a2148 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -41,6 +41,7 @@ #include <linux/pci.h> #include <linux/init.h> #include <linux/bitops.h> +#include <linux/completion.h> #include <asm/system.h> #include <asm/io.h> @@ -142,7 +143,7 @@ struct moxa_port { struct tty_struct *tty; int cflag; wait_queue_head_t open_wait; - wait_queue_head_t close_wait; + struct completion close_wait; struct timer_list emptyTimer; @@ -166,7 +167,6 @@ struct moxa_port { #define WAKEUP_CHARS 256 -static int verbose = 0; static int ttymajor = MOXAMAJOR; /* Variables for insmod */ #ifdef MODULE @@ -184,7 +184,6 @@ module_param_array(baseaddr, int, NULL, 0); module_param_array(numports, int, NULL, 0); #endif module_param(ttymajor, int, 0); -module_param(verbose, bool, 0644); /* * static functions: @@ -208,13 +207,13 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file); static int moxa_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); static void moxa_poll(unsigned long); -static void set_tty_param(struct tty_struct *); -static int block_till_ready(struct tty_struct *, struct file *, +static void moxa_set_tty_param(struct tty_struct *); +static int moxa_block_till_ready(struct tty_struct *, struct file *, struct moxa_port *); -static void setup_empty_event(struct tty_struct *); -static void check_xmit_empty(unsigned long); -static void shut_down(struct moxa_port *); -static void receive_data(struct moxa_port *); +static void moxa_setup_empty_event(struct tty_struct *); +static void moxa_check_xmit_empty(unsigned long); +static void moxa_shut_down(struct moxa_port *); +static void moxa_receive_data(struct moxa_port *); /* * moxa board interface functions: */ @@ -283,8 +282,10 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, int retval; retval = pci_enable_device(pdev); - if (retval) + if (retval) { + dev_err(&pdev->dev, "can't enable pci device\n"); goto err; + } for (i = 0; i < MAX_BOARDS; i++) if (moxa_boards[i].basemem == NULL) @@ -292,16 +293,17 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, retval = -ENODEV; if (i >= MAX_BOARDS) { - if (verbose) - printk("More than %d MOXA Intellio family boards " + dev_warn(&pdev->dev, "more than %u MOXA Intellio family boards " "found. Board is ignored.\n", MAX_BOARDS); goto err; } board = &moxa_boards[i]; board->basemem = pci_iomap(pdev, 2, 0x4000); - if (board->basemem == NULL) + if (board->basemem == NULL) { + dev_err(&pdev->dev, "can't remap io space 2\n"); goto err; + } board->boardType = board_type; switch (board_type) { @@ -347,7 +349,8 @@ static int __init moxa_init(void) int i, numBoards, retval = 0; struct moxa_port *ch; - printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION); + printk(KERN_INFO "MOXA Intellio family driver version %s\n", + MOXA_VERSION); moxaDriver = alloc_tty_driver(MAX_PORTS + 1); if (!moxaDriver) return -ENOMEM; @@ -372,13 +375,13 @@ static int __init moxa_init(void) ch->closing_wait = 30 * HZ; ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; init_waitqueue_head(&ch->open_wait); - init_waitqueue_head(&ch->close_wait); + init_completion(&ch->close_wait); - setup_timer(&ch->emptyTimer, check_xmit_empty, + setup_timer(&ch->emptyTimer, moxa_check_xmit_empty, (unsigned long)ch); } - printk("Tty devices major number = %d\n", ttymajor); + pr_debug("Moxa tty devices major number = %d\n", ttymajor); if (tty_register_driver(moxaDriver)) { printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n"); @@ -400,11 +403,10 @@ static int __init moxa_init(void) moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts; moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA; moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr; - if (verbose) - printk("Board %2d: %s board(baseAddr=%lx)\n", - numBoards + 1, - moxa_brdname[moxa_boards[numBoards].boardType - 1], - moxa_boards[numBoards].baseAddr); + pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", + numBoards + 1, + moxa_brdname[moxa_boards[numBoards].boardType-1], + moxa_boards[numBoards].baseAddr); numBoards++; } } @@ -413,14 +415,13 @@ static int __init moxa_init(void) for (i = 0; i < MAX_BOARDS; i++) { if ((type[i] == MOXA_BOARD_C218_ISA) || (type[i] == MOXA_BOARD_C320_ISA)) { - if (verbose) - printk("Board %2d: %s board(baseAddr=%lx)\n", - numBoards + 1, - moxa_brdname[type[i] - 1], - (unsigned long) baseaddr[i]); + pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", + numBoards + 1, moxa_brdname[type[i] - 1], + (unsigned long)baseaddr[i]); if (numBoards >= MAX_BOARDS) { - if (verbose) - printk("More than %d MOXA Intellio family boards found. Board is ignored.", MAX_BOARDS); + printk(KERN_WARNING "More than %d MOXA " + "Intellio family boards found. Board " + "is ignored.\n", MAX_BOARDS); continue; } moxa_boards[numBoards].boardType = type[i]; @@ -456,16 +457,14 @@ static void __exit moxa_exit(void) { int i; - if (verbose) - printk("Unloading module moxa ...\n"); - del_timer_sync(&moxaTimer); for (i = 0; i < MAX_PORTS; i++) del_timer_sync(&moxa_ports[i].emptyTimer); if (tty_unregister_driver(moxaDriver)) - printk("Couldn't unregister MOXA Intellio family serial driver\n"); + printk(KERN_ERR "Couldn't unregister MOXA Intellio family " + "serial driver\n"); put_tty_driver(moxaDriver); #ifdef CONFIG_PCI @@ -475,9 +474,6 @@ static void __exit moxa_exit(void) for (i = 0; i < MAX_BOARDS; i++) if (moxa_boards[i].basemem) iounmap(moxa_boards[i].basemem); - - if (verbose) - printk("Done\n"); } module_init(moxa_init); @@ -504,12 +500,12 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) ch->tty = tty; if (!(ch->asyncflags & ASYNC_INITIALIZED)) { ch->statusflags = 0; - set_tty_param(tty); + moxa_set_tty_param(tty); MoxaPortLineCtrl(ch->port, 1, 1); MoxaPortEnable(ch->port); ch->asyncflags |= ASYNC_INITIALIZED; } - retval = block_till_ready(tty, filp, ch); + retval = moxa_block_till_ready(tty, filp, ch); moxa_unthrottle(tty); @@ -532,9 +528,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) return; } if (!MoxaPortIsValid(port)) { -#ifdef SERIAL_DEBUG_CLOSE - printk("Invalid portno in moxa_close\n"); -#endif + pr_debug("Invalid portno in moxa_close\n"); tty->driver_data = NULL; return; } @@ -547,13 +541,13 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) ch = (struct moxa_port *) tty->driver_data; if ((tty->count == 1) && (ch->count != 1)) { - printk("moxa_close: bad serial port count; tty->count is 1, " - "ch->count is %d\n", ch->count); + printk(KERN_WARNING "moxa_close: bad serial port count; " + "tty->count is 1, ch->count is %d\n", ch->count); ch->count = 1; } if (--ch->count < 0) { - printk("moxa_close: bad serial port count, device=%s\n", - tty->name); + printk(KERN_WARNING "moxa_close: bad serial port count, " + "device=%s\n", tty->name); ch->count = 0; } if (ch->count) { @@ -563,11 +557,11 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) ch->cflag = tty->termios->c_cflag; if (ch->asyncflags & ASYNC_INITIALIZED) { - setup_empty_event(tty); + moxa_setup_empty_event(tty); tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ del_timer_sync(&moxa_ports[ch->port].emptyTimer); } - shut_down(ch); + moxa_shut_down(ch); MoxaPortFlushData(port, 2); if (tty->driver->flush_buffer) @@ -584,7 +578,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) wake_up_interruptible(&ch->open_wait); } ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); - wake_up_interruptible(&ch->close_wait); + complete_all(&ch->close_wait); } static int moxa_write(struct tty_struct *tty, @@ -653,7 +647,7 @@ static int moxa_chars_in_buffer(struct tty_struct *tty) * in tty_ioctl.c, etc. */ if (!(ch->statusflags & EMPTYWAIT)) - setup_empty_event(tty); + moxa_setup_empty_event(tty); } return (chars); } @@ -751,7 +745,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, retval = tty_check_change(tty); if (retval) return (retval); - setup_empty_event(tty); + moxa_setup_empty_event(tty); tty_wait_until_sent(tty, 0); if (!arg) MoxaPortSendBreak(ch->port, 0); @@ -760,7 +754,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file, retval = tty_check_change(tty); if (retval) return (retval); - setup_empty_event(tty); + moxa_setup_empty_event(tty); tty_wait_until_sent(tty, 0); MoxaPortSendBreak(ch->port, arg); return (0); @@ -809,7 +803,7 @@ static void moxa_set_termios(struct tty_struct *tty, if (ch == NULL) return; - set_tty_param(tty); + moxa_set_tty_param(tty); if (!(old_termios->c_cflag & CLOCAL) && (tty->termios->c_cflag & CLOCAL)) wake_up_interruptible(&ch->open_wait); @@ -845,7 +839,7 @@ static void moxa_hangup(struct tty_struct *tty) struct moxa_port *ch = (struct moxa_port *) tty->driver_data; moxa_flush_buffer(tty); - shut_down(ch); + moxa_shut_down(ch); ch->event = 0; ch->count = 0; ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; @@ -875,7 +869,7 @@ static void moxa_poll(unsigned long ignored) continue; if (!(ch->statusflags & THROTTLE) && (MoxaPortRxQueue(ch->port) > 0)) - receive_data(ch); + moxa_receive_data(ch); if ((tp = ch->tty) == 0) continue; if (ch->statusflags & LOWWAIT) { @@ -909,7 +903,7 @@ static void moxa_poll(unsigned long ignored) /******************************************************************************/ -static void set_tty_param(struct tty_struct *tty) +static void moxa_set_tty_param(struct tty_struct *tty) { register struct ktermios *ts; struct moxa_port *ch; @@ -934,7 +928,7 @@ static void set_tty_param(struct tty_struct *tty) MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty)); } -static int block_till_ready(struct tty_struct *tty, struct file *filp, +static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, struct moxa_port *ch) { DECLARE_WAITQUEUE(wait,current); @@ -948,7 +942,7 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, */ if (tty_hung_up_p(filp) || (ch->asyncflags & ASYNC_CLOSING)) { if (ch->asyncflags & ASYNC_CLOSING) - interruptible_sleep_on(&ch->close_wait); + wait_for_completion_interruptible(&ch->close_wait); #ifdef SERIAL_DO_RESTART if (ch->asyncflags & ASYNC_HUP_NOTIFY) return (-EAGAIN); @@ -971,10 +965,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, */ retval = 0; add_wait_queue(&ch->open_wait, &wait); -#ifdef SERIAL_DEBUG_OPEN - printk("block_til_ready before block: ttys%d, count = %d\n", - ch->line, ch->count); -#endif + pr_debug("block_til_ready before block: ttys%d, count = %d\n", + ch->port, ch->count); spin_lock_irqsave(&moxa_lock, flags); if (!tty_hung_up_p(filp)) ch->count--; @@ -1013,10 +1005,8 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, ch->count++; ch->blocked_open--; spin_unlock_irqrestore(&moxa_lock, flags); -#ifdef SERIAL_DEBUG_OPEN - printk("block_til_ready after blocking: ttys%d, count = %d\n", - ch->line, ch->count); -#endif + pr_debug("block_til_ready after blocking: ttys%d, count = %d\n", + ch->port, ch->count); if (retval) return (retval); /* FIXME: review to see if we need to use set_bit on these */ @@ -1024,7 +1014,7 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp, return 0; } -static void setup_empty_event(struct tty_struct *tty) +static void moxa_setup_empty_event(struct tty_struct *tty) { struct moxa_port *ch = tty->driver_data; unsigned long flags; @@ -1035,24 +1025,24 @@ static void setup_empty_event(struct tty_struct *tty) spin_unlock_irqrestore(&moxa_lock, flags); } -static void check_xmit_empty(unsigned long data) +static void moxa_check_xmit_empty(unsigned long data) { struct moxa_port *ch; ch = (struct moxa_port *) data; - del_timer_sync(&moxa_ports[ch->port].emptyTimer); if (ch->tty && (ch->statusflags & EMPTYWAIT)) { if (MoxaPortTxQueue(ch->port) == 0) { ch->statusflags &= ~EMPTYWAIT; tty_wakeup(ch->tty); return; } - mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ); + mod_timer(&moxa_ports[ch->port].emptyTimer, + round_jiffies(jiffies + HZ)); } else ch->statusflags &= ~EMPTYWAIT; } -static void shut_down(struct moxa_port *ch) +static void moxa_shut_down(struct moxa_port *ch) { struct tty_struct *tp; @@ -1072,7 +1062,7 @@ static void shut_down(struct moxa_port *ch) ch->asyncflags &= ~ASYNC_INITIALIZED; } -static void receive_data(struct moxa_port *ch) +static void moxa_receive_data(struct moxa_port *ch) { struct tty_struct *tp; struct ktermios *ts; @@ -1406,8 +1396,8 @@ static struct mon_str moxaLog; static int moxaFuncTout = HZ / 2; static void moxafunc(void __iomem *, int, ushort); -static void wait_finish(void __iomem *); -static void low_water_check(void __iomem *); +static void moxa_wait_finish(void __iomem *); +static void moxa_low_water_check(void __iomem *); static int moxaloadbios(int, unsigned char __user *, int); static int moxafindcard(int); static int moxaload320b(int, unsigned char __user *, int); @@ -1473,7 +1463,7 @@ void MoxaPortFlushData(int port, int mode) moxafunc(ofsAddr, FC_FlushQueue, mode); if (mode != 1) { moxa_ports[port].lowChkFlag = 0; - low_water_check(ofsAddr); + moxa_low_water_check(ofsAddr); } } @@ -1654,7 +1644,7 @@ int MoxaDriverPoll(void) if (moxa_ports[p].lowChkFlag) { moxa_ports[p].lowChkFlag = 0; ofsAddr = moxa_ports[p].tableAddr; - low_water_check(ofsAddr); + moxa_low_water_check(ofsAddr); } } } @@ -2081,7 +2071,7 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) writeb(termio->c_cc[VSTART], ofsAddr + FuncArg); writeb(termio->c_cc[VSTOP], ofsAddr + FuncArg1); writeb(FC_SetXonXoff, ofsAddr + FuncCode); - wait_finish(ofsAddr); + moxa_wait_finish(ofsAddr); } return (0); @@ -2480,10 +2470,10 @@ static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg) writew(arg, ofsAddr + FuncArg); writew(cmd, ofsAddr + FuncCode); - wait_finish(ofsAddr); + moxa_wait_finish(ofsAddr); } -static void wait_finish(void __iomem *ofsAddr) +static void moxa_wait_finish(void __iomem *ofsAddr) { unsigned long i, j; @@ -2496,7 +2486,7 @@ static void wait_finish(void __iomem *ofsAddr) } } -static void low_water_check(void __iomem *ofsAddr) +static void moxa_low_water_check(void __iomem *ofsAddr) { int len; ushort rptr, wptr, mask; diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 2aee3fef041..661aca0e155 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -383,7 +383,6 @@ static int mxser_init(void); /* static void mxser_poll(unsigned long); */ static int mxser_get_ISA_conf(int, struct mxser_hwconf *); -static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); static void mxser_do_softint(struct work_struct *); static int mxser_open(struct tty_struct *, struct file *); static void mxser_close(struct tty_struct *, struct file *); @@ -422,7 +421,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout); static void mxser_startrx(struct tty_struct *tty); static void mxser_stoprx(struct tty_struct *tty); - +#ifdef CONFIG_PCI static int CheckIsMoxaMust(int io) { u8 oldmcr, hwid; @@ -445,6 +444,7 @@ static int CheckIsMoxaMust(int io) } return MOXA_OTHER_UART; } +#endif /* above is modified by Victor Yu. 08-15-2002 */ @@ -1938,14 +1938,6 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id) inb(info->base + UART_MSR); continue; } - /* above add by Victor Yu. 09-13-2002 */ - /* - if (info->tty->flip.count < TTY_FLIPBUF_SIZE / 4) { - info->IER |= MOXA_MUST_RECV_ISR; - outb(info->IER, info->base + UART_IER); - } - */ - /* mask by Victor Yu. 09-13-2002 if ( !info->tty || @@ -2599,19 +2591,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct ktermios *old_te info->IER |= UART_IER_MSI; if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { info->MCR |= UART_MCR_AFE; - /* status = mxser_get_msr(info->base, 0, info->port); */ -/* - save_flags(flags); - cli(); - status = inb(baseaddr + UART_MSR); - restore_flags(flags); -*/ - /* mxser_check_modem_status(info, status); */ } else { - /* status = mxser_get_msr(info->base, 0, info->port); */ - /* MX_LOCK(&info->slock); */ status = inb(info->base + UART_MSR); - /* MX_UNLOCK(&info->slock); */ if (info->tty->hw_stopped) { if (status & UART_MSR_CTS) { info->tty->hw_stopped = 0; diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index 6a563932ba1..854dbf59eb6 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c @@ -2,7 +2,7 @@ * mxser.c -- MOXA Smartio/Industio family multiport serial driver. * * Copyright (C) 1999-2006 Moxa Technologies (support@moxa.com.tw). - * Copyright (C) 2006 Jiri Slaby <jirislaby@gmail.com> + * Copyright (C) 2006-2007 Jiri Slaby <jirislaby@gmail.com> * * This code is loosely based on the 1.8 moxa driver which is based on * Linux serial driver, written by Linus Torvalds, Theodore T'so and @@ -48,7 +48,7 @@ #include "mxser_new.h" -#define MXSER_VERSION "2.0.1" /* 1.9.15 */ +#define MXSER_VERSION "2.0.2" /* 1.10 */ #define MXSERMAJOR 174 #define MXSERCUMAJOR 175 @@ -72,6 +72,12 @@ #define UART_MCR_AFE 0x20 #define UART_LSR_SPECIAL 0x1E +#define PCI_DEVICE_ID_CB108 0x1080 +#define PCI_DEVICE_ID_CB114 0x1142 +#define PCI_DEVICE_ID_CB134I 0x1341 +#define PCI_DEVICE_ID_CP138U 0x1380 +#define PCI_DEVICE_ID_POS104UL 0x1044 + #define C168_ASIC_ID 1 #define C104_ASIC_ID 2 @@ -107,71 +113,63 @@ struct mxser_cardinfo { }; static const struct mxser_cardinfo mxser_cards[] = { - { 8, "C168 series", }, /* C168-ISA */ - { 4, "C104 series", }, /* C104-ISA */ - { 4, "CI-104J series", }, /* CI104J */ - { 8, "C168H/PCI series", }, /* C168-PCI */ - { 4, "C104H/PCI series", }, /* C104-PCI */ - { 4, "C102 series", MXSER_HAS2 }, /* C102-ISA */ - { 4, "CI-132 series", MXSER_HAS2 }, /* CI132 */ - { 4, "CI-134 series", }, /* CI134 */ - { 2, "CP-132 series", }, /* CP132 */ - { 4, "CP-114 series", }, /* CP114 */ - { 4, "CT-114 series", }, /* CT114 */ - { 2, "CP-102 series", MXSER_HIGHBAUD }, /* CP102 */ - { 4, "CP-104U series", }, /* CP104U */ - { 8, "CP-168U series", }, /* CP168U */ - { 2, "CP-132U series", }, /* CP132U */ - { 4, "CP-134U series", }, /* CP134U */ - { 4, "CP-104JU series", }, /* CP104JU */ +/* 0*/ { 8, "C168 series", }, + { 4, "C104 series", }, + { 4, "CI-104J series", }, + { 8, "C168H/PCI series", }, + { 4, "C104H/PCI series", }, +/* 5*/ { 4, "C102 series", MXSER_HAS2 }, /* C102-ISA */ + { 4, "CI-132 series", MXSER_HAS2 }, + { 4, "CI-134 series", }, + { 2, "CP-132 series", }, + { 4, "CP-114 series", }, +/*10*/ { 4, "CT-114 series", }, + { 2, "CP-102 series", MXSER_HIGHBAUD }, + { 4, "CP-104U series", }, + { 8, "CP-168U series", }, + { 2, "CP-132U series", }, +/*15*/ { 4, "CP-134U series", }, + { 4, "CP-104JU series", }, { 8, "Moxa UC7000 Serial", }, /* RC7000 */ - { 8, "CP-118U series", }, /* CP118U */ - { 2, "CP-102UL series", }, /* CP102UL */ - { 2, "CP-102U series", }, /* CP102U */ - { 8, "CP-118EL series", }, /* CP118EL */ - { 8, "CP-168EL series", }, /* CP168EL */ - { 4, "CP-104EL series", } /* CP104EL */ + { 8, "CP-118U series", }, + { 2, "CP-102UL series", }, +/*20*/ { 2, "CP-102U series", }, + { 8, "CP-118EL series", }, + { 8, "CP-168EL series", }, + { 4, "CP-104EL series", }, + { 8, "CB-108 series", }, +/*25*/ { 4, "CB-114 series", }, + { 4, "CB-134I series", }, + { 8, "CP-138U series", }, + { 4, "POS-104UL series", } }; /* driver_data correspond to the lines in the structure above see also ISA probe function before you change something */ static struct pci_device_id mxser_pcibrds[] = { - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168), - .driver_data = 3 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C104), - .driver_data = 4 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132), - .driver_data = 8 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114), - .driver_data = 9 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CT114), - .driver_data = 10 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102), - .driver_data = 11 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104U), - .driver_data = 12 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168U), - .driver_data = 13 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132U), - .driver_data = 14 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134U), - .driver_data = 15 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104JU), - .driver_data = 16 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_RC7000), - .driver_data = 17 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118U), - .driver_data = 18 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102UL), - .driver_data = 19 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102U), - .driver_data = 20 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL), - .driver_data = 21 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL), - .driver_data = 22 }, - { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL), - .driver_data = 23 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 3 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104), .driver_data = 4 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 8 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114), .driver_data = 9 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114), .driver_data = 10 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102), .driver_data = 11 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U), .driver_data = 12 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U), .driver_data = 13 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U), .driver_data = 14 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U), .driver_data = 15 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 16 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000), .driver_data = 17 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U), .driver_data = 18 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 19 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U), .driver_data = 20 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 21 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 22 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 23 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108), .driver_data = 24 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114), .driver_data = 25 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I), .driver_data = 26 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U), .driver_data = 27 }, + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL), .driver_data = 28 }, { } }; MODULE_DEVICE_TABLE(pci, mxser_pcibrds); diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 73de77105fe..706ff34728f 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -318,7 +318,7 @@ int pty_limit = NR_UNIX98_PTY_DEFAULT; static int pty_limit_min = 0; static int pty_limit_max = NR_UNIX98_PTY_MAX; -ctl_table pty_table[] = { +static struct ctl_table pty_table[] = { { .ctl_name = PTY_MAX, .procname = "max", @@ -340,6 +340,27 @@ ctl_table pty_table[] = { } }; +static struct ctl_table pty_kern_table[] = { + { + .ctl_name = KERN_PTY, + .procname = "pty", + .mode = 0555, + .child = pty_table, + }, + {} +}; + +static struct ctl_table pty_root_table[] = { + { + .ctl_name = CTL_KERN, + .procname = "kernel", + .mode = 0555, + .child = pty_kern_table, + }, + {} +}; + + static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { @@ -404,6 +425,7 @@ static void __init unix98_pty_init(void) panic("Couldn't register Unix98 pts driver"); pty_table[1].data = &ptm_driver->refcount; + register_sysctl_table(pty_root_table); } #else static inline void unix98_pty_init(void) { } diff --git a/drivers/char/random.c b/drivers/char/random.c index af274e5a25e..1756b1f7cb7 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -649,7 +649,7 @@ EXPORT_SYMBOL_GPL(add_input_randomness); void add_interrupt_randomness(int irq) { - if (irq >= NR_IRQS || irq_timer_state[irq] == 0) + if (irq >= NR_IRQS || irq_timer_state[irq] == NULL) return; DEBUG_ENT("irq event %d\n", irq); diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 56cbba7b6ec..7e6a3a413bb 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -84,6 +84,7 @@ #include <linux/mutex.h> #include <linux/ioport.h> #include <linux/delay.h> +#include <linux/completion.h> #include <linux/wait.h> #include <linux/pci.h> #include <asm/uaccess.h> @@ -548,8 +549,8 @@ static void rp_handle_port(struct r_port *info) static void rp_do_poll(unsigned long dummy) { CONTROLLER_t *ctlp; - int ctrl, aiop, ch, line, i; - unsigned int xmitmask; + int ctrl, aiop, ch, line; + unsigned int xmitmask, i; unsigned int CtlMask; unsigned char AiopMask; Word_t bit; @@ -650,7 +651,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) info->closing_wait = 3000; info->close_delay = 50; init_waitqueue_head(&info->open_wait); - init_waitqueue_head(&info->close_wait); + init_completion(&info->close_wait); info->flags &= ~ROCKET_MODE_MASK; switch (pc104[board][line]) { case 422: @@ -699,8 +700,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) spin_lock_init(&info->slock); mutex_init(&info->write_mtx); rp_table[line] = info; - if (pci_dev) - tty_register_device(rocket_driver, line, &pci_dev->dev); + tty_register_device(rocket_driver, line, pci_dev ? &pci_dev->dev : + NULL); } /* @@ -878,7 +879,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, if (tty_hung_up_p(filp)) return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); if (info->flags & ROCKET_CLOSING) { - interruptible_sleep_on(&info->close_wait); + if (wait_for_completion_interruptible(&info->close_wait)) + return -ERESTARTSYS; return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } @@ -983,8 +985,10 @@ static int rp_open(struct tty_struct *tty, struct file *filp) return -ENOMEM; if (info->flags & ROCKET_CLOSING) { - interruptible_sleep_on(&info->close_wait); + retval = wait_for_completion_interruptible(&info->close_wait); free_page(page); + if (retval) + return retval; return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } @@ -1176,7 +1180,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp) } info->flags &= ~(ROCKET_INITIALIZED | ROCKET_CLOSING | ROCKET_NORMAL_ACTIVE); tty->closing = 0; - wake_up_interruptible(&info->close_wait); + complete_all(&info->close_wait); atomic_dec(&rp_num_ports_open); #ifdef ROCKET_DEBUG_OPEN @@ -1869,8 +1873,6 @@ static __init int register_PCI(int i, struct pci_dev *dev) int fast_clock = 0; int altChanRingIndicator = 0; int ports_per_aiop = 8; - int ret; - unsigned int class_rev; WordIO_t ConfigIO = 0; ByteIO_t UPCIRingInd = 0; @@ -1878,12 +1880,6 @@ static __init int register_PCI(int i, struct pci_dev *dev) return 0; rcktpt_io_addr[i] = pci_resource_start(dev, 0); - ret = pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); - - if (ret) { - printk(KERN_INFO " Error during register_PCI(), unable to read config dword \n"); - return 0; - } rcktpt_type[i] = ROCKET_TYPE_NORMAL; rocketModel[i].loadrm2 = 0; @@ -2037,8 +2033,9 @@ static __init int register_PCI(int i, struct pci_dev *dev) ports_per_aiop = 6; str = "6-port"; - /* If class_rev is 1, the rocketmodem flash must be loaded. If it is 2 it is a "socketed" version. */ - if ((class_rev & 0xFF) == 1) { + /* If revision is 1, the rocketmodem flash must be loaded. + * If it is 2 it is a "socketed" version. */ + if (dev->revision == 1) { rcktpt_type[i] = ROCKET_TYPE_MODEMII; rocketModel[i].loadrm2 = 1; } else { @@ -2053,7 +2050,7 @@ static __init int register_PCI(int i, struct pci_dev *dev) max_num_aiops = 1; ports_per_aiop = 4; str = "4-port"; - if ((class_rev & 0xFF) == 1) { + if (dev->revision == 1) { rcktpt_type[i] = ROCKET_TYPE_MODEMII; rocketModel[i].loadrm2 = 1; } else { @@ -2362,26 +2359,14 @@ static const struct tty_operations rocket_ops = { */ static int __init rp_init(void) { - int retval, pci_boards_found, isa_boards_found, i; + int ret = -ENOMEM, pci_boards_found, isa_boards_found, i; printk(KERN_INFO "RocketPort device driver module, version %s, %s\n", ROCKET_VERSION, ROCKET_DATE); rocket_driver = alloc_tty_driver(MAX_RP_PORTS); if (!rocket_driver) - return -ENOMEM; - - /* - * Initialize the array of pointers to our own internal state - * structures. - */ - memset(rp_table, 0, sizeof (rp_table)); - memset(xmit_flags, 0, sizeof (xmit_flags)); - - for (i = 0; i < MAX_RP_PORTS; i++) - lineNumbers[i] = 0; - nextLineNumber = 0; - memset(rocketModel, 0, sizeof (rocketModel)); + goto err; /* * If board 1 is non-zero, there is at least one ISA configured. If controller is @@ -2396,8 +2381,11 @@ static int __init rp_init(void) /* If an ISA card is configured, reserve the 4 byte IO space for the Mudbac controller */ if (controller && (!request_region(controller, 4, "Comtrol RocketPort"))) { - printk(KERN_INFO "Unable to reserve IO region for first configured ISA RocketPort controller 0x%lx. Driver exiting \n", controller); - return -EBUSY; + printk(KERN_ERR "Unable to reserve IO region for first " + "configured ISA RocketPort controller 0x%lx. " + "Driver exiting\n", controller); + ret = -EBUSY; + goto err_tty; } /* Store ISA variable retrieved from command line or .conf file. */ @@ -2434,15 +2422,14 @@ static int __init rp_init(void) rocket_driver->init_termios.c_ispeed = 9600; rocket_driver->init_termios.c_ospeed = 9600; #ifdef ROCKET_SOFT_FLOW - rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + rocket_driver->flags |= TTY_DRIVER_REAL_RAW; #endif tty_set_operations(rocket_driver, &rocket_ops); - retval = tty_register_driver(rocket_driver); - if (retval < 0) { - printk(KERN_INFO "Couldn't install tty RocketPort driver (error %d)\n", -retval); - put_tty_driver(rocket_driver); - return -1; + ret = tty_register_driver(rocket_driver); + if (ret < 0) { + printk(KERN_ERR "Couldn't install tty RocketPort driver\n"); + goto err_tty; } #ifdef ROCKET_DEBUG_OPEN @@ -2469,14 +2456,18 @@ static int __init rp_init(void) max_board = pci_boards_found + isa_boards_found; if (max_board == 0) { - printk(KERN_INFO "No rocketport ports found; unloading driver.\n"); - del_timer_sync(&rocket_timer); - tty_unregister_driver(rocket_driver); - put_tty_driver(rocket_driver); - return -ENXIO; + printk(KERN_ERR "No rocketport ports found; unloading driver\n"); + ret = -ENXIO; + goto err_ttyu; } return 0; +err_ttyu: + tty_unregister_driver(rocket_driver); +err_tty: + put_tty_driver(rocket_driver); +err: + return ret; } @@ -2491,10 +2482,14 @@ static void rp_cleanup_module(void) if (retval) printk(KERN_INFO "Error %d while trying to unregister " "rocketport driver\n", -retval); - put_tty_driver(rocket_driver); for (i = 0; i < MAX_RP_PORTS; i++) - kfree(rp_table[i]); + if (rp_table[i]) { + tty_unregister_device(rocket_driver, i); + kfree(rp_table[i]); + } + + put_tty_driver(rocket_driver); for (i = 0; i < NUM_BOARDS; i++) { if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h index b4c53dfa795..55b8f2d71a9 100644 --- a/drivers/char/rocket_int.h +++ b/drivers/char/rocket_int.h @@ -1163,13 +1163,8 @@ struct r_port { int read_status_mask; int cps; -#ifdef DECLARE_WAITQUEUE wait_queue_head_t open_wait; - wait_queue_head_t close_wait; -#else - struct wait_queue *open_wait; - struct wait_queue *close_wait; -#endif + struct completion close_wait; spinlock_t slock; struct mutex write_mtx; }; diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index 745d552620b..0def089cc1f 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c @@ -228,7 +228,8 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate); * and will all go away once this is done. */ -void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud) +void tty_termios_encode_baud_rate(struct ktermios *termios, + speed_t ibaud, speed_t obaud) { int i = 0; int ifound = -1, ofound = -1; @@ -263,11 +264,15 @@ void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed */ do { - if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) { + if (obaud - oclose <= baud_table[i] && + obaud + oclose >= baud_table[i]) { termios->c_cflag |= baud_bits[i]; ofound = i; } - if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) { + if (ibaud - iclose <= baud_table[i] && + ibaud + iclose >= baud_table[i]) { + /* For the case input == output don't set IBAUD bits + if the user didn't do so */ if (ofound == i && !ibinput) ifound = i; #ifdef IBSHIFT diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 645ad980898..1764c67b585 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -158,11 +158,7 @@ static void blank_screen_t(unsigned long dummy); static void set_palette(struct vc_data *vc); static int printable; /* Is console ready for printing? */ -#ifdef CONFIG_VT_UNICODE -int default_utf8 = 1; -#else -int default_utf8; -#endif +int default_utf8 = true; module_param(default_utf8, int, S_IRUGO | S_IWUSR); /* |