aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/imx.c68
-rw-r--r--drivers/serial/ioc4_serial.c50
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_neo.c2
-rw-r--r--drivers/serial/jsm/jsm_tty.c4
-rw-r--r--drivers/serial/serial_cs.c173
-rw-r--r--drivers/serial/sn_console.c4
8 files changed, 198 insertions, 106 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 218b69372c0b..0d9358608fdf 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -51,7 +51,7 @@
51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option 51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option
52 * is unsafe when used on edge-triggered interrupts. 52 * is unsafe when used on edge-triggered interrupts.
53 */ 53 */
54unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 54static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
55 55
56/* 56/*
57 * Debugging. 57 * Debugging.
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index c682c6308cde..01a8726a3f97 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -321,18 +321,39 @@ static void imx_break_ctl(struct uart_port *port, int break_state)
321#define TXTL 2 /* reset default */ 321#define TXTL 2 /* reset default */
322#define RXTL 1 /* reset default */ 322#define RXTL 1 /* reset default */
323 323
324static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
325{
326 unsigned int val;
327 unsigned int ufcr_rfdiv;
328
329 /* set receiver / transmitter trigger level.
330 * RFDIV is set such way to satisfy requested uartclk value
331 */
332 val = TXTL<<10 | RXTL;
333 ufcr_rfdiv = (imx_get_perclk1() + sport->port.uartclk / 2) / sport->port.uartclk;
334
335 if(!ufcr_rfdiv)
336 ufcr_rfdiv = 1;
337
338 if(ufcr_rfdiv >= 7)
339 ufcr_rfdiv = 6;
340 else
341 ufcr_rfdiv = 6 - ufcr_rfdiv;
342
343 val |= UFCR_RFDIV & (ufcr_rfdiv << 7);
344
345 UFCR((u32)sport->port.membase) = val;
346
347 return 0;
348}
349
324static int imx_startup(struct uart_port *port) 350static int imx_startup(struct uart_port *port)
325{ 351{
326 struct imx_port *sport = (struct imx_port *)port; 352 struct imx_port *sport = (struct imx_port *)port;
327 int retval; 353 int retval;
328 unsigned int val;
329 unsigned long flags; 354 unsigned long flags;
330 355
331 /* set receiver / transmitter trigger level. We assume 356 imx_setup_ufcr(sport, 0);
332 * that RFDIV has been set by the arch setup or by the bootloader.
333 */
334 val = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) | TXTL<<10 | RXTL;
335 UFCR((u32)sport->port.membase) = val;
336 357
337 /* disable the DREN bit (Data Ready interrupt enable) before 358 /* disable the DREN bit (Data Ready interrupt enable) before
338 * requesting IRQs 359 * requesting IRQs
@@ -737,9 +758,12 @@ static void __init
737imx_console_get_options(struct imx_port *sport, int *baud, 758imx_console_get_options(struct imx_port *sport, int *baud,
738 int *parity, int *bits) 759 int *parity, int *bits)
739{ 760{
761
740 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) { 762 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) {
741 /* ok, the port was enabled */ 763 /* ok, the port was enabled */
742 unsigned int ucr2, ubir,ubmr, uartclk; 764 unsigned int ucr2, ubir,ubmr, uartclk;
765 unsigned int baud_raw;
766 unsigned int ucfr_rfdiv;
743 767
744 ucr2 = UCR2((u32)sport->port.membase); 768 ucr2 = UCR2((u32)sport->port.membase);
745 769
@@ -758,9 +782,35 @@ imx_console_get_options(struct imx_port *sport, int *baud,
758 782
759 ubir = UBIR((u32)sport->port.membase) & 0xffff; 783 ubir = UBIR((u32)sport->port.membase) & 0xffff;
760 ubmr = UBMR((u32)sport->port.membase) & 0xffff; 784 ubmr = UBMR((u32)sport->port.membase) & 0xffff;
761 uartclk = sport->port.uartclk;
762 785
763 *baud = ((uartclk/16) * (ubir + 1)) / (ubmr + 1); 786
787 ucfr_rfdiv = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) >> 7;
788 if (ucfr_rfdiv == 6)
789 ucfr_rfdiv = 7;
790 else
791 ucfr_rfdiv = 6 - ucfr_rfdiv;
792
793 uartclk = imx_get_perclk1();
794 uartclk /= ucfr_rfdiv;
795
796 { /*
797 * The next code provides exact computation of
798 * baud_raw = round(((uartclk/16) * (ubir + 1)) / (ubmr + 1))
799 * without need of float support or long long division,
800 * which would be required to prevent 32bit arithmetic overflow
801 */
802 unsigned int mul = ubir + 1;
803 unsigned int div = 16 * (ubmr + 1);
804 unsigned int rem = uartclk % div;
805
806 baud_raw = (uartclk / div) * mul;
807 baud_raw += (rem * mul + div / 2) / div;
808 *baud = (baud_raw + 50) / 100 * 100;
809 }
810
811 if(*baud != baud_raw)
812 printk(KERN_INFO "Serial: Console IMX rounded baud rate from %d to %d\n",
813 baud_raw, *baud);
764 } 814 }
765} 815}
766 816
@@ -787,6 +837,8 @@ imx_console_setup(struct console *co, char *options)
787 else 837 else
788 imx_console_get_options(sport, &baud, &parity, &bits); 838 imx_console_get_options(sport, &baud, &parity, &bits);
789 839
840 imx_setup_ufcr(sport, 0);
841
790 return uart_set_options(&sport->port, co, baud, parity, bits, flow); 842 return uart_set_options(&sport->port, co, baud, parity, bits, flow);
791} 843}
792 844
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index d054f1265701..ba4e13a22a50 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -838,7 +838,7 @@ static int inline port_init(struct ioc4_port *port)
838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK; 838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK;
839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir); 839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir);
840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; 840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK;
841 writel(port->ip_rx_cons, &port->ip_serial_regs->srcir); 841 writel(port->ip_rx_cons | IOC4_SRCIR_ARM, &port->ip_serial_regs->srcir);
842 842
843 /* Disable interrupts for this 16550 */ 843 /* Disable interrupts for this 16550 */
844 uart = port->ip_uart_regs; 844 uart = port->ip_uart_regs;
@@ -1272,8 +1272,9 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1272 * and set the rx threshold to that amount. There are 4 chars 1272 * and set the rx threshold to that amount. There are 4 chars
1273 * per ring entry, so we'll divide the number of chars that will 1273 * per ring entry, so we'll divide the number of chars that will
1274 * arrive in timeout by 4. 1274 * arrive in timeout by 4.
1275 * So .... timeout * baud / 10 / HZ / 4, with HZ = 100.
1275 */ 1276 */
1276 threshold = timeout * port->ip_baud / 10 / HZ / 4; 1277 threshold = timeout * port->ip_baud / 4000;
1277 if (threshold == 0) 1278 if (threshold == 0)
1278 threshold = 1; /* otherwise we'll intr all the time! */ 1279 threshold = 1; /* otherwise we'll intr all the time! */
1279 1280
@@ -1285,8 +1286,10 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1285 1286
1286 writel(port->ip_sscr, &port->ip_serial_regs->sscr); 1287 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1287 1288
1288 /* Now set the rx timeout to the given value */ 1289 /* Now set the rx timeout to the given value
1289 timeout = timeout * IOC4_SRTR_HZ / HZ; 1290 * again timeout * IOC4_SRTR_HZ / HZ
1291 */
1292 timeout = timeout * IOC4_SRTR_HZ / 100;
1290 if (timeout > IOC4_SRTR_CNT) 1293 if (timeout > IOC4_SRTR_CNT)
1291 timeout = IOC4_SRTR_CNT; 1294 timeout = IOC4_SRTR_CNT;
1292 1295
@@ -1380,7 +1383,7 @@ config_port(struct ioc4_port *port,
1380 if (port->ip_tx_lowat == 0) 1383 if (port->ip_tx_lowat == 0)
1381 port->ip_tx_lowat = 1; 1384 port->ip_tx_lowat = 1;
1382 1385
1383 set_rx_timeout(port, port->ip_rx_timeout); 1386 set_rx_timeout(port, 2);
1384 1387
1385 return 0; 1388 return 0;
1386} 1389}
@@ -1685,8 +1688,8 @@ ioc4_change_speed(struct uart_port *the_port,
1685{ 1688{
1686 struct ioc4_port *port = get_ioc4_port(the_port); 1689 struct ioc4_port *port = get_ioc4_port(the_port);
1687 int baud, bits; 1690 int baud, bits;
1688 unsigned cflag, cval; 1691 unsigned cflag;
1689 int new_parity = 0, new_parity_enable = 0, new_stop = 1, new_data = 8; 1692 int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8;
1690 struct uart_info *info = the_port->info; 1693 struct uart_info *info = the_port->info;
1691 1694
1692 cflag = new_termios->c_cflag; 1695 cflag = new_termios->c_cflag;
@@ -1694,48 +1697,35 @@ ioc4_change_speed(struct uart_port *the_port,
1694 switch (cflag & CSIZE) { 1697 switch (cflag & CSIZE) {
1695 case CS5: 1698 case CS5:
1696 new_data = 5; 1699 new_data = 5;
1697 cval = 0x00;
1698 bits = 7; 1700 bits = 7;
1699 break; 1701 break;
1700 case CS6: 1702 case CS6:
1701 new_data = 6; 1703 new_data = 6;
1702 cval = 0x01;
1703 bits = 8; 1704 bits = 8;
1704 break; 1705 break;
1705 case CS7: 1706 case CS7:
1706 new_data = 7; 1707 new_data = 7;
1707 cval = 0x02;
1708 bits = 9; 1708 bits = 9;
1709 break; 1709 break;
1710 case CS8: 1710 case CS8:
1711 new_data = 8; 1711 new_data = 8;
1712 cval = 0x03;
1713 bits = 10; 1712 bits = 10;
1714 break; 1713 break;
1715 default: 1714 default:
1716 /* cuz we always need a default ... */ 1715 /* cuz we always need a default ... */
1717 new_data = 5; 1716 new_data = 5;
1718 cval = 0x00;
1719 bits = 7; 1717 bits = 7;
1720 break; 1718 break;
1721 } 1719 }
1722 if (cflag & CSTOPB) { 1720 if (cflag & CSTOPB) {
1723 cval |= 0x04;
1724 bits++; 1721 bits++;
1725 new_stop = 1; 1722 new_stop = 1;
1726 } 1723 }
1727 if (cflag & PARENB) { 1724 if (cflag & PARENB) {
1728 cval |= UART_LCR_PARITY;
1729 bits++; 1725 bits++;
1730 new_parity_enable = 1; 1726 new_parity_enable = 1;
1731 } 1727 if (cflag & PARODD)
1732 if (cflag & PARODD) { 1728 new_parity = 1;
1733 cval |= UART_LCR_EPAR;
1734 new_parity = 1;
1735 }
1736 if (cflag & IGNPAR) {
1737 cval &= ~UART_LCR_PARITY;
1738 new_parity_enable = 0;
1739 } 1729 }
1740 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 1730 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
1741 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 1731 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
@@ -1765,10 +1755,15 @@ ioc4_change_speed(struct uart_port *the_port,
1765 the_port->ignore_status_mask &= ~N_DATA_READY; 1755 the_port->ignore_status_mask &= ~N_DATA_READY;
1766 } 1756 }
1767 1757
1768 if (cflag & CRTSCTS) 1758 if (cflag & CRTSCTS) {
1769 info->flags |= ASYNC_CTS_FLOW; 1759 info->flags |= ASYNC_CTS_FLOW;
1770 else 1760 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1761 }
1762 else {
1771 info->flags &= ~ASYNC_CTS_FLOW; 1763 info->flags &= ~ASYNC_CTS_FLOW;
1764 port->ip_sscr &= ~IOC4_SSCR_HFC_EN;
1765 }
1766 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1772 1767
1773 /* Set the configuration and proper notification call */ 1768 /* Set the configuration and proper notification call */
1774 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o " 1769 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o "
@@ -1825,12 +1820,6 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1825 /* set the speed of the serial port */ 1820 /* set the speed of the serial port */
1826 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0); 1821 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
1827 1822
1828 /* enable hardware flow control - after ioc4_change_speed because
1829 * ASYNC_CTS_FLOW is set there */
1830 if (info->flags & ASYNC_CTS_FLOW) {
1831 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1832 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1833 }
1834 info->flags |= UIF_INITIALIZED; 1823 info->flags |= UIF_INITIALIZED;
1835 return 0; 1824 return 0;
1836} 1825}
@@ -1847,7 +1836,6 @@ static void ioc4_cb_output_lowat(struct ioc4_port *port)
1847 } 1836 }
1848} 1837}
1849 1838
1850
1851/** 1839/**
1852 * handle_intr - service any interrupts for the given port - 2nd level 1840 * handle_intr - service any interrupts for the given port - 2nd level
1853 * called via sd_intr 1841 * called via sd_intr
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index e0717611c940..777829fa3300 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -393,7 +393,6 @@ int jsm_tty_init(struct jsm_board *);
393int jsm_uart_port_init(struct jsm_board *); 393int jsm_uart_port_init(struct jsm_board *);
394int jsm_remove_uart_port(struct jsm_board *); 394int jsm_remove_uart_port(struct jsm_board *);
395void jsm_input(struct jsm_channel *ch); 395void jsm_input(struct jsm_channel *ch);
396void jsm_carrier(struct jsm_channel *ch);
397void jsm_check_queue_flow_control(struct jsm_channel *ch); 396void jsm_check_queue_flow_control(struct jsm_channel *ch);
398 397
399#endif 398#endif
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 9b79c1ff6c72..3a11a69feb44 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -688,7 +688,7 @@ static void neo_flush_uart_read(struct jsm_channel *ch)
688/* 688/*
689 * No locks are assumed to be held when calling this function. 689 * No locks are assumed to be held when calling this function.
690 */ 690 */
691void neo_clear_break(struct jsm_channel *ch, int force) 691static void neo_clear_break(struct jsm_channel *ch, int force)
692{ 692{
693 unsigned long lock_flags; 693 unsigned long lock_flags;
694 694
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 24fe76c28833..98de2258fd06 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -31,6 +31,8 @@
31 31
32#include "jsm.h" 32#include "jsm.h"
33 33
34static void jsm_carrier(struct jsm_channel *ch);
35
34static inline int jsm_get_mstat(struct jsm_channel *ch) 36static inline int jsm_get_mstat(struct jsm_channel *ch)
35{ 37{
36 unsigned char mstat; 38 unsigned char mstat;
@@ -755,7 +757,7 @@ void jsm_input(struct jsm_channel *ch)
755 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 757 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
756} 758}
757 759
758void jsm_carrier(struct jsm_channel *ch) 760static void jsm_carrier(struct jsm_channel *ch)
759{ 761{
760 struct jsm_board *bd; 762 struct jsm_board *bd;
761 763
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 9034f9ad37c7..6eeb48f6a482 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -107,6 +107,13 @@ struct serial_info {
107 int line[4]; 107 int line[4];
108}; 108};
109 109
110struct serial_cfg_mem {
111 tuple_t tuple;
112 cisparse_t parse;
113 u_char buf[256];
114};
115
116
110static void serial_config(dev_link_t * link); 117static void serial_config(dev_link_t * link);
111static int serial_event(event_t event, int priority, 118static int serial_event(event_t event, int priority,
112 event_callback_args_t * args); 119 event_callback_args_t * args);
@@ -357,14 +364,24 @@ static int simple_config(dev_link_t *link)
357 static int size_table[2] = { 8, 16 }; 364 static int size_table[2] = { 8, 16 };
358 client_handle_t handle = link->handle; 365 client_handle_t handle = link->handle;
359 struct serial_info *info = link->priv; 366 struct serial_info *info = link->priv;
360 tuple_t tuple; 367 struct serial_cfg_mem *cfg_mem;
361 u_char buf[256]; 368 tuple_t *tuple;
362 cisparse_t parse; 369 u_char *buf;
363 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 370 cisparse_t *parse;
371 cistpl_cftable_entry_t *cf;
364 config_info_t config; 372 config_info_t config;
365 int i, j, try; 373 int i, j, try;
366 int s; 374 int s;
367 375
376 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
377 if (!cfg_mem)
378 return -1;
379
380 tuple = &cfg_mem->tuple;
381 parse = &cfg_mem->parse;
382 cf = &parse->cftable_entry;
383 buf = cfg_mem->buf;
384
368 /* If the card is already configured, look up the port and irq */ 385 /* If the card is already configured, look up the port and irq */
369 i = pcmcia_get_configuration_info(handle, &config); 386 i = pcmcia_get_configuration_info(handle, &config);
370 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { 387 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) {
@@ -377,21 +394,23 @@ static int simple_config(dev_link_t *link)
377 port = config.BasePort1 + 0x28; 394 port = config.BasePort1 + 0x28;
378 info->slave = 1; 395 info->slave = 1;
379 } 396 }
380 if (info->slave) 397 if (info->slave) {
398 kfree(cfg_mem);
381 return setup_serial(handle, info, port, config.AssignedIRQ); 399 return setup_serial(handle, info, port, config.AssignedIRQ);
400 }
382 } 401 }
383 link->conf.Vcc = config.Vcc; 402 link->conf.Vcc = config.Vcc;
384 403
385 /* First pass: look for a config entry that looks normal. */ 404 /* First pass: look for a config entry that looks normal. */
386 tuple.TupleData = (cisdata_t *) buf; 405 tuple->TupleData = (cisdata_t *) buf;
387 tuple.TupleOffset = 0; 406 tuple->TupleOffset = 0;
388 tuple.TupleDataMax = 255; 407 tuple->TupleDataMax = 255;
389 tuple.Attributes = 0; 408 tuple->Attributes = 0;
390 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 409 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
391 /* Two tries: without IO aliases, then with aliases */ 410 /* Two tries: without IO aliases, then with aliases */
392 for (s = 0; s < 2; s++) { 411 for (s = 0; s < 2; s++) {
393 for (try = 0; try < 2; try++) { 412 for (try = 0; try < 2; try++) {
394 i = first_tuple(handle, &tuple, &parse); 413 i = first_tuple(handle, tuple, parse);
395 while (i != CS_NO_MORE_ITEMS) { 414 while (i != CS_NO_MORE_ITEMS) {
396 if (i != CS_SUCCESS) 415 if (i != CS_SUCCESS)
397 goto next_entry; 416 goto next_entry;
@@ -409,14 +428,14 @@ static int simple_config(dev_link_t *link)
409 goto found_port; 428 goto found_port;
410 } 429 }
411next_entry: 430next_entry:
412 i = next_tuple(handle, &tuple, &parse); 431 i = next_tuple(handle, tuple, parse);
413 } 432 }
414 } 433 }
415 } 434 }
416 /* Second pass: try to find an entry that isn't picky about 435 /* Second pass: try to find an entry that isn't picky about
417 its base address, then try to grab any standard serial port 436 its base address, then try to grab any standard serial port
418 address, and finally try to get any free port. */ 437 address, and finally try to get any free port. */
419 i = first_tuple(handle, &tuple, &parse); 438 i = first_tuple(handle, tuple, parse);
420 while (i != CS_NO_MORE_ITEMS) { 439 while (i != CS_NO_MORE_ITEMS) {
421 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && 440 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) &&
422 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 441 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
@@ -429,7 +448,7 @@ next_entry:
429 goto found_port; 448 goto found_port;
430 } 449 }
431 } 450 }
432 i = next_tuple(handle, &tuple, &parse); 451 i = next_tuple(handle, tuple, parse);
433 } 452 }
434 453
435 found_port: 454 found_port:
@@ -437,6 +456,7 @@ next_entry:
437 printk(KERN_NOTICE 456 printk(KERN_NOTICE
438 "serial_cs: no usable port range found, giving up\n"); 457 "serial_cs: no usable port range found, giving up\n");
439 cs_error(link->handle, RequestIO, i); 458 cs_error(link->handle, RequestIO, i);
459 kfree(cfg_mem);
440 return -1; 460 return -1;
441 } 461 }
442 462
@@ -450,9 +470,10 @@ next_entry:
450 i = pcmcia_request_configuration(link->handle, &link->conf); 470 i = pcmcia_request_configuration(link->handle, &link->conf);
451 if (i != CS_SUCCESS) { 471 if (i != CS_SUCCESS) {
452 cs_error(link->handle, RequestConfiguration, i); 472 cs_error(link->handle, RequestConfiguration, i);
473 kfree(cfg_mem);
453 return -1; 474 return -1;
454 } 475 }
455 476 kfree(cfg_mem);
456 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 477 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
457} 478}
458 479
@@ -460,29 +481,39 @@ static int multi_config(dev_link_t * link)
460{ 481{
461 client_handle_t handle = link->handle; 482 client_handle_t handle = link->handle;
462 struct serial_info *info = link->priv; 483 struct serial_info *info = link->priv;
463 tuple_t tuple; 484 struct serial_cfg_mem *cfg_mem;
464 u_char buf[256]; 485 tuple_t *tuple;
465 cisparse_t parse; 486 u_char *buf;
466 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 487 cisparse_t *parse;
488 cistpl_cftable_entry_t *cf;
467 config_info_t config; 489 config_info_t config;
468 int i, base2 = 0; 490 int i, rc, base2 = 0;
491
492 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
493 if (!cfg_mem)
494 return -1;
495 tuple = &cfg_mem->tuple;
496 parse = &cfg_mem->parse;
497 cf = &parse->cftable_entry;
498 buf = cfg_mem->buf;
469 499
470 i = pcmcia_get_configuration_info(handle, &config); 500 i = pcmcia_get_configuration_info(handle, &config);
471 if (i != CS_SUCCESS) { 501 if (i != CS_SUCCESS) {
472 cs_error(handle, GetConfigurationInfo, i); 502 cs_error(handle, GetConfigurationInfo, i);
473 return -1; 503 rc = -1;
504 goto free_cfg_mem;
474 } 505 }
475 link->conf.Vcc = config.Vcc; 506 link->conf.Vcc = config.Vcc;
476 507
477 tuple.TupleData = (cisdata_t *) buf; 508 tuple->TupleData = (cisdata_t *) buf;
478 tuple.TupleOffset = 0; 509 tuple->TupleOffset = 0;
479 tuple.TupleDataMax = 255; 510 tuple->TupleDataMax = 255;
480 tuple.Attributes = 0; 511 tuple->Attributes = 0;
481 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 512 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
482 513
483 /* First, look for a generic full-sized window */ 514 /* First, look for a generic full-sized window */
484 link->io.NumPorts1 = info->multi * 8; 515 link->io.NumPorts1 = info->multi * 8;
485 i = first_tuple(handle, &tuple, &parse); 516 i = first_tuple(handle, tuple, parse);
486 while (i != CS_NO_MORE_ITEMS) { 517 while (i != CS_NO_MORE_ITEMS) {
487 /* The quad port cards have bad CIS's, so just look for a 518 /* The quad port cards have bad CIS's, so just look for a
488 window larger than 8 ports and assume it will be right */ 519 window larger than 8 ports and assume it will be right */
@@ -497,14 +528,14 @@ static int multi_config(dev_link_t * link)
497 if (i == CS_SUCCESS) 528 if (i == CS_SUCCESS)
498 break; 529 break;
499 } 530 }
500 i = next_tuple(handle, &tuple, &parse); 531 i = next_tuple(handle, tuple, parse);
501 } 532 }
502 533
503 /* If that didn't work, look for two windows */ 534 /* If that didn't work, look for two windows */
504 if (i != CS_SUCCESS) { 535 if (i != CS_SUCCESS) {
505 link->io.NumPorts1 = link->io.NumPorts2 = 8; 536 link->io.NumPorts1 = link->io.NumPorts2 = 8;
506 info->multi = 2; 537 info->multi = 2;
507 i = first_tuple(handle, &tuple, &parse); 538 i = first_tuple(handle, tuple, parse);
508 while (i != CS_NO_MORE_ITEMS) { 539 while (i != CS_NO_MORE_ITEMS) {
509 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { 540 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) {
510 link->conf.ConfigIndex = cf->index; 541 link->conf.ConfigIndex = cf->index;
@@ -517,13 +548,14 @@ static int multi_config(dev_link_t * link)
517 if (i == CS_SUCCESS) 548 if (i == CS_SUCCESS)
518 break; 549 break;
519 } 550 }
520 i = next_tuple(handle, &tuple, &parse); 551 i = next_tuple(handle, tuple, parse);
521 } 552 }
522 } 553 }
523 554
524 if (i != CS_SUCCESS) { 555 if (i != CS_SUCCESS) {
525 cs_error(link->handle, RequestIO, i); 556 cs_error(link->handle, RequestIO, i);
526 return -1; 557 rc = -1;
558 goto free_cfg_mem;
527 } 559 }
528 560
529 i = pcmcia_request_irq(link->handle, &link->irq); 561 i = pcmcia_request_irq(link->handle, &link->irq);
@@ -541,7 +573,8 @@ static int multi_config(dev_link_t * link)
541 i = pcmcia_request_configuration(link->handle, &link->conf); 573 i = pcmcia_request_configuration(link->handle, &link->conf);
542 if (i != CS_SUCCESS) { 574 if (i != CS_SUCCESS) {
543 cs_error(link->handle, RequestConfiguration, i); 575 cs_error(link->handle, RequestConfiguration, i);
544 return -1; 576 rc = -1;
577 goto free_cfg_mem;
545 } 578 }
546 579
547 /* The Oxford Semiconductor OXCF950 cards are in fact single-port: 580 /* The Oxford Semiconductor OXCF950 cards are in fact single-port:
@@ -554,17 +587,23 @@ static int multi_config(dev_link_t * link)
554 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 587 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
555 outb(12, base2 + 1); 588 outb(12, base2 + 1);
556 } 589 }
557 return 0; 590 rc = 0;
591 goto free_cfg_mem;
558 } 592 }
559 593
560 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 594 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
561 /* The Nokia cards are not really multiport cards */ 595 /* The Nokia cards are not really multiport cards */
562 if (info->manfid == MANFID_NOKIA) 596 if (info->manfid == MANFID_NOKIA) {
563 return 0; 597 rc = 0;
598 goto free_cfg_mem;
599 }
564 for (i = 0; i < info->multi - 1; i++) 600 for (i = 0; i < info->multi - 1; i++)
565 setup_serial(handle, info, base2 + (8 * i), link->irq.AssignedIRQ); 601 setup_serial(handle, info, base2 + (8 * i),
566 602 link->irq.AssignedIRQ);
567 return 0; 603 rc = 0;
604free_cfg_mem:
605 kfree(cfg_mem);
606 return rc;
568} 607}
569 608
570/*====================================================================== 609/*======================================================================
@@ -579,39 +618,49 @@ void serial_config(dev_link_t * link)
579{ 618{
580 client_handle_t handle = link->handle; 619 client_handle_t handle = link->handle;
581 struct serial_info *info = link->priv; 620 struct serial_info *info = link->priv;
582 tuple_t tuple; 621 struct serial_cfg_mem *cfg_mem;
583 u_short buf[128]; 622 tuple_t *tuple;
584 cisparse_t parse; 623 u_char *buf;
585 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 624 cisparse_t *parse;
625 cistpl_cftable_entry_t *cf;
586 int i, last_ret, last_fn; 626 int i, last_ret, last_fn;
587 627
588 DEBUG(0, "serial_config(0x%p)\n", link); 628 DEBUG(0, "serial_config(0x%p)\n", link);
589 629
590 tuple.TupleData = (cisdata_t *) buf; 630 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
591 tuple.TupleOffset = 0; 631 if (!cfg_mem)
592 tuple.TupleDataMax = 255; 632 goto failed;
593 tuple.Attributes = 0; 633
634 tuple = &cfg_mem->tuple;
635 parse = &cfg_mem->parse;
636 cf = &parse->cftable_entry;
637 buf = cfg_mem->buf;
638
639 tuple->TupleData = (cisdata_t *) buf;
640 tuple->TupleOffset = 0;
641 tuple->TupleDataMax = 255;
642 tuple->Attributes = 0;
594 /* Get configuration register information */ 643 /* Get configuration register information */
595 tuple.DesiredTuple = CISTPL_CONFIG; 644 tuple->DesiredTuple = CISTPL_CONFIG;
596 last_ret = first_tuple(handle, &tuple, &parse); 645 last_ret = first_tuple(handle, tuple, parse);
597 if (last_ret != CS_SUCCESS) { 646 if (last_ret != CS_SUCCESS) {
598 last_fn = ParseTuple; 647 last_fn = ParseTuple;
599 goto cs_failed; 648 goto cs_failed;
600 } 649 }
601 link->conf.ConfigBase = parse.config.base; 650 link->conf.ConfigBase = parse->config.base;
602 link->conf.Present = parse.config.rmask[0]; 651 link->conf.Present = parse->config.rmask[0];
603 652
604 /* Configure card */ 653 /* Configure card */
605 link->state |= DEV_CONFIG; 654 link->state |= DEV_CONFIG;
606 655
607 /* Is this a compliant multifunction card? */ 656 /* Is this a compliant multifunction card? */
608 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 657 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
609 tuple.Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; 658 tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
610 info->multi = (first_tuple(handle, &tuple, &parse) == CS_SUCCESS); 659 info->multi = (first_tuple(handle, tuple, parse) == CS_SUCCESS);
611 660
612 /* Is this a multiport card? */ 661 /* Is this a multiport card? */
613 tuple.DesiredTuple = CISTPL_MANFID; 662 tuple->DesiredTuple = CISTPL_MANFID;
614 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 663 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
615 info->manfid = le16_to_cpu(buf[0]); 664 info->manfid = le16_to_cpu(buf[0]);
616 for (i = 0; i < MULTI_COUNT; i++) 665 for (i = 0; i < MULTI_COUNT; i++)
617 if ((info->manfid == multi_id[i].manfid) && 666 if ((info->manfid == multi_id[i].manfid) &&
@@ -623,13 +672,13 @@ void serial_config(dev_link_t * link)
623 672
624 /* Another check for dual-serial cards: look for either serial or 673 /* Another check for dual-serial cards: look for either serial or
625 multifunction cards that ask for appropriate IO port ranges */ 674 multifunction cards that ask for appropriate IO port ranges */
626 tuple.DesiredTuple = CISTPL_FUNCID; 675 tuple->DesiredTuple = CISTPL_FUNCID;
627 if ((info->multi == 0) && 676 if ((info->multi == 0) &&
628 ((first_tuple(handle, &tuple, &parse) != CS_SUCCESS) || 677 ((first_tuple(handle, tuple, parse) != CS_SUCCESS) ||
629 (parse.funcid.func == CISTPL_FUNCID_MULTI) || 678 (parse->funcid.func == CISTPL_FUNCID_MULTI) ||
630 (parse.funcid.func == CISTPL_FUNCID_SERIAL))) { 679 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) {
631 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 680 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
632 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 681 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
633 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 682 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
634 info->multi = cf->io.win[0].len >> 3; 683 info->multi = cf->io.win[0].len >> 3;
635 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && 684 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) &&
@@ -664,6 +713,7 @@ void serial_config(dev_link_t * link)
664 713
665 link->dev = &info->node[0]; 714 link->dev = &info->node[0];
666 link->state &= ~DEV_CONFIG_PENDING; 715 link->state &= ~DEV_CONFIG_PENDING;
716 kfree(cfg_mem);
667 return; 717 return;
668 718
669 cs_failed: 719 cs_failed:
@@ -671,6 +721,7 @@ void serial_config(dev_link_t * link)
671 failed: 721 failed:
672 serial_remove(link); 722 serial_remove(link);
673 link->state &= ~DEV_CONFIG_PENDING; 723 link->state &= ~DEV_CONFIG_PENDING;
724 kfree(cfg_mem);
674} 725}
675 726
676/*====================================================================== 727/*======================================================================
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index ffaab9b90fd8..fee6418e84c4 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -787,7 +787,7 @@ static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port)
787 787
788static void sn_sal_console_write(struct console *, const char *, unsigned); 788static void sn_sal_console_write(struct console *, const char *, unsigned);
789static int __init sn_sal_console_setup(struct console *, char *); 789static int __init sn_sal_console_setup(struct console *, char *);
790extern struct uart_driver sal_console_uart; 790static struct uart_driver sal_console_uart;
791extern struct tty_driver *uart_console_device(struct console *, int *); 791extern struct tty_driver *uart_console_device(struct console *, int *);
792 792
793static struct console sal_console = { 793static struct console sal_console = {
@@ -801,7 +801,7 @@ static struct console sal_console = {
801 801
802#define SAL_CONSOLE &sal_console 802#define SAL_CONSOLE &sal_console
803 803
804struct uart_driver sal_console_uart = { 804static struct uart_driver sal_console_uart = {
805 .owner = THIS_MODULE, 805 .owner = THIS_MODULE,
806 .driver_name = "sn_console", 806 .driver_name = "sn_console",
807 .dev_name = DEVICE_NAME, 807 .dev_name = DEVICE_NAME,