aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:09:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 02:09:27 -0400
commitd5ef642355bdd9b383ff5c18cbc6102a06eecbaf (patch)
treefcf78d33c1790c6c24efbfd0c3695f7874f053d7 /drivers/tty
parentf549953c15deab4c54708b39af86d4edecc6cddc (diff)
parentdef90f4239f094f3846c108c1c41a4cd55c33e8e (diff)
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (26 commits) amba pl011: workaround for uart registers lockup n_gsm: fix the wrong FCS handling pch_uart: add missing comment about OKI ML7223 pch_uart: Add MSI support tty: fix "IRQ45: nobody cared" PTI feature to allow user to name and mark masterchannel request. 0 for o PTI Makefile bug. tty: serial: samsung.c remove legacy PM code. SERIAL: SC26xx: Fix link error. serial: mrst_max3110: initialize waitqueue earlier mrst_max3110: Change max missing message priority. tty: s5pv210: Add delay loop on fifo reset function for UART tty/serial: Fix XSCALE serial ports, e.g. ce4100 serial: bfin_5xx: fix off-by-one with resource size drivers/tty: use printk_ratelimited() instead of printk_ratelimit() tty: n_gsm: Added refcount usage to gsm_mux and gsm_dlci structs tty: n_gsm: Add raw-ip support tty: n_gsm: expose gsmtty device nodes at ldisc open time pch_phub: Fix register miss-setting issue serial: 8250, increase PASS_LIMIT ...
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/moxa.c5
-rw-r--r--drivers/tty/mxser.c4
-rw-r--r--drivers/tty/n_gsm.c401
-rw-r--r--drivers/tty/n_tty.c2
-rw-r--r--drivers/tty/serial/8250.c4
-rw-r--r--drivers/tty/serial/8250_pci.c183
-rw-r--r--drivers/tty/serial/Kconfig2
-rw-r--r--drivers/tty/serial/pch_uart.c11
-rw-r--r--drivers/tty/serial/s5pv210.c4
-rw-r--r--drivers/tty/serial/samsung.c27
-rw-r--r--drivers/tty/tty_io.c4
11 files changed, 591 insertions, 56 deletions
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index ba679ce0a774..d15a071b1a54 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/ratelimit.h>
47 48
48#include <asm/system.h> 49#include <asm/system.h>
49#include <asm/io.h> 50#include <asm/io.h>
@@ -242,8 +243,8 @@ static void moxa_wait_finish(void __iomem *ofsAddr)
242 while (readw(ofsAddr + FuncCode) != 0) 243 while (readw(ofsAddr + FuncCode) != 0)
243 if (time_after(jiffies, end)) 244 if (time_after(jiffies, end))
244 return; 245 return;
245 if (readw(ofsAddr + FuncCode) != 0 && printk_ratelimit()) 246 if (readw(ofsAddr + FuncCode) != 0)
246 printk(KERN_WARNING "moxa function expired\n"); 247 printk_ratelimited(KERN_WARNING "moxa function expired\n");
247} 248}
248 249
249static void moxafunc(void __iomem *ofsAddr, u16 cmd, u16 arg) 250static void moxafunc(void __iomem *ofsAddr, u16 cmd, u16 arg)
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index d188f378684d..7fc8c02fea6c 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -39,6 +39,7 @@
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/bitops.h> 40#include <linux/bitops.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/ratelimit.h>
42 43
43#include <asm/system.h> 44#include <asm/system.h>
44#include <asm/io.h> 45#include <asm/io.h>
@@ -1490,8 +1491,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1490 1491
1491 switch (cmd) { 1492 switch (cmd) {
1492 case MOXA_GET_MAJOR: 1493 case MOXA_GET_MAJOR:
1493 if (printk_ratelimit()) 1494 printk_ratelimited(KERN_WARNING "mxser: '%s' uses deprecated ioctl "
1494 printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl "
1495 "%x (GET_MAJOR), fix your userspace\n", 1495 "%x (GET_MAJOR), fix your userspace\n",
1496 current->comm, cmd); 1496 current->comm, cmd);
1497 return put_user(ttymajor, (int __user *)argp); 1497 return put_user(ttymajor, (int __user *)argp);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 19b4ae052af8..8a50e4eebf18 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -58,6 +58,10 @@
58#include <linux/serial.h> 58#include <linux/serial.h>
59#include <linux/kfifo.h> 59#include <linux/kfifo.h>
60#include <linux/skbuff.h> 60#include <linux/skbuff.h>
61#include <net/arp.h>
62#include <linux/ip.h>
63#include <linux/netdevice.h>
64#include <linux/etherdevice.h>
61#include <linux/gsmmux.h> 65#include <linux/gsmmux.h>
62 66
63static int debug; 67static int debug;
@@ -77,8 +81,24 @@ module_param(debug, int, 0600);
77 * Semi-arbitrary buffer size limits. 0710 is normally run with 32-64 byte 81 * Semi-arbitrary buffer size limits. 0710 is normally run with 32-64 byte
78 * limits so this is plenty 82 * limits so this is plenty
79 */ 83 */
80#define MAX_MRU 512 84#define MAX_MRU 1500
81#define MAX_MTU 512 85#define MAX_MTU 1500
86#define GSM_NET_TX_TIMEOUT (HZ*10)
87
88/**
89 * struct gsm_mux_net - network interface
90 * @struct gsm_dlci* dlci
91 * @struct net_device_stats stats;
92 *
93 * Created when net interface is initialized.
94 **/
95struct gsm_mux_net {
96 struct kref ref;
97 struct gsm_dlci *dlci;
98 struct net_device_stats stats;
99};
100
101#define STATS(net) (((struct gsm_mux_net *)netdev_priv(net))->stats)
82 102
83/* 103/*
84 * Each block of data we have queued to go out is in the form of 104 * Each block of data we have queued to go out is in the form of
@@ -113,6 +133,8 @@ struct gsm_dlci {
113#define DLCI_OPENING 1 /* Sending SABM not seen UA */ 133#define DLCI_OPENING 1 /* Sending SABM not seen UA */
114#define DLCI_OPEN 2 /* SABM/UA complete */ 134#define DLCI_OPEN 2 /* SABM/UA complete */
115#define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */ 135#define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */
136 struct kref ref; /* freed from port or mux close */
137 struct mutex mutex;
116 138
117 /* Link layer */ 139 /* Link layer */
118 spinlock_t lock; /* Protects the internal state */ 140 spinlock_t lock; /* Protects the internal state */
@@ -123,6 +145,7 @@ struct gsm_dlci {
123 struct kfifo *fifo; /* Queue fifo for the DLCI */ 145 struct kfifo *fifo; /* Queue fifo for the DLCI */
124 struct kfifo _fifo; /* For new fifo API porting only */ 146 struct kfifo _fifo; /* For new fifo API porting only */
125 int adaption; /* Adaption layer in use */ 147 int adaption; /* Adaption layer in use */
148 int prev_adaption;
126 u32 modem_rx; /* Our incoming virtual modem lines */ 149 u32 modem_rx; /* Our incoming virtual modem lines */
127 u32 modem_tx; /* Our outgoing modem lines */ 150 u32 modem_tx; /* Our outgoing modem lines */
128 int dead; /* Refuse re-open */ 151 int dead; /* Refuse re-open */
@@ -134,6 +157,8 @@ struct gsm_dlci {
134 struct sk_buff_head skb_list; /* Queued frames */ 157 struct sk_buff_head skb_list; /* Queued frames */
135 /* Data handling callback */ 158 /* Data handling callback */
136 void (*data)(struct gsm_dlci *dlci, u8 *data, int len); 159 void (*data)(struct gsm_dlci *dlci, u8 *data, int len);
160 void (*prev_data)(struct gsm_dlci *dlci, u8 *data, int len);
161 struct net_device *net; /* network interface, if created */
137}; 162};
138 163
139/* DLCI 0, 62/63 are special or reseved see gsmtty_open */ 164/* DLCI 0, 62/63 are special or reseved see gsmtty_open */
@@ -169,6 +194,8 @@ struct gsm_control {
169struct gsm_mux { 194struct gsm_mux {
170 struct tty_struct *tty; /* The tty our ldisc is bound to */ 195 struct tty_struct *tty; /* The tty our ldisc is bound to */
171 spinlock_t lock; 196 spinlock_t lock;
197 unsigned int num;
198 struct kref ref;
172 199
173 /* Events on the GSM channel */ 200 /* Events on the GSM channel */
174 wait_queue_head_t event; 201 wait_queue_head_t event;
@@ -250,6 +277,8 @@ struct gsm_mux {
250static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */ 277static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */
251static spinlock_t gsm_mux_lock; 278static spinlock_t gsm_mux_lock;
252 279
280static struct tty_driver *gsm_tty_driver;
281
253/* 282/*
254 * This section of the driver logic implements the GSM encodings 283 * This section of the driver logic implements the GSM encodings
255 * both the basic and the 'advanced'. Reliable transport is not 284 * both the basic and the 'advanced'. Reliable transport is not
@@ -878,8 +907,10 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
878 memcpy(dp, dlci->skb->data, len); 907 memcpy(dp, dlci->skb->data, len);
879 skb_pull(dlci->skb, len); 908 skb_pull(dlci->skb, len);
880 __gsm_data_queue(dlci, msg); 909 __gsm_data_queue(dlci, msg);
881 if (last) 910 if (last) {
911 kfree_skb(dlci->skb);
882 dlci->skb = NULL; 912 dlci->skb = NULL;
913 }
883 return size; 914 return size;
884} 915}
885 916
@@ -912,7 +943,7 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
912 i++; 943 i++;
913 continue; 944 continue;
914 } 945 }
915 if (dlci->adaption < 3) 946 if (dlci->adaption < 3 && !dlci->net)
916 len = gsm_dlci_data_output(gsm, dlci); 947 len = gsm_dlci_data_output(gsm, dlci);
917 else 948 else
918 len = gsm_dlci_data_output_framed(gsm, dlci); 949 len = gsm_dlci_data_output_framed(gsm, dlci);
@@ -939,9 +970,12 @@ static void gsm_dlci_data_kick(struct gsm_dlci *dlci)
939 970
940 spin_lock_irqsave(&dlci->gsm->tx_lock, flags); 971 spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
941 /* If we have nothing running then we need to fire up */ 972 /* If we have nothing running then we need to fire up */
942 if (dlci->gsm->tx_bytes == 0) 973 if (dlci->gsm->tx_bytes == 0) {
943 gsm_dlci_data_output(dlci->gsm, dlci); 974 if (dlci->net)
944 else if (dlci->gsm->tx_bytes < TX_THRESH_LO) 975 gsm_dlci_data_output_framed(dlci->gsm, dlci);
976 else
977 gsm_dlci_data_output(dlci->gsm, dlci);
978 } else if (dlci->gsm->tx_bytes < TX_THRESH_LO)
945 gsm_dlci_data_sweep(dlci->gsm); 979 gsm_dlci_data_sweep(dlci->gsm);
946 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags); 980 spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
947} 981}
@@ -1588,6 +1622,8 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
1588 if (dlci == NULL) 1622 if (dlci == NULL)
1589 return NULL; 1623 return NULL;
1590 spin_lock_init(&dlci->lock); 1624 spin_lock_init(&dlci->lock);
1625 kref_init(&dlci->ref);
1626 mutex_init(&dlci->mutex);
1591 dlci->fifo = &dlci->_fifo; 1627 dlci->fifo = &dlci->_fifo;
1592 if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) { 1628 if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
1593 kfree(dlci); 1629 kfree(dlci);
@@ -1613,26 +1649,52 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
1613} 1649}
1614 1650
1615/** 1651/**
1616 * gsm_dlci_free - release DLCI 1652 * gsm_dlci_free - free DLCI
1653 * @dlci: DLCI to free
1654 *
1655 * Free up a DLCI.
1656 *
1657 * Can sleep.
1658 */
1659static void gsm_dlci_free(struct kref *ref)
1660{
1661 struct gsm_dlci *dlci = container_of(ref, struct gsm_dlci, ref);
1662
1663 del_timer_sync(&dlci->t1);
1664 dlci->gsm->dlci[dlci->addr] = NULL;
1665 kfifo_free(dlci->fifo);
1666 while ((dlci->skb = skb_dequeue(&dlci->skb_list)))
1667 kfree_skb(dlci->skb);
1668 kfree(dlci);
1669}
1670
1671static inline void dlci_get(struct gsm_dlci *dlci)
1672{
1673 kref_get(&dlci->ref);
1674}
1675
1676static inline void dlci_put(struct gsm_dlci *dlci)
1677{
1678 kref_put(&dlci->ref, gsm_dlci_free);
1679}
1680
1681/**
1682 * gsm_dlci_release - release DLCI
1617 * @dlci: DLCI to destroy 1683 * @dlci: DLCI to destroy
1618 * 1684 *
1619 * Free up a DLCI. Currently to keep the lifetime rules sane we only 1685 * Release a DLCI. Actual free is deferred until either
1620 * clean up DLCI objects when the MUX closes rather than as the port 1686 * mux is closed or tty is closed - whichever is last.
1621 * is closed down on both the tty and mux levels.
1622 * 1687 *
1623 * Can sleep. 1688 * Can sleep.
1624 */ 1689 */
1625static void gsm_dlci_free(struct gsm_dlci *dlci) 1690static void gsm_dlci_release(struct gsm_dlci *dlci)
1626{ 1691{
1627 struct tty_struct *tty = tty_port_tty_get(&dlci->port); 1692 struct tty_struct *tty = tty_port_tty_get(&dlci->port);
1628 if (tty) { 1693 if (tty) {
1629 tty_vhangup(tty); 1694 tty_vhangup(tty);
1630 tty_kref_put(tty); 1695 tty_kref_put(tty);
1631 } 1696 }
1632 del_timer_sync(&dlci->t1); 1697 dlci_put(dlci);
1633 dlci->gsm->dlci[dlci->addr] = NULL;
1634 kfifo_free(dlci->fifo);
1635 kfree(dlci);
1636} 1698}
1637 1699
1638/* 1700/*
@@ -1823,10 +1885,6 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
1823 break; 1885 break;
1824 case GSM_FCS: /* FCS follows the packet */ 1886 case GSM_FCS: /* FCS follows the packet */
1825 gsm->received_fcs = c; 1887 gsm->received_fcs = c;
1826 if (c == GSM0_SOF) {
1827 gsm->state = GSM_SEARCH;
1828 break;
1829 }
1830 gsm_queue(gsm); 1888 gsm_queue(gsm);
1831 gsm->state = GSM_SSOF; 1889 gsm->state = GSM_SSOF;
1832 break; 1890 break;
@@ -1970,7 +2028,7 @@ void gsm_cleanup_mux(struct gsm_mux *gsm)
1970 /* Free up any link layer users */ 2028 /* Free up any link layer users */
1971 for (i = 0; i < NUM_DLCI; i++) 2029 for (i = 0; i < NUM_DLCI; i++)
1972 if (gsm->dlci[i]) 2030 if (gsm->dlci[i])
1973 gsm_dlci_free(gsm->dlci[i]); 2031 gsm_dlci_release(gsm->dlci[i]);
1974 /* Now wipe the queues */ 2032 /* Now wipe the queues */
1975 for (txq = gsm->tx_head; txq != NULL; txq = gsm->tx_head) { 2033 for (txq = gsm->tx_head; txq != NULL; txq = gsm->tx_head) {
1976 gsm->tx_head = txq->next; 2034 gsm->tx_head = txq->next;
@@ -2010,6 +2068,7 @@ int gsm_activate_mux(struct gsm_mux *gsm)
2010 spin_lock(&gsm_mux_lock); 2068 spin_lock(&gsm_mux_lock);
2011 for (i = 0; i < MAX_MUX; i++) { 2069 for (i = 0; i < MAX_MUX; i++) {
2012 if (gsm_mux[i] == NULL) { 2070 if (gsm_mux[i] == NULL) {
2071 gsm->num = i;
2013 gsm_mux[i] = gsm; 2072 gsm_mux[i] = gsm;
2014 break; 2073 break;
2015 } 2074 }
@@ -2030,8 +2089,7 @@ EXPORT_SYMBOL_GPL(gsm_activate_mux);
2030 * gsm_free_mux - free up a mux 2089 * gsm_free_mux - free up a mux
2031 * @mux: mux to free 2090 * @mux: mux to free
2032 * 2091 *
2033 * Dispose of allocated resources for a dead mux. No refcounting 2092 * Dispose of allocated resources for a dead mux
2034 * at present so the mux must be truly dead.
2035 */ 2093 */
2036void gsm_free_mux(struct gsm_mux *gsm) 2094void gsm_free_mux(struct gsm_mux *gsm)
2037{ 2095{
@@ -2042,6 +2100,28 @@ void gsm_free_mux(struct gsm_mux *gsm)
2042EXPORT_SYMBOL_GPL(gsm_free_mux); 2100EXPORT_SYMBOL_GPL(gsm_free_mux);
2043 2101
2044/** 2102/**
2103 * gsm_free_muxr - free up a mux
2104 * @mux: mux to free
2105 *
2106 * Dispose of allocated resources for a dead mux
2107 */
2108static void gsm_free_muxr(struct kref *ref)
2109{
2110 struct gsm_mux *gsm = container_of(ref, struct gsm_mux, ref);
2111 gsm_free_mux(gsm);
2112}
2113
2114static inline void mux_get(struct gsm_mux *gsm)
2115{
2116 kref_get(&gsm->ref);
2117}
2118
2119static inline void mux_put(struct gsm_mux *gsm)
2120{
2121 kref_put(&gsm->ref, gsm_free_muxr);
2122}
2123
2124/**
2045 * gsm_alloc_mux - allocate a mux 2125 * gsm_alloc_mux - allocate a mux
2046 * 2126 *
2047 * Creates a new mux ready for activation. 2127 * Creates a new mux ready for activation.
@@ -2064,12 +2144,12 @@ struct gsm_mux *gsm_alloc_mux(void)
2064 return NULL; 2144 return NULL;
2065 } 2145 }
2066 spin_lock_init(&gsm->lock); 2146 spin_lock_init(&gsm->lock);
2147 kref_init(&gsm->ref);
2067 2148
2068 gsm->t1 = T1; 2149 gsm->t1 = T1;
2069 gsm->t2 = T2; 2150 gsm->t2 = T2;
2070 gsm->n2 = N2; 2151 gsm->n2 = N2;
2071 gsm->ftype = UIH; 2152 gsm->ftype = UIH;
2072 gsm->initiator = 0;
2073 gsm->adaption = 1; 2153 gsm->adaption = 1;
2074 gsm->encoding = 1; 2154 gsm->encoding = 1;
2075 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */ 2155 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */
@@ -2115,13 +2195,20 @@ static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)
2115 2195
2116static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) 2196static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2117{ 2197{
2118 int ret; 2198 int ret, i;
2199 int base = gsm->num << 6; /* Base for this MUX */
2119 2200
2120 gsm->tty = tty_kref_get(tty); 2201 gsm->tty = tty_kref_get(tty);
2121 gsm->output = gsmld_output; 2202 gsm->output = gsmld_output;
2122 ret = gsm_activate_mux(gsm); 2203 ret = gsm_activate_mux(gsm);
2123 if (ret != 0) 2204 if (ret != 0)
2124 tty_kref_put(gsm->tty); 2205 tty_kref_put(gsm->tty);
2206 else {
2207 /* Don't register device 0 - this is the control channel and not
2208 a usable tty interface */
2209 for (i = 1; i < NUM_DLCI; i++)
2210 tty_register_device(gsm_tty_driver, base + i, NULL);
2211 }
2125 return ret; 2212 return ret;
2126} 2213}
2127 2214
@@ -2136,7 +2223,12 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2136 2223
2137static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) 2224static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2138{ 2225{
2226 int i;
2227 int base = gsm->num << 6; /* Base for this MUX */
2228
2139 WARN_ON(tty != gsm->tty); 2229 WARN_ON(tty != gsm->tty);
2230 for (i = 1; i < NUM_DLCI; i++)
2231 tty_unregister_device(gsm_tty_driver, base + i);
2140 gsm_cleanup_mux(gsm); 2232 gsm_cleanup_mux(gsm);
2141 tty_kref_put(gsm->tty); 2233 tty_kref_put(gsm->tty);
2142 gsm->tty = NULL; 2234 gsm->tty = NULL;
@@ -2224,7 +2316,7 @@ static void gsmld_close(struct tty_struct *tty)
2224 2316
2225 gsmld_flush_buffer(tty); 2317 gsmld_flush_buffer(tty);
2226 /* Do other clean up here */ 2318 /* Do other clean up here */
2227 gsm_free_mux(gsm); 2319 mux_put(gsm);
2228} 2320}
2229 2321
2230/** 2322/**
@@ -2476,6 +2568,220 @@ static int gsmld_ioctl(struct tty_struct *tty, struct file *file,
2476 } 2568 }
2477} 2569}
2478 2570
2571/*
2572 * Network interface
2573 *
2574 */
2575
2576static int gsm_mux_net_open(struct net_device *net)
2577{
2578 pr_debug("%s called\n", __func__);
2579 netif_start_queue(net);
2580 return 0;
2581}
2582
2583static int gsm_mux_net_close(struct net_device *net)
2584{
2585 netif_stop_queue(net);
2586 return 0;
2587}
2588
2589static struct net_device_stats *gsm_mux_net_get_stats(struct net_device *net)
2590{
2591 return &((struct gsm_mux_net *)netdev_priv(net))->stats;
2592}
2593static void dlci_net_free(struct gsm_dlci *dlci)
2594{
2595 if (!dlci->net) {
2596 WARN_ON(1);
2597 return;
2598 }
2599 dlci->adaption = dlci->prev_adaption;
2600 dlci->data = dlci->prev_data;
2601 free_netdev(dlci->net);
2602 dlci->net = NULL;
2603}
2604static void net_free(struct kref *ref)
2605{
2606 struct gsm_mux_net *mux_net;
2607 struct gsm_dlci *dlci;
2608
2609 mux_net = container_of(ref, struct gsm_mux_net, ref);
2610 dlci = mux_net->dlci;
2611
2612 if (dlci->net) {
2613 unregister_netdev(dlci->net);
2614 dlci_net_free(dlci);
2615 }
2616}
2617
2618static inline void muxnet_get(struct gsm_mux_net *mux_net)
2619{
2620 kref_get(&mux_net->ref);
2621}
2622
2623static inline void muxnet_put(struct gsm_mux_net *mux_net)
2624{
2625 kref_put(&mux_net->ref, net_free);
2626}
2627
2628static int gsm_mux_net_start_xmit(struct sk_buff *skb,
2629 struct net_device *net)
2630{
2631 struct gsm_mux_net *mux_net = (struct gsm_mux_net *)netdev_priv(net);
2632 struct gsm_dlci *dlci = mux_net->dlci;
2633 muxnet_get(mux_net);
2634
2635 skb_queue_head(&dlci->skb_list, skb);
2636 STATS(net).tx_packets++;
2637 STATS(net).tx_bytes += skb->len;
2638 gsm_dlci_data_kick(dlci);
2639 /* And tell the kernel when the last transmit started. */
2640 net->trans_start = jiffies;
2641 muxnet_put(mux_net);
2642 return NETDEV_TX_OK;
2643}
2644
2645/* called when a packet did not ack after watchdogtimeout */
2646static void gsm_mux_net_tx_timeout(struct net_device *net)
2647{
2648 /* Tell syslog we are hosed. */
2649 dev_dbg(&net->dev, "Tx timed out.\n");
2650
2651 /* Update statistics */
2652 STATS(net).tx_errors++;
2653}
2654
2655static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,
2656 unsigned char *in_buf, int size)
2657{
2658 struct net_device *net = dlci->net;
2659 struct sk_buff *skb;
2660 struct gsm_mux_net *mux_net = (struct gsm_mux_net *)netdev_priv(net);
2661 muxnet_get(mux_net);
2662
2663 /* Allocate an sk_buff */
2664 skb = dev_alloc_skb(size + NET_IP_ALIGN);
2665 if (!skb) {
2666 /* We got no receive buffer. */
2667 STATS(net).rx_dropped++;
2668 muxnet_put(mux_net);
2669 return;
2670 }
2671 skb_reserve(skb, NET_IP_ALIGN);
2672 memcpy(skb_put(skb, size), in_buf, size);
2673
2674 skb->dev = net;
2675 skb->protocol = __constant_htons(ETH_P_IP);
2676
2677 /* Ship it off to the kernel */
2678 netif_rx(skb);
2679
2680 /* update out statistics */
2681 STATS(net).rx_packets++;
2682 STATS(net).rx_bytes += size;
2683 muxnet_put(mux_net);
2684 return;
2685}
2686
2687int gsm_change_mtu(struct net_device *net, int new_mtu)
2688{
2689 struct gsm_mux_net *mux_net = (struct gsm_mux_net *)netdev_priv(net);
2690 if ((new_mtu < 8) || (new_mtu > mux_net->dlci->gsm->mtu))
2691 return -EINVAL;
2692 net->mtu = new_mtu;
2693 return 0;
2694}
2695
2696static void gsm_mux_net_init(struct net_device *net)
2697{
2698 static const struct net_device_ops gsm_netdev_ops = {
2699 .ndo_open = gsm_mux_net_open,
2700 .ndo_stop = gsm_mux_net_close,
2701 .ndo_start_xmit = gsm_mux_net_start_xmit,
2702 .ndo_tx_timeout = gsm_mux_net_tx_timeout,
2703 .ndo_get_stats = gsm_mux_net_get_stats,
2704 .ndo_change_mtu = gsm_change_mtu,
2705 };
2706
2707 net->netdev_ops = &gsm_netdev_ops;
2708
2709 /* fill in the other fields */
2710 net->watchdog_timeo = GSM_NET_TX_TIMEOUT;
2711 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
2712 net->type = ARPHRD_NONE;
2713 net->tx_queue_len = 10;
2714}
2715
2716
2717/* caller holds the dlci mutex */
2718static void gsm_destroy_network(struct gsm_dlci *dlci)
2719{
2720 struct gsm_mux_net *mux_net;
2721
2722 pr_debug("destroy network interface");
2723 if (!dlci->net)
2724 return;
2725 mux_net = (struct gsm_mux_net *)netdev_priv(dlci->net);
2726 muxnet_put(mux_net);
2727}
2728
2729
2730/* caller holds the dlci mutex */
2731static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
2732{
2733 char *netname;
2734 int retval = 0;
2735 struct net_device *net;
2736 struct gsm_mux_net *mux_net;
2737
2738 if (!capable(CAP_NET_ADMIN))
2739 return -EPERM;
2740
2741 /* Already in a non tty mode */
2742 if (dlci->adaption > 2)
2743 return -EBUSY;
2744
2745 if (nc->protocol != htons(ETH_P_IP))
2746 return -EPROTONOSUPPORT;
2747
2748 if (nc->adaption != 3 && nc->adaption != 4)
2749 return -EPROTONOSUPPORT;
2750
2751 pr_debug("create network interface");
2752
2753 netname = "gsm%d";
2754 if (nc->if_name[0] != '\0')
2755 netname = nc->if_name;
2756 net = alloc_netdev(sizeof(struct gsm_mux_net),
2757 netname,
2758 gsm_mux_net_init);
2759 if (!net) {
2760 pr_err("alloc_netdev failed");
2761 return -ENOMEM;
2762 }
2763 net->mtu = dlci->gsm->mtu;
2764 mux_net = (struct gsm_mux_net *)netdev_priv(net);
2765 mux_net->dlci = dlci;
2766 kref_init(&mux_net->ref);
2767 strncpy(nc->if_name, net->name, IFNAMSIZ); /* return net name */
2768
2769 /* reconfigure dlci for network */
2770 dlci->prev_adaption = dlci->adaption;
2771 dlci->prev_data = dlci->data;
2772 dlci->adaption = nc->adaption;
2773 dlci->data = gsm_mux_rx_netchar;
2774 dlci->net = net;
2775
2776 pr_debug("register netdev");
2777 retval = register_netdev(net);
2778 if (retval) {
2779 pr_err("network register fail %d\n", retval);
2780 dlci_net_free(dlci);
2781 return retval;
2782 }
2783 return net->ifindex; /* return network index */
2784}
2479 2785
2480/* Line discipline for real tty */ 2786/* Line discipline for real tty */
2481struct tty_ldisc_ops tty_ldisc_packet = { 2787struct tty_ldisc_ops tty_ldisc_packet = {
@@ -2579,6 +2885,9 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
2579 port = &dlci->port; 2885 port = &dlci->port;
2580 port->count++; 2886 port->count++;
2581 tty->driver_data = dlci; 2887 tty->driver_data = dlci;
2888 dlci_get(dlci);
2889 dlci_get(dlci->gsm->dlci[0]);
2890 mux_get(dlci->gsm);
2582 tty_port_tty_set(port, tty); 2891 tty_port_tty_set(port, tty);
2583 2892
2584 dlci->modem_rx = 0; 2893 dlci->modem_rx = 0;
@@ -2594,13 +2903,23 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
2594static void gsmtty_close(struct tty_struct *tty, struct file *filp) 2903static void gsmtty_close(struct tty_struct *tty, struct file *filp)
2595{ 2904{
2596 struct gsm_dlci *dlci = tty->driver_data; 2905 struct gsm_dlci *dlci = tty->driver_data;
2906 struct gsm_mux *gsm;
2907
2597 if (dlci == NULL) 2908 if (dlci == NULL)
2598 return; 2909 return;
2910 mutex_lock(&dlci->mutex);
2911 gsm_destroy_network(dlci);
2912 mutex_unlock(&dlci->mutex);
2913 gsm = dlci->gsm;
2599 if (tty_port_close_start(&dlci->port, tty, filp) == 0) 2914 if (tty_port_close_start(&dlci->port, tty, filp) == 0)
2600 return; 2915 goto out;
2601 gsm_dlci_begin_close(dlci); 2916 gsm_dlci_begin_close(dlci);
2602 tty_port_close_end(&dlci->port, tty); 2917 tty_port_close_end(&dlci->port, tty);
2603 tty_port_tty_set(&dlci->port, NULL); 2918 tty_port_tty_set(&dlci->port, NULL);
2919out:
2920 dlci_put(dlci);
2921 dlci_put(gsm->dlci[0]);
2922 mux_put(gsm);
2604} 2923}
2605 2924
2606static void gsmtty_hangup(struct tty_struct *tty) 2925static void gsmtty_hangup(struct tty_struct *tty)
@@ -2677,7 +2996,32 @@ static int gsmtty_tiocmset(struct tty_struct *tty,
2677static int gsmtty_ioctl(struct tty_struct *tty, 2996static int gsmtty_ioctl(struct tty_struct *tty,
2678 unsigned int cmd, unsigned long arg) 2997 unsigned int cmd, unsigned long arg)
2679{ 2998{
2680 return -ENOIOCTLCMD; 2999 struct gsm_dlci *dlci = tty->driver_data;
3000 struct gsm_netconfig nc;
3001 int index;
3002
3003 switch (cmd) {
3004 case GSMIOC_ENABLE_NET:
3005 if (copy_from_user(&nc, (void __user *)arg, sizeof(nc)))
3006 return -EFAULT;
3007 nc.if_name[IFNAMSIZ-1] = '\0';
3008 /* return net interface index or error code */
3009 mutex_lock(&dlci->mutex);
3010 index = gsm_create_network(dlci, &nc);
3011 mutex_unlock(&dlci->mutex);
3012 if (copy_to_user((void __user *)arg, &nc, sizeof(nc)))
3013 return -EFAULT;
3014 return index;
3015 case GSMIOC_DISABLE_NET:
3016 if (!capable(CAP_NET_ADMIN))
3017 return -EPERM;
3018 mutex_lock(&dlci->mutex);
3019 gsm_destroy_network(dlci);
3020 mutex_unlock(&dlci->mutex);
3021 return 0;
3022 default:
3023 return -ENOIOCTLCMD;
3024 }
2681} 3025}
2682 3026
2683static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old) 3027static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old)
@@ -2726,7 +3070,6 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
2726 return gsmtty_modem_update(dlci, encode); 3070 return gsmtty_modem_update(dlci, encode);
2727} 3071}
2728 3072
2729static struct tty_driver *gsm_tty_driver;
2730 3073
2731/* Virtual ttys for the demux */ 3074/* Virtual ttys for the demux */
2732static const struct tty_operations gsmtty_ops = { 3075static const struct tty_operations gsmtty_ops = {
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index c3954fbf6ac4..39d6ab6551e0 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -185,7 +185,6 @@ static void reset_buffer_flags(struct tty_struct *tty)
185 tty->canon_head = tty->canon_data = tty->erasing = 0; 185 tty->canon_head = tty->canon_data = tty->erasing = 0;
186 memset(&tty->read_flags, 0, sizeof tty->read_flags); 186 memset(&tty->read_flags, 0, sizeof tty->read_flags);
187 n_tty_set_room(tty); 187 n_tty_set_room(tty);
188 check_unthrottle(tty);
189} 188}
190 189
191/** 190/**
@@ -1587,6 +1586,7 @@ static int n_tty_open(struct tty_struct *tty)
1587 return -ENOMEM; 1586 return -ENOMEM;
1588 } 1587 }
1589 reset_buffer_flags(tty); 1588 reset_buffer_flags(tty);
1589 tty_unthrottle(tty);
1590 tty->column = 0; 1590 tty->column = 0;
1591 n_tty_set_termios(tty, NULL); 1591 n_tty_set_termios(tty, NULL);
1592 tty->minimum_to_wake = 1; 1592 tty->minimum_to_wake = 1;
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index b4129f53fb1b..f2dfec82faf8 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -81,7 +81,7 @@ static unsigned int skip_txen_test; /* force skip of txen test at init time */
81#define DEBUG_INTR(fmt...) do { } while (0) 81#define DEBUG_INTR(fmt...) do { } while (0)
82#endif 82#endif
83 83
84#define PASS_LIMIT 256 84#define PASS_LIMIT 512
85 85
86#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 86#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
87 87
@@ -1107,7 +1107,7 @@ static void autoconfig_16550a(struct uart_8250_port *up)
1107 */ 1107 */
1108 DEBUG_AUTOCONF("Xscale "); 1108 DEBUG_AUTOCONF("Xscale ");
1109 up->port.type = PORT_XSCALE; 1109 up->port.type = PORT_XSCALE;
1110 up->capabilities |= UART_CAP_UUE; 1110 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE;
1111 return; 1111 return;
1112 } 1112 }
1113 } else { 1113 } else {
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
index cf35e0dc5085..6b887d90a205 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250_pci.c
@@ -39,6 +39,7 @@ struct pci_serial_quirk {
39 u32 device; 39 u32 device;
40 u32 subvendor; 40 u32 subvendor;
41 u32 subdevice; 41 u32 subdevice;
42 int (*probe)(struct pci_dev *dev);
42 int (*init)(struct pci_dev *dev); 43 int (*init)(struct pci_dev *dev);
43 int (*setup)(struct serial_private *, 44 int (*setup)(struct serial_private *,
44 const struct pciserial_board *, 45 const struct pciserial_board *,
@@ -56,6 +57,9 @@ struct serial_private {
56 int line[0]; 57 int line[0];
57}; 58};
58 59
60static int pci_default_setup(struct serial_private*,
61 const struct pciserial_board*, struct uart_port*, int);
62
59static void moan_device(const char *str, struct pci_dev *dev) 63static void moan_device(const char *str, struct pci_dev *dev)
60{ 64{
61 printk(KERN_WARNING 65 printk(KERN_WARNING
@@ -571,6 +575,28 @@ static const struct timedia_struct {
571 { 8, timedia_eight_port } 575 { 8, timedia_eight_port }
572}; 576};
573 577
578/*
579 * There are nearly 70 different Timedia/SUNIX PCI serial devices. Instead of
580 * listing them individually, this driver merely grabs them all with
581 * PCI_ANY_ID. Some of these devices, however, also feature a parallel port,
582 * and should be left free to be claimed by parport_serial instead.
583 */
584static int pci_timedia_probe(struct pci_dev *dev)
585{
586 /*
587 * Check the third digit of the subdevice ID
588 * (0,2,3,5,6: serial only -- 7,8,9: serial + parallel)
589 */
590 if ((dev->subsystem_device & 0x00f0) >= 0x70) {
591 dev_info(&dev->dev,
592 "ignoring Timedia subdevice %04x for parport_serial\n",
593 dev->subsystem_device);
594 return -ENODEV;
595 }
596
597 return 0;
598}
599
574static int pci_timedia_init(struct pci_dev *dev) 600static int pci_timedia_init(struct pci_dev *dev)
575{ 601{
576 const unsigned short *ids; 602 const unsigned short *ids;
@@ -752,6 +778,62 @@ pci_ni8430_setup(struct serial_private *priv,
752 return setup_port(priv, port, bar, offset, board->reg_shift); 778 return setup_port(priv, port, bar, offset, board->reg_shift);
753} 779}
754 780
781static int pci_netmos_9900_setup(struct serial_private *priv,
782 const struct pciserial_board *board,
783 struct uart_port *port, int idx)
784{
785 unsigned int bar;
786
787 if ((priv->dev->subsystem_device & 0xff00) == 0x3000) {
788 /* netmos apparently orders BARs by datasheet layout, so serial
789 * ports get BARs 0 and 3 (or 1 and 4 for memmapped)
790 */
791 bar = 3 * idx;
792
793 return setup_port(priv, port, bar, 0, board->reg_shift);
794 } else {
795 return pci_default_setup(priv, board, port, idx);
796 }
797}
798
799/* the 99xx series comes with a range of device IDs and a variety
800 * of capabilities:
801 *
802 * 9900 has varying capabilities and can cascade to sub-controllers
803 * (cascading should be purely internal)
804 * 9904 is hardwired with 4 serial ports
805 * 9912 and 9922 are hardwired with 2 serial ports
806 */
807static int pci_netmos_9900_numports(struct pci_dev *dev)
808{
809 unsigned int c = dev->class;
810 unsigned int pi;
811 unsigned short sub_serports;
812
813 pi = (c & 0xff);
814
815 if (pi == 2) {
816 return 1;
817 } else if ((pi == 0) &&
818 (dev->device == PCI_DEVICE_ID_NETMOS_9900)) {
819 /* two possibilities: 0x30ps encodes number of parallel and
820 * serial ports, or 0x1000 indicates *something*. This is not
821 * immediately obvious, since the 2s1p+4s configuration seems
822 * to offer all functionality on functions 0..2, while still
823 * advertising the same function 3 as the 4s+2s1p config.
824 */
825 sub_serports = dev->subsystem_device & 0xf;
826 if (sub_serports > 0) {
827 return sub_serports;
828 } else {
829 printk(KERN_NOTICE "NetMos/Mostech serial driver ignoring port on ambiguous config.\n");
830 return 0;
831 }
832 }
833
834 moan_device("unknown NetMos/Mostech program interface", dev);
835 return 0;
836}
755 837
756static int pci_netmos_init(struct pci_dev *dev) 838static int pci_netmos_init(struct pci_dev *dev)
757{ 839{
@@ -761,12 +843,28 @@ static int pci_netmos_init(struct pci_dev *dev)
761 if ((dev->device == PCI_DEVICE_ID_NETMOS_9901) || 843 if ((dev->device == PCI_DEVICE_ID_NETMOS_9901) ||
762 (dev->device == PCI_DEVICE_ID_NETMOS_9865)) 844 (dev->device == PCI_DEVICE_ID_NETMOS_9865))
763 return 0; 845 return 0;
846
764 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM && 847 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
765 dev->subsystem_device == 0x0299) 848 dev->subsystem_device == 0x0299)
766 return 0; 849 return 0;
767 850
851 switch (dev->device) { /* FALLTHROUGH on all */
852 case PCI_DEVICE_ID_NETMOS_9904:
853 case PCI_DEVICE_ID_NETMOS_9912:
854 case PCI_DEVICE_ID_NETMOS_9922:
855 case PCI_DEVICE_ID_NETMOS_9900:
856 num_serial = pci_netmos_9900_numports(dev);
857 break;
858
859 default:
860 if (num_serial == 0 ) {
861 moan_device("unknown NetMos/Mostech device", dev);
862 }
863 }
864
768 if (num_serial == 0) 865 if (num_serial == 0)
769 return -ENODEV; 866 return -ENODEV;
867
770 return num_serial; 868 return num_serial;
771} 869}
772 870
@@ -1396,6 +1494,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1396 .device = PCI_DEVICE_ID_TIMEDIA_1889, 1494 .device = PCI_DEVICE_ID_TIMEDIA_1889,
1397 .subvendor = PCI_VENDOR_ID_TIMEDIA, 1495 .subvendor = PCI_VENDOR_ID_TIMEDIA,
1398 .subdevice = PCI_ANY_ID, 1496 .subdevice = PCI_ANY_ID,
1497 .probe = pci_timedia_probe,
1399 .init = pci_timedia_init, 1498 .init = pci_timedia_init,
1400 .setup = pci_timedia_setup, 1499 .setup = pci_timedia_setup,
1401 }, 1500 },
@@ -1426,7 +1525,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1426 .subvendor = PCI_ANY_ID, 1525 .subvendor = PCI_ANY_ID,
1427 .subdevice = PCI_ANY_ID, 1526 .subdevice = PCI_ANY_ID,
1428 .init = pci_netmos_init, 1527 .init = pci_netmos_init,
1429 .setup = pci_default_setup, 1528 .setup = pci_netmos_9900_setup,
1430 }, 1529 },
1431 /* 1530 /*
1432 * For Oxford Semiconductor Tornado based devices 1531 * For Oxford Semiconductor Tornado based devices
@@ -1703,6 +1802,7 @@ enum pci_board_num_t {
1703 pbn_ADDIDATA_PCIe_8_3906250, 1802 pbn_ADDIDATA_PCIe_8_3906250,
1704 pbn_ce4100_1_115200, 1803 pbn_ce4100_1_115200,
1705 pbn_omegapci, 1804 pbn_omegapci,
1805 pbn_NETMOS9900_2s_115200,
1706}; 1806};
1707 1807
1708/* 1808/*
@@ -2404,6 +2504,11 @@ static struct pciserial_board pci_boards[] __devinitdata = {
2404 .base_baud = 115200, 2504 .base_baud = 115200,
2405 .uart_offset = 0x200, 2505 .uart_offset = 0x200,
2406 }, 2506 },
2507 [pbn_NETMOS9900_2s_115200] = {
2508 .flags = FL_BASE0,
2509 .num_ports = 2,
2510 .base_baud = 115200,
2511 },
2407}; 2512};
2408 2513
2409static const struct pci_device_id softmodem_blacklist[] = { 2514static const struct pci_device_id softmodem_blacklist[] = {
@@ -2640,11 +2745,19 @@ EXPORT_SYMBOL_GPL(pciserial_resume_ports);
2640static int __devinit 2745static int __devinit
2641pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) 2746pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2642{ 2747{
2748 struct pci_serial_quirk *quirk;
2643 struct serial_private *priv; 2749 struct serial_private *priv;
2644 const struct pciserial_board *board; 2750 const struct pciserial_board *board;
2645 struct pciserial_board tmp; 2751 struct pciserial_board tmp;
2646 int rc; 2752 int rc;
2647 2753
2754 quirk = find_quirk(dev);
2755 if (quirk->probe) {
2756 rc = quirk->probe(dev);
2757 if (rc)
2758 return rc;
2759 }
2760
2648 if (ent->driver_data >= ARRAY_SIZE(pci_boards)) { 2761 if (ent->driver_data >= ARRAY_SIZE(pci_boards)) {
2649 printk(KERN_ERR "pci_init_one: invalid driver_data: %ld\n", 2762 printk(KERN_ERR "pci_init_one: invalid driver_data: %ld\n",
2650 ent->driver_data); 2763 ent->driver_data);
@@ -2654,6 +2767,7 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2654 board = &pci_boards[ent->driver_data]; 2767 board = &pci_boards[ent->driver_data];
2655 2768
2656 rc = pci_enable_device(dev); 2769 rc = pci_enable_device(dev);
2770 pci_save_state(dev);
2657 if (rc) 2771 if (rc)
2658 return rc; 2772 return rc;
2659 2773
@@ -3885,6 +3999,27 @@ static struct pci_device_id serial_pci_tbl[] = {
3885 0xA000, 0x1000, 3999 0xA000, 0x1000,
3886 0, 0, pbn_b0_1_115200 }, 4000 0, 0, pbn_b0_1_115200 },
3887 4001
4002 /* the 9901 is a rebranded 9912 */
4003 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9912,
4004 0xA000, 0x1000,
4005 0, 0, pbn_b0_1_115200 },
4006
4007 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
4008 0xA000, 0x1000,
4009 0, 0, pbn_b0_1_115200 },
4010
4011 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9904,
4012 0xA000, 0x1000,
4013 0, 0, pbn_b0_1_115200 },
4014
4015 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
4016 0xA000, 0x1000,
4017 0, 0, pbn_b0_1_115200 },
4018
4019 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
4020 0xA000, 0x3002,
4021 0, 0, pbn_NETMOS9900_2s_115200 },
4022
3888 /* 4023 /*
3889 * Best Connectivity PCI Multi I/O cards 4024 * Best Connectivity PCI Multi I/O cards
3890 */ 4025 */
@@ -3927,6 +4062,51 @@ static struct pci_device_id serial_pci_tbl[] = {
3927 { 0, } 4062 { 0, }
3928}; 4063};
3929 4064
4065static pci_ers_result_t serial8250_io_error_detected(struct pci_dev *dev,
4066 pci_channel_state_t state)
4067{
4068 struct serial_private *priv = pci_get_drvdata(dev);
4069
4070 if (state == pci_channel_io_perm_failure)
4071 return PCI_ERS_RESULT_DISCONNECT;
4072
4073 if (priv)
4074 pciserial_suspend_ports(priv);
4075
4076 pci_disable_device(dev);
4077
4078 return PCI_ERS_RESULT_NEED_RESET;
4079}
4080
4081static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
4082{
4083 int rc;
4084
4085 rc = pci_enable_device(dev);
4086
4087 if (rc)
4088 return PCI_ERS_RESULT_DISCONNECT;
4089
4090 pci_restore_state(dev);
4091 pci_save_state(dev);
4092
4093 return PCI_ERS_RESULT_RECOVERED;
4094}
4095
4096static void serial8250_io_resume(struct pci_dev *dev)
4097{
4098 struct serial_private *priv = pci_get_drvdata(dev);
4099
4100 if (priv)
4101 pciserial_resume_ports(priv);
4102}
4103
4104static struct pci_error_handlers serial8250_err_handler = {
4105 .error_detected = serial8250_io_error_detected,
4106 .slot_reset = serial8250_io_slot_reset,
4107 .resume = serial8250_io_resume,
4108};
4109
3930static struct pci_driver serial_pci_driver = { 4110static struct pci_driver serial_pci_driver = {
3931 .name = "serial", 4111 .name = "serial",
3932 .probe = pciserial_init_one, 4112 .probe = pciserial_init_one,
@@ -3936,6 +4116,7 @@ static struct pci_driver serial_pci_driver = {
3936 .resume = pciserial_resume_one, 4116 .resume = pciserial_resume_one,
3937#endif 4117#endif
3938 .id_table = serial_pci_tbl, 4118 .id_table = serial_pci_tbl,
4119 .err_handler = &serial8250_err_handler,
3939}; 4120};
3940 4121
3941static int __init serial8250_pci_init(void) 4122static int __init serial8250_pci_init(void)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 8f41e1123461..cb40b82daf36 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1404,7 +1404,7 @@ config SERIAL_SC26XX
1404 1404
1405config SERIAL_SC26XX_CONSOLE 1405config SERIAL_SC26XX_CONSOLE
1406 bool "Console on SC2681/SC2692 serial port" 1406 bool "Console on SC2681/SC2692 serial port"
1407 depends on SERIAL_SC26XX 1407 depends on SERIAL_SC26XX=y
1408 select SERIAL_CORE_CONSOLE 1408 select SERIAL_CORE_CONSOLE
1409 help 1409 help
1410 Support for Console on SC2681/SC2692 serial ports. 1410 Support for Console on SC2681/SC2692 serial ports.
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 465210930890..846dfcd3ce0d 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -14,6 +14,7 @@
14 *along with this program; if not, write to the Free Software 14 *along with this program; if not, write to the Free Software
15 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 15 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16 */ 16 */
17#include <linux/kernel.h>
17#include <linux/serial_reg.h> 18#include <linux/serial_reg.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -44,6 +45,7 @@ enum {
44/* Set the max number of UART port 45/* Set the max number of UART port
45 * Intel EG20T PCH: 4 port 46 * Intel EG20T PCH: 4 port
46 * OKI SEMICONDUCTOR ML7213 IOH: 3 port 47 * OKI SEMICONDUCTOR ML7213 IOH: 3 port
48 * OKI SEMICONDUCTOR ML7223 IOH: 2 port
47*/ 49*/
48#define PCH_UART_NR 4 50#define PCH_UART_NR 4
49 51
@@ -137,8 +139,6 @@ enum {
137#define PCH_UART_DLL 0x00 139#define PCH_UART_DLL 0x00
138#define PCH_UART_DLM 0x01 140#define PCH_UART_DLM 0x01
139 141
140#define DIV_ROUND(a, b) (((a) + ((b)/2)) / (b))
141
142#define PCH_UART_IID_RLS (PCH_UART_IIR_REI) 142#define PCH_UART_IID_RLS (PCH_UART_IIR_REI)
143#define PCH_UART_IID_RDR (PCH_UART_IIR_RRI) 143#define PCH_UART_IID_RDR (PCH_UART_IIR_RRI)
144#define PCH_UART_IID_RDR_TO (PCH_UART_IIR_RRI | PCH_UART_IIR_TOI) 144#define PCH_UART_IID_RDR_TO (PCH_UART_IIR_RRI | PCH_UART_IIR_TOI)
@@ -316,7 +316,7 @@ static int pch_uart_hal_set_line(struct eg20t_port *priv, int baud,
316 unsigned int dll, dlm, lcr; 316 unsigned int dll, dlm, lcr;
317 int div; 317 int div;
318 318
319 div = DIV_ROUND(priv->base_baud / 16, baud); 319 div = DIV_ROUND_CLOSEST(priv->base_baud / 16, baud);
320 if (div < 0 || USHRT_MAX <= div) { 320 if (div < 0 || USHRT_MAX <= div) {
321 dev_err(priv->port.dev, "Invalid Baud(div=0x%x)\n", div); 321 dev_err(priv->port.dev, "Invalid Baud(div=0x%x)\n", div);
322 return -EINVAL; 322 return -EINVAL;
@@ -1429,6 +1429,8 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
1429 goto init_port_hal_free; 1429 goto init_port_hal_free;
1430 } 1430 }
1431 1431
1432 pci_enable_msi(pdev);
1433
1432 iobase = pci_resource_start(pdev, 0); 1434 iobase = pci_resource_start(pdev, 0);
1433 mapbase = pci_resource_start(pdev, 1); 1435 mapbase = pci_resource_start(pdev, 1);
1434 priv->mapbase = mapbase; 1436 priv->mapbase = mapbase;
@@ -1485,6 +1487,8 @@ static void pch_uart_pci_remove(struct pci_dev *pdev)
1485 struct eg20t_port *priv; 1487 struct eg20t_port *priv;
1486 1488
1487 priv = (struct eg20t_port *)pci_get_drvdata(pdev); 1489 priv = (struct eg20t_port *)pci_get_drvdata(pdev);
1490
1491 pci_disable_msi(pdev);
1488 pch_uart_exit_port(priv); 1492 pch_uart_exit_port(priv);
1489 pci_disable_device(pdev); 1493 pci_disable_device(pdev);
1490 kfree(priv); 1494 kfree(priv);
@@ -1568,6 +1572,7 @@ static int __devinit pch_uart_pci_probe(struct pci_dev *pdev,
1568 return ret; 1572 return ret;
1569 1573
1570probe_disable_device: 1574probe_disable_device:
1575 pci_disable_msi(pdev);
1571 pci_disable_device(pdev); 1576 pci_disable_device(pdev);
1572probe_error: 1577probe_error:
1573 return ret; 1578 return ret;
diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
index 8dd160c96e87..8b0b888a1b76 100644
--- a/drivers/tty/serial/s5pv210.c
+++ b/drivers/tty/serial/s5pv210.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/serial_core.h> 19#include <linux/serial_core.h>
20#include <linux/serial.h> 20#include <linux/serial.h>
21#include <linux/delay.h>
21 22
22#include <asm/irq.h> 23#include <asm/irq.h>
23#include <mach/hardware.h> 24#include <mach/hardware.h>
@@ -83,6 +84,9 @@ static int s5pv210_serial_resetport(struct uart_port *port,
83 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); 84 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
84 wr_regl(port, S3C2410_UFCON, cfg->ufcon); 85 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
85 86
87 /* It is need to delay When reset FIFO register */
88 udelay(1);
89
86 return 0; 90 return 0;
87} 91}
88 92
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 7ead42104c67..afc629423152 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1194,12 +1194,10 @@ int __devexit s3c24xx_serial_remove(struct platform_device *dev)
1194EXPORT_SYMBOL_GPL(s3c24xx_serial_remove); 1194EXPORT_SYMBOL_GPL(s3c24xx_serial_remove);
1195 1195
1196/* UART power management code */ 1196/* UART power management code */
1197 1197#ifdef CONFIG_PM_SLEEP
1198#ifdef CONFIG_PM 1198static int s3c24xx_serial_suspend(struct device *dev)
1199
1200static int s3c24xx_serial_suspend(struct platform_device *dev, pm_message_t state)
1201{ 1199{
1202 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); 1200 struct uart_port *port = s3c24xx_dev_to_port(dev);
1203 1201
1204 if (port) 1202 if (port)
1205 uart_suspend_port(&s3c24xx_uart_drv, port); 1203 uart_suspend_port(&s3c24xx_uart_drv, port);
@@ -1207,9 +1205,9 @@ static int s3c24xx_serial_suspend(struct platform_device *dev, pm_message_t stat
1207 return 0; 1205 return 0;
1208} 1206}
1209 1207
1210static int s3c24xx_serial_resume(struct platform_device *dev) 1208static int s3c24xx_serial_resume(struct device *dev)
1211{ 1209{
1212 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); 1210 struct uart_port *port = s3c24xx_dev_to_port(dev);
1213 struct s3c24xx_uart_port *ourport = to_ourport(port); 1211 struct s3c24xx_uart_port *ourport = to_ourport(port);
1214 1212
1215 if (port) { 1213 if (port) {
@@ -1222,17 +1220,20 @@ static int s3c24xx_serial_resume(struct platform_device *dev)
1222 1220
1223 return 0; 1221 return 0;
1224} 1222}
1225#endif 1223
1224static const struct dev_pm_ops s3c24xx_serial_pm_ops = {
1225 .suspend = s3c24xx_serial_suspend,
1226 .resume = s3c24xx_serial_resume,
1227};
1228#else /* !CONFIG_PM_SLEEP */
1229#define s3c24xx_serial_pm_ops NULL
1230#endif /* CONFIG_PM_SLEEP */
1226 1231
1227int s3c24xx_serial_init(struct platform_driver *drv, 1232int s3c24xx_serial_init(struct platform_driver *drv,
1228 struct s3c24xx_uart_info *info) 1233 struct s3c24xx_uart_info *info)
1229{ 1234{
1230 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info); 1235 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
1231 1236 drv->driver.pm = &s3c24xx_serial_pm_ops;
1232#ifdef CONFIG_PM
1233 drv->suspend = s3c24xx_serial_suspend;
1234 drv->resume = s3c24xx_serial_resume;
1235#endif
1236 1237
1237 return platform_driver_register(drv); 1238 return platform_driver_register(drv);
1238} 1239}
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 6556f7452ba6..150e4f747c7d 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -94,6 +94,7 @@
94#include <linux/delay.h> 94#include <linux/delay.h>
95#include <linux/seq_file.h> 95#include <linux/seq_file.h>
96#include <linux/serial.h> 96#include <linux/serial.h>
97#include <linux/ratelimit.h>
97 98
98#include <linux/uaccess.h> 99#include <linux/uaccess.h>
99#include <asm/system.h> 100#include <asm/system.h>
@@ -1420,8 +1421,7 @@ err_module_put:
1420 1421
1421 /* call the tty release_tty routine to clean out this slot */ 1422 /* call the tty release_tty routine to clean out this slot */
1422err_release_tty: 1423err_release_tty:
1423 if (printk_ratelimit()) 1424 printk_ratelimited(KERN_INFO "tty_init_dev: ldisc open failed, "
1424 printk(KERN_INFO "tty_init_dev: ldisc open failed, "
1425 "clearing slot %d\n", idx); 1425 "clearing slot %d\n", idx);
1426 release_tty(tty, idx); 1426 release_tty(tty, idx);
1427 return ERR_PTR(retval); 1427 return ERR_PTR(retval);