aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ark3116.c
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 /drivers/usb/serial/ark3116.c
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>
Diffstat (limited to 'drivers/usb/serial/ark3116.c')
-rw-r--r--drivers/usb/serial/ark3116.c46
1 files changed, 11 insertions, 35 deletions
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,