aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-09-19 16:13:33 -0400
committerLive-CD User <linux@linux.site>2009-09-19 16:13:33 -0400
commitfe1ae7fdd2ee603f2d95f04e09a68f7f79045127 (patch)
tree1234647e3bd970cfb105dab1c4f0ad2cd14ce179
parentba15ab0e8de0d4439a91342ad52d55ca9e313f3d (diff)
tty: USB serial termios bits
Various drivers have hacks to mangle termios structures. This stems from the fact there is no nice setup hook for configuring the termios settings when the port is created Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/char/tty_io.c1
-rw-r--r--drivers/usb/serial/ark3116.c46
-rw-r--r--drivers/usb/serial/cypress_m8.c12
-rw-r--r--drivers/usb/serial/empeg.c12
-rw-r--r--drivers/usb/serial/iuu_phoenix.c31
-rw-r--r--drivers/usb/serial/kobil_sct.c22
-rw-r--r--drivers/usb/serial/oti6858.c21
-rw-r--r--drivers/usb/serial/spcp8x5.c21
-rw-r--r--drivers/usb/serial/usb-serial.c38
-rw-r--r--drivers/usb/serial/whiteheat.c6
-rw-r--r--include/linux/usb/serial.h3
11 files changed, 106 insertions, 107 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 385cca7074da..05f443c47bbe 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1184,6 +1184,7 @@ int tty_init_termios(struct tty_struct *tty)
1184 tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios); 1184 tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);
1185 return 0; 1185 return 0;
1186} 1186}
1187EXPORT_SYMBOL_GPL(tty_init_termios);
1187 1188
1188/** 1189/**
1189 * tty_driver_install_tty() - install a tty entry in the driver 1190 * tty_driver_install_tty() - install a tty entry in the driver
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 7ddde4ddfb4b..5d25d3e52bf6 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -35,11 +35,6 @@ static struct usb_device_id id_table [] = {
35}; 35};
36MODULE_DEVICE_TABLE(usb, id_table); 36MODULE_DEVICE_TABLE(usb, id_table);
37 37
38struct ark3116_private {
39 spinlock_t lock;
40 u8 termios_initialized;
41};
42
43static inline void ARK3116_SND(struct usb_serial *serial, int seq, 38static inline void ARK3116_SND(struct usb_serial *serial, int seq,
44 __u8 request, __u8 requesttype, 39 __u8 request, __u8 requesttype,
45 __u16 value, __u16 index) 40 __u16 value, __u16 index)
@@ -82,22 +77,11 @@ static inline void ARK3116_RCV_QUIET(struct usb_serial *serial,
82static int ark3116_attach(struct usb_serial *serial) 77static int ark3116_attach(struct usb_serial *serial)
83{ 78{
84 char *buf; 79 char *buf;
85 struct ark3116_private *priv;
86 int i;
87
88 for (i = 0; i < serial->num_ports; ++i) {
89 priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
90 if (!priv)
91 goto cleanup;
92 spin_lock_init(&priv->lock);
93
94 usb_set_serial_port_data(serial->port[i], priv);
95 }
96 80
97 buf = kmalloc(1, GFP_KERNEL); 81 buf = kmalloc(1, GFP_KERNEL);
98 if (!buf) { 82 if (!buf) {
99 dbg("error kmalloc -> out of mem?"); 83 dbg("error kmalloc -> out of mem?");
100 goto cleanup; 84 return -ENOMEM;
101 } 85 }
102 86
103 /* 3 */ 87 /* 3 */
@@ -149,13 +133,16 @@ static int ark3116_attach(struct usb_serial *serial)
149 133
150 kfree(buf); 134 kfree(buf);
151 return 0; 135 return 0;
136}
152 137
153cleanup: 138static void ark3116_init_termios(struct tty_struct *tty)
154 for (--i; i >= 0; --i) { 139{
155 kfree(usb_get_serial_port_data(serial->port[i])); 140 struct ktermios *termios = tty->termios;
156 usb_set_serial_port_data(serial->port[i], NULL); 141 *termios = tty_std_termios;
157 } 142 termios->c_cflag = B9600 | CS8
158 return -ENOMEM; 143 | CREAD | HUPCL | CLOCAL;
144 termios->c_ispeed = 9600;
145 termios->c_ospeed = 9600;
159} 146}
160 147
161static void ark3116_set_termios(struct tty_struct *tty, 148static void ark3116_set_termios(struct tty_struct *tty,
@@ -163,10 +150,8 @@ static void ark3116_set_termios(struct tty_struct *tty,
163 struct ktermios *old_termios) 150 struct ktermios *old_termios)
164{ 151{
165 struct usb_serial *serial = port->serial; 152 struct usb_serial *serial = port->serial;
166 struct ark3116_private *priv = usb_get_serial_port_data(port);
167 struct ktermios *termios = tty->termios; 153 struct ktermios *termios = tty->termios;
168 unsigned int cflag = termios->c_cflag; 154 unsigned int cflag = termios->c_cflag;
169 unsigned long flags;
170 int baud; 155 int baud;
171 int ark3116_baud; 156 int ark3116_baud;
172 char *buf; 157 char *buf;
@@ -176,16 +161,6 @@ static void ark3116_set_termios(struct tty_struct *tty,
176 161
177 dbg("%s - port %d", __func__, port->number); 162 dbg("%s - port %d", __func__, port->number);
178 163
179 spin_lock_irqsave(&priv->lock, flags);
180 if (!priv->termios_initialized) {
181 *termios = tty_std_termios;
182 termios->c_cflag = B9600 | CS8
183 | CREAD | HUPCL | CLOCAL;
184 termios->c_ispeed = 9600;
185 termios->c_ospeed = 9600;
186 priv->termios_initialized = 1;
187 }
188 spin_unlock_irqrestore(&priv->lock, flags);
189 164
190 cflag = termios->c_cflag; 165 cflag = termios->c_cflag;
191 termios->c_cflag &= ~(CMSPAR|CRTSCTS); 166 termios->c_cflag &= ~(CMSPAR|CRTSCTS);
@@ -454,6 +429,7 @@ static struct usb_serial_driver ark3116_device = {
454 .num_ports = 1, 429 .num_ports = 1,
455 .attach = ark3116_attach, 430 .attach = ark3116_attach,
456 .set_termios = ark3116_set_termios, 431 .set_termios = ark3116_set_termios,
432 .init_termios = ark3116_init_termios,
457 .ioctl = ark3116_ioctl, 433 .ioctl = ark3116_ioctl,
458 .tiocmget = ark3116_tiocmget, 434 .tiocmget = ark3116_tiocmget,
459 .open = ark3116_open, 435 .open = ark3116_open,
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index df1adb9a4367..e0a8b715f2f2 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -657,15 +657,7 @@ static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
657 spin_unlock_irqrestore(&priv->lock, flags); 657 spin_unlock_irqrestore(&priv->lock, flags);
658 658
659 /* Set termios */ 659 /* Set termios */
660 result = cypress_write(tty, port, NULL, 0); 660 cypress_send(port);
661
662 if (result) {
663 dev_err(&port->dev,
664 "%s - failed setting the control lines - error %d\n",
665 __func__, result);
666 return result;
667 } else
668 dbg("%s - success setting the control lines", __func__);
669 661
670 if (tty) 662 if (tty)
671 cypress_set_termios(tty, port, &priv->tmp_termios); 663 cypress_set_termios(tty, port, &priv->tmp_termios);
@@ -1003,6 +995,8 @@ static void cypress_set_termios(struct tty_struct *tty,
1003 dbg("%s - port %d", __func__, port->number); 995 dbg("%s - port %d", __func__, port->number);
1004 996
1005 spin_lock_irqsave(&priv->lock, flags); 997 spin_lock_irqsave(&priv->lock, flags);
998 /* We can't clean this one up as we don't know the device type
999 early enough */
1006 if (!priv->termios_initialized) { 1000 if (!priv->termios_initialized) {
1007 if (priv->chiptype == CT_EARTHMATE) { 1001 if (priv->chiptype == CT_EARTHMATE) {
1008 *(tty->termios) = tty_std_termios; 1002 *(tty->termios) = tty_std_termios;
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index da559a773b51..33c9e9cf9eb2 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -89,8 +89,7 @@ static int empeg_chars_in_buffer(struct tty_struct *tty);
89static void empeg_throttle(struct tty_struct *tty); 89static void empeg_throttle(struct tty_struct *tty);
90static void empeg_unthrottle(struct tty_struct *tty); 90static void empeg_unthrottle(struct tty_struct *tty);
91static int empeg_startup(struct usb_serial *serial); 91static int empeg_startup(struct usb_serial *serial);
92static void empeg_set_termios(struct tty_struct *tty, 92static void empeg_init_termios(struct tty_struct *tty);
93 struct usb_serial_port *port, struct ktermios *old_termios);
94static void empeg_write_bulk_callback(struct urb *urb); 93static void empeg_write_bulk_callback(struct urb *urb);
95static void empeg_read_bulk_callback(struct urb *urb); 94static void empeg_read_bulk_callback(struct urb *urb);
96 95
@@ -122,7 +121,7 @@ static struct usb_serial_driver empeg_device = {
122 .throttle = empeg_throttle, 121 .throttle = empeg_throttle,
123 .unthrottle = empeg_unthrottle, 122 .unthrottle = empeg_unthrottle,
124 .attach = empeg_startup, 123 .attach = empeg_startup,
125 .set_termios = empeg_set_termios, 124 .init_termios = empeg_init_termios,
126 .write = empeg_write, 125 .write = empeg_write,
127 .write_room = empeg_write_room, 126 .write_room = empeg_write_room,
128 .chars_in_buffer = empeg_chars_in_buffer, 127 .chars_in_buffer = empeg_chars_in_buffer,
@@ -148,9 +147,6 @@ static int empeg_open(struct tty_struct *tty,struct usb_serial_port *port)
148 147
149 dbg("%s - port %d", __func__, port->number); 148 dbg("%s - port %d", __func__, port->number);
150 149
151 /* Force default termio settings */
152 empeg_set_termios(tty, port, NULL);
153
154 bytes_in = 0; 150 bytes_in = 0;
155 bytes_out = 0; 151 bytes_out = 0;
156 152
@@ -423,11 +419,9 @@ static int empeg_startup(struct usb_serial *serial)
423} 419}
424 420
425 421
426static void empeg_set_termios(struct tty_struct *tty, 422static void empeg_init_termios(struct tty_struct *tty)
427 struct usb_serial_port *port, struct ktermios *old_termios)
428{ 423{
429 struct ktermios *termios = tty->termios; 424 struct ktermios *termios = tty->termios;
430 dbg("%s - port %d", __func__, port->number);
431 425
432 /* 426 /*
433 * The empeg-car player wants these particular tty settings. 427 * The empeg-car player wants these particular tty settings.
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index f3f9be0469c5..6138c1cda35f 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -71,7 +71,6 @@ struct iuu_private {
71 spinlock_t lock; /* store irq state */ 71 spinlock_t lock; /* store irq state */
72 wait_queue_head_t delta_msr_wait; 72 wait_queue_head_t delta_msr_wait;
73 u8 line_status; 73 u8 line_status;
74 u8 termios_initialized;
75 int tiostatus; /* store IUART SIGNAL for tiocmget call */ 74 int tiostatus; /* store IUART SIGNAL for tiocmget call */
76 u8 reset; /* if 1 reset is needed */ 75 u8 reset; /* if 1 reset is needed */
77 int poll; /* number of poll */ 76 int poll; /* number of poll */
@@ -1018,13 +1017,24 @@ static void iuu_close(struct usb_serial_port *port)
1018 } 1017 }
1019} 1018}
1020 1019
1020static void iuu_init_termios(struct tty_struct *tty)
1021{
1022 *(tty->termios) = tty_std_termios;
1023 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
1024 | TIOCM_CTS | CSTOPB | PARENB;
1025 tty->termios->c_ispeed = 9600;
1026 tty->termios->c_ospeed = 9600;
1027 tty->termios->c_lflag = 0;
1028 tty->termios->c_oflag = 0;
1029 tty->termios->c_iflag = 0;
1030}
1031
1021static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) 1032static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1022{ 1033{
1023 struct usb_serial *serial = port->serial; 1034 struct usb_serial *serial = port->serial;
1024 u8 *buf; 1035 u8 *buf;
1025 int result; 1036 int result;
1026 u32 actual; 1037 u32 actual;
1027 unsigned long flags;
1028 struct iuu_private *priv = usb_get_serial_port_data(port); 1038 struct iuu_private *priv = usb_get_serial_port_data(port);
1029 1039
1030 dbg("%s - port %d", __func__, port->number); 1040 dbg("%s - port %d", __func__, port->number);
@@ -1063,21 +1073,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1063 port->bulk_in_buffer, 512, 1073 port->bulk_in_buffer, 512,
1064 NULL, NULL); 1074 NULL, NULL);
1065 1075
1066 /* set the termios structure */ 1076 priv->poll = 0;
1067 spin_lock_irqsave(&priv->lock, flags);
1068 if (tty && !priv->termios_initialized) {
1069 *(tty->termios) = tty_std_termios;
1070 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
1071 | TIOCM_CTS | CSTOPB | PARENB;
1072 tty->termios->c_ispeed = 9600;
1073 tty->termios->c_ospeed = 9600;
1074 tty->termios->c_lflag = 0;
1075 tty->termios->c_oflag = 0;
1076 tty->termios->c_iflag = 0;
1077 priv->termios_initialized = 1;
1078 priv->poll = 0;
1079 }
1080 spin_unlock_irqrestore(&priv->lock, flags);
1081 1077
1082 /* initialize writebuf */ 1078 /* initialize writebuf */
1083#define FISH(a, b, c, d) do { \ 1079#define FISH(a, b, c, d) do { \
@@ -1200,6 +1196,7 @@ static struct usb_serial_driver iuu_device = {
1200 .tiocmget = iuu_tiocmget, 1196 .tiocmget = iuu_tiocmget,
1201 .tiocmset = iuu_tiocmset, 1197 .tiocmset = iuu_tiocmset,
1202 .set_termios = iuu_set_termios, 1198 .set_termios = iuu_set_termios,
1199 .init_termios = iuu_init_termios,
1203 .attach = iuu_startup, 1200 .attach = iuu_startup,
1204 .release = iuu_release, 1201 .release = iuu_release,
1205}; 1202};
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 97901578343a..45ea694b3ae6 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -84,7 +84,7 @@ static void kobil_read_int_callback(struct urb *urb);
84static void kobil_write_callback(struct urb *purb); 84static void kobil_write_callback(struct urb *purb);
85static void kobil_set_termios(struct tty_struct *tty, 85static void kobil_set_termios(struct tty_struct *tty,
86 struct usb_serial_port *port, struct ktermios *old); 86 struct usb_serial_port *port, struct ktermios *old);
87 87static void kobil_init_termios(struct tty_struct *tty);
88 88
89static struct usb_device_id id_table [] = { 89static struct usb_device_id id_table [] = {
90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, 90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) },
@@ -119,6 +119,7 @@ static struct usb_serial_driver kobil_device = {
119 .release = kobil_release, 119 .release = kobil_release,
120 .ioctl = kobil_ioctl, 120 .ioctl = kobil_ioctl,
121 .set_termios = kobil_set_termios, 121 .set_termios = kobil_set_termios,
122 .init_termios = kobil_init_termios,
122 .tiocmget = kobil_tiocmget, 123 .tiocmget = kobil_tiocmget,
123 .tiocmset = kobil_tiocmset, 124 .tiocmset = kobil_tiocmset,
124 .open = kobil_open, 125 .open = kobil_open,
@@ -209,6 +210,15 @@ static void kobil_release(struct usb_serial *serial)
209 kfree(usb_get_serial_port_data(serial->port[i])); 210 kfree(usb_get_serial_port_data(serial->port[i]));
210} 211}
211 212
213static void kobil_init_termios(struct tty_struct *tty)
214{
215 /* Default to echo off and other sane device settings */
216 tty->termios->c_lflag = 0;
217 tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
218 tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
219 /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
220 tty->termios->c_oflag &= ~ONLCR;
221}
212 222
213static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) 223static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
214{ 224{
@@ -224,16 +234,6 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
224 /* someone sets the dev to 0 if the close method has been called */ 234 /* someone sets the dev to 0 if the close method has been called */
225 port->interrupt_in_urb->dev = port->serial->dev; 235 port->interrupt_in_urb->dev = port->serial->dev;
226 236
227 if (tty) {
228
229 /* Default to echo off and other sane device settings */
230 tty->termios->c_lflag = 0;
231 tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN |
232 XCASE);
233 tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
234 /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
235 tty->termios->c_oflag &= ~ONLCR;
236 }
237 /* allocate memory for transfer buffer */ 237 /* allocate memory for transfer buffer */
238 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); 238 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
239 if (!transfer_buffer) 239 if (!transfer_buffer)
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index e90f88a3b040..0f4a70ce3823 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -145,6 +145,7 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port);
145static void oti6858_close(struct usb_serial_port *port); 145static void oti6858_close(struct usb_serial_port *port);
146static void oti6858_set_termios(struct tty_struct *tty, 146static void oti6858_set_termios(struct tty_struct *tty,
147 struct usb_serial_port *port, struct ktermios *old); 147 struct usb_serial_port *port, struct ktermios *old);
148static void oti6858_init_termios(struct tty_struct *tty);
148static int oti6858_ioctl(struct tty_struct *tty, struct file *file, 149static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
149 unsigned int cmd, unsigned long arg); 150 unsigned int cmd, unsigned long arg);
150static void oti6858_read_int_callback(struct urb *urb); 151static void oti6858_read_int_callback(struct urb *urb);
@@ -185,6 +186,7 @@ static struct usb_serial_driver oti6858_device = {
185 .write = oti6858_write, 186 .write = oti6858_write,
186 .ioctl = oti6858_ioctl, 187 .ioctl = oti6858_ioctl,
187 .set_termios = oti6858_set_termios, 188 .set_termios = oti6858_set_termios,
189 .init_termios = oti6858_init_termios,
188 .tiocmget = oti6858_tiocmget, 190 .tiocmget = oti6858_tiocmget,
189 .tiocmset = oti6858_tiocmset, 191 .tiocmset = oti6858_tiocmset,
190 .read_bulk_callback = oti6858_read_bulk_callback, 192 .read_bulk_callback = oti6858_read_bulk_callback,
@@ -205,7 +207,6 @@ struct oti6858_private {
205 struct { 207 struct {
206 u8 read_urb_in_use; 208 u8 read_urb_in_use;
207 u8 write_urb_in_use; 209 u8 write_urb_in_use;
208 u8 termios_initialized;
209 } flags; 210 } flags;
210 struct delayed_work delayed_write_work; 211 struct delayed_work delayed_write_work;
211 212
@@ -446,6 +447,14 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty)
446 return chars; 447 return chars;
447} 448}
448 449
450static void oti6858_init_termios(struct tty_struct *tty)
451{
452 *(tty->termios) = tty_std_termios;
453 tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
454 tty->termios->c_ispeed = 38400;
455 tty->termios->c_ospeed = 38400;
456}
457
449static void oti6858_set_termios(struct tty_struct *tty, 458static void oti6858_set_termios(struct tty_struct *tty,
450 struct usb_serial_port *port, struct ktermios *old_termios) 459 struct usb_serial_port *port, struct ktermios *old_termios)
451{ 460{
@@ -463,16 +472,6 @@ static void oti6858_set_termios(struct tty_struct *tty,
463 return; 472 return;
464 } 473 }
465 474
466 spin_lock_irqsave(&priv->lock, flags);
467 if (!priv->flags.termios_initialized) {
468 *(tty->termios) = tty_std_termios;
469 tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
470 tty->termios->c_ispeed = 38400;
471 tty->termios->c_ospeed = 38400;
472 priv->flags.termios_initialized = 1;
473 }
474 spin_unlock_irqrestore(&priv->lock, flags);
475
476 cflag = tty->termios->c_cflag; 475 cflag = tty->termios->c_cflag;
477 476
478 spin_lock_irqsave(&priv->lock, flags); 477 spin_lock_irqsave(&priv->lock, flags);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 8b312a05a353..61e7c40b94fb 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -299,7 +299,6 @@ struct spcp8x5_private {
299 wait_queue_head_t delta_msr_wait; 299 wait_queue_head_t delta_msr_wait;
300 u8 line_control; 300 u8 line_control;
301 u8 line_status; 301 u8 line_status;
302 u8 termios_initialized;
303}; 302};
304 303
305/* desc : when device plug in,this function would be called. 304/* desc : when device plug in,this function would be called.
@@ -498,6 +497,15 @@ static void spcp8x5_close(struct usb_serial_port *port)
498 dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result); 497 dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result);
499} 498}
500 499
500static void spcp8x5_init_termios(struct tty_struct *tty)
501{
502 /* for the 1st time call this function */
503 *(tty->termios) = tty_std_termios;
504 tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
505 tty->termios->c_ispeed = 115200;
506 tty->termios->c_ospeed = 115200;
507}
508
501/* set the serial param for transfer. we should check if we really need to 509/* set the serial param for transfer. we should check if we really need to
502 * transfer. if we set flow control we should do this too. */ 510 * transfer. if we set flow control we should do this too. */
503static void spcp8x5_set_termios(struct tty_struct *tty, 511static void spcp8x5_set_termios(struct tty_struct *tty,
@@ -514,16 +522,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
514 int i; 522 int i;
515 u8 control; 523 u8 control;
516 524
517 /* for the 1st time call this function */
518 spin_lock_irqsave(&priv->lock, flags);
519 if (!priv->termios_initialized) {
520 *(tty->termios) = tty_std_termios;
521 tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
522 tty->termios->c_ispeed = 115200;
523 tty->termios->c_ospeed = 115200;
524 priv->termios_initialized = 1;
525 }
526 spin_unlock_irqrestore(&priv->lock, flags);
527 525
528 /* check that they really want us to change something */ 526 /* check that they really want us to change something */
529 if (!tty_termios_hw_change(tty->termios, old_termios)) 527 if (!tty_termios_hw_change(tty->termios, old_termios))
@@ -1008,6 +1006,7 @@ static struct usb_serial_driver spcp8x5_device = {
1008 .carrier_raised = spcp8x5_carrier_raised, 1006 .carrier_raised = spcp8x5_carrier_raised,
1009 .write = spcp8x5_write, 1007 .write = spcp8x5_write,
1010 .set_termios = spcp8x5_set_termios, 1008 .set_termios = spcp8x5_set_termios,
1009 .init_termios = spcp8x5_init_termios,
1011 .ioctl = spcp8x5_ioctl, 1010 .ioctl = spcp8x5_ioctl,
1012 .tiocmget = spcp8x5_tiocmget, 1011 .tiocmget = spcp8x5_tiocmget,
1013 .tiocmset = spcp8x5_tiocmset, 1012 .tiocmset = spcp8x5_tiocmset,
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 3dda6841e724..80c1f4d8e910 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -721,6 +721,41 @@ static const struct tty_port_operations serial_port_ops = {
721 .dtr_rts = serial_dtr_rts, 721 .dtr_rts = serial_dtr_rts,
722}; 722};
723 723
724/**
725 * serial_install - install tty
726 * @driver: the driver (USB in our case)
727 * @tty: the tty being created
728 *
729 * Create the termios objects for this tty. We use the default USB
730 * serial ones but permit them to be overriddenby serial->type->termios.
731 * This lets us remove all the ugly hackery
732 */
733
734static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
735{
736 int idx = tty->index;
737 struct usb_serial *serial;
738 int retval;
739
740 /* If the termios setup has yet to be done */
741 if (tty->driver->termios[idx] == NULL) {
742 /* perform the standard setup */
743 retval = tty_init_termios(tty);
744 if (retval)
745 return retval;
746 /* allow the driver to update it */
747 serial = usb_serial_get_by_index(tty->index);
748 if (serial->type->init_termios)
749 serial->type->init_termios(tty);
750 usb_serial_put(serial);
751 }
752 /* Final install (we use the default method) */
753 tty_driver_kref_get(driver);
754 tty->count++;
755 driver->ttys[idx] = tty;
756 return 0;
757}
758
724int usb_serial_probe(struct usb_interface *interface, 759int usb_serial_probe(struct usb_interface *interface,
725 const struct usb_device_id *id) 760 const struct usb_device_id *id)
726{ 761{
@@ -1228,7 +1263,8 @@ static const struct tty_operations serial_ops = {
1228 .chars_in_buffer = serial_chars_in_buffer, 1263 .chars_in_buffer = serial_chars_in_buffer,
1229 .tiocmget = serial_tiocmget, 1264 .tiocmget = serial_tiocmget,
1230 .tiocmset = serial_tiocmset, 1265 .tiocmset = serial_tiocmset,
1231 .shutdown = serial_do_free, 1266 .shutdown = serial_do_free,
1267 .install = serial_install,
1232 .proc_fops = &serial_proc_fops, 1268 .proc_fops = &serial_proc_fops,
1233}; 1269};
1234 1270
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 81f2ae505966..62424eec33ec 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -259,7 +259,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
259 __u8 *data, __u8 datasize); 259 __u8 *data, __u8 datasize);
260static int firm_open(struct usb_serial_port *port); 260static int firm_open(struct usb_serial_port *port);
261static int firm_close(struct usb_serial_port *port); 261static int firm_close(struct usb_serial_port *port);
262static int firm_setup_port(struct tty_struct *tty); 262static void firm_setup_port(struct tty_struct *tty);
263static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); 263static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
264static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); 264static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
265static int firm_set_break(struct usb_serial_port *port, __u8 onoff); 265static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
@@ -1210,7 +1210,7 @@ static int firm_close(struct usb_serial_port *port)
1210} 1210}
1211 1211
1212 1212
1213static int firm_setup_port(struct tty_struct *tty) 1213static void firm_setup_port(struct tty_struct *tty)
1214{ 1214{
1215 struct usb_serial_port *port = tty->driver_data; 1215 struct usb_serial_port *port = tty->driver_data;
1216 struct whiteheat_port_settings port_settings; 1216 struct whiteheat_port_settings port_settings;
@@ -1285,7 +1285,7 @@ static int firm_setup_port(struct tty_struct *tty)
1285 port_settings.lloop = 0; 1285 port_settings.lloop = 0;
1286 1286
1287 /* now send the message to the device */ 1287 /* now send the message to the device */
1288 return firm_send_command(port, WHITEHEAT_SETUP_PORT, 1288 firm_send_command(port, WHITEHEAT_SETUP_PORT,
1289 (__u8 *)&port_settings, sizeof(port_settings)); 1289 (__u8 *)&port_settings, sizeof(port_settings));
1290} 1290}
1291 1291
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 1cbaf4a6b449..7b85e327af91 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -260,6 +260,9 @@ struct usb_serial_driver {
260 be an attached tty at this point */ 260 be an attached tty at this point */
261 void (*dtr_rts)(struct usb_serial_port *port, int on); 261 void (*dtr_rts)(struct usb_serial_port *port, int on);
262 int (*carrier_raised)(struct usb_serial_port *port); 262 int (*carrier_raised)(struct usb_serial_port *port);
263 /* Called by the usb serial hooks to allow the user to rework the
264 termios state */
265 void (*init_termios)(struct tty_struct *tty);
263 /* USB events */ 266 /* USB events */
264 void (*read_int_callback)(struct urb *urb); 267 void (*read_int_callback)(struct urb *urb);
265 void (*write_int_callback)(struct urb *urb); 268 void (*write_int_callback)(struct urb *urb);