diff options
Diffstat (limited to 'drivers/usb/serial/ark3116.c')
-rw-r--r-- | drivers/usb/serial/ark3116.c | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index aec61880f36c..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 | }; |
36 | MODULE_DEVICE_TABLE(usb, id_table); | 36 | MODULE_DEVICE_TABLE(usb, id_table); |
37 | 37 | ||
38 | struct ark3116_private { | ||
39 | spinlock_t lock; | ||
40 | u8 termios_initialized; | ||
41 | }; | ||
42 | |||
43 | static inline void ARK3116_SND(struct usb_serial *serial, int seq, | 38 | static 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, | |||
82 | static int ark3116_attach(struct usb_serial *serial) | 77 | static 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 | ||
153 | cleanup: | 138 | static 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 | ||
161 | static void ark3116_set_termios(struct tty_struct *tty, | 148 | static 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); |
@@ -318,8 +293,7 @@ static void ark3116_set_termios(struct tty_struct *tty, | |||
318 | return; | 293 | return; |
319 | } | 294 | } |
320 | 295 | ||
321 | static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port, | 296 | static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) |
322 | struct file *filp) | ||
323 | { | 297 | { |
324 | struct ktermios tmp_termios; | 298 | struct ktermios tmp_termios; |
325 | struct usb_serial *serial = port->serial; | 299 | struct usb_serial *serial = port->serial; |
@@ -334,7 +308,7 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
334 | return -ENOMEM; | 308 | return -ENOMEM; |
335 | } | 309 | } |
336 | 310 | ||
337 | result = usb_serial_generic_open(tty, port, filp); | 311 | result = usb_serial_generic_open(tty, port); |
338 | if (result) | 312 | if (result) |
339 | goto err_out; | 313 | goto err_out; |
340 | 314 | ||
@@ -455,6 +429,7 @@ static struct usb_serial_driver ark3116_device = { | |||
455 | .num_ports = 1, | 429 | .num_ports = 1, |
456 | .attach = ark3116_attach, | 430 | .attach = ark3116_attach, |
457 | .set_termios = ark3116_set_termios, | 431 | .set_termios = ark3116_set_termios, |
432 | .init_termios = ark3116_init_termios, | ||
458 | .ioctl = ark3116_ioctl, | 433 | .ioctl = ark3116_ioctl, |
459 | .tiocmget = ark3116_tiocmget, | 434 | .tiocmget = ark3116_tiocmget, |
460 | .open = ark3116_open, | 435 | .open = ark3116_open, |