diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:11:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:23 -0400 |
commit | 93c467952ff6b5c3d92fddf4b1a609e68f6d08d1 (patch) | |
tree | 615e630a7803df0c22a1c68d9927620de11aef7e /drivers/usb/serial/empeg.c | |
parent | 41ad427da1f9303e2e34811398b31c999c3d39d1 (diff) |
empeg: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/empeg.c')
-rw-r--r-- | drivers/usb/serial/empeg.c | 203 |
1 files changed, 107 insertions, 96 deletions
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 47ebdf5fad8e..a6ab5b58d9ca 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -11,36 +11,39 @@ | |||
11 | * it under the terms of the GNU General Public License, as published by | 11 | * it under the terms of the GNU General Public License, as published by |
12 | * the Free Software Foundation, version 2. | 12 | * the Free Software Foundation, version 2. |
13 | * | 13 | * |
14 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 14 | * See Documentation/usb/usb-serial.txt for more information on using this |
15 | * | 15 | * driver |
16 | * | ||
16 | * (07/16/2001) gb | 17 | * (07/16/2001) gb |
17 | * remove unused code in empeg_close() (thanks to Oliver Neukum for pointing this | 18 | * remove unused code in empeg_close() (thanks to Oliver Neukum for |
18 | * out) and rewrote empeg_set_termios(). | 19 | * pointing this out) and rewrote empeg_set_termios(). |
19 | * | 20 | * |
20 | * (05/30/2001) gkh | 21 | * (05/30/2001) gkh |
21 | * switched from using spinlock to a semaphore, which fixes lots of problems. | 22 | * switched from using spinlock to a semaphore, which fixes lots of |
23 | * problems. | ||
22 | * | 24 | * |
23 | * (04/08/2001) gb | 25 | * (04/08/2001) gb |
24 | * Identify version on module load. | 26 | * Identify version on module load. |
25 | * | 27 | * |
26 | * (01/22/2001) gb | 28 | * (01/22/2001) gb |
27 | * Added write_room() and chars_in_buffer() support. | 29 | * Added write_room() and chars_in_buffer() support. |
28 | * | 30 | * |
29 | * (12/21/2000) gb | 31 | * (12/21/2000) gb |
30 | * Moved termio stuff inside the port->active check. | 32 | * Moved termio stuff inside the port->active check. |
31 | * Moved MOD_DEC_USE_COUNT to end of empeg_close(). | 33 | * Moved MOD_DEC_USE_COUNT to end of empeg_close(). |
32 | * | 34 | * |
33 | * (12/03/2000) gb | 35 | * (12/03/2000) gb |
34 | * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open() | 36 | * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to |
35 | * This notifies the tty driver that the termios have changed. | 37 | * empeg_open(). This notifies the tty driver that the termios have |
36 | * | 38 | * changed. |
39 | * | ||
37 | * (11/13/2000) gb | 40 | * (11/13/2000) gb |
38 | * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to empeg_open() | 41 | * Moved tty->low_latency = 1 from empeg_read_bulk_callback() to |
39 | * (It only needs to be set once - Doh!) | 42 | * empeg_open() (It only needs to be set once - Doh!) |
40 | * | 43 | * |
41 | * (11/11/2000) gb | 44 | * (11/11/2000) gb |
42 | * Updated to work with id_table structure. | 45 | * Updated to work with id_table structure. |
43 | * | 46 | * |
44 | * (11/04/2000) gb | 47 | * (11/04/2000) gb |
45 | * Forked this from visor.c, and hacked it up to work with an | 48 | * Forked this from visor.c, and hacked it up to work with an |
46 | * Empeg ltd. empeg-car player. Constructive criticism welcomed. | 49 | * Empeg ltd. empeg-car player. Constructive criticism welcomed. |
@@ -48,7 +51,7 @@ | |||
48 | * use of his code, and for his guidance, advice and patience. :) | 51 | * use of his code, and for his guidance, advice and patience. :) |
49 | * A 'Thank You' is in order for John Ripley of Empeg ltd for his | 52 | * A 'Thank You' is in order for John Ripley of Empeg ltd for his |
50 | * advice, and patience too. | 53 | * advice, and patience too. |
51 | * | 54 | * |
52 | */ | 55 | */ |
53 | 56 | ||
54 | #include <linux/kernel.h> | 57 | #include <linux/kernel.h> |
@@ -60,7 +63,7 @@ | |||
60 | #include <linux/tty_flip.h> | 63 | #include <linux/tty_flip.h> |
61 | #include <linux/module.h> | 64 | #include <linux/module.h> |
62 | #include <linux/spinlock.h> | 65 | #include <linux/spinlock.h> |
63 | #include <asm/uaccess.h> | 66 | #include <linux/uaccess.h> |
64 | #include <linux/usb.h> | 67 | #include <linux/usb.h> |
65 | #include <linux/usb/serial.h> | 68 | #include <linux/usb/serial.h> |
66 | 69 | ||
@@ -77,27 +80,30 @@ static int debug; | |||
77 | #define EMPEG_PRODUCT_ID 0x0001 | 80 | #define EMPEG_PRODUCT_ID 0x0001 |
78 | 81 | ||
79 | /* function prototypes for an empeg-car player */ | 82 | /* function prototypes for an empeg-car player */ |
80 | static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 83 | static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, |
81 | static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 84 | struct file *filp); |
82 | static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port, | 85 | static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, |
83 | const unsigned char *buf, | 86 | struct file *filp); |
84 | int count); | 87 | static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, |
85 | static int empeg_write_room (struct tty_struct *tty); | 88 | const unsigned char *buf, |
86 | static int empeg_chars_in_buffer (struct tty_struct *tty); | 89 | int count); |
87 | static void empeg_throttle (struct tty_struct *tty); | 90 | static int empeg_write_room(struct tty_struct *tty); |
88 | static void empeg_unthrottle (struct tty_struct *tty); | 91 | static int empeg_chars_in_buffer(struct tty_struct *tty); |
89 | static int empeg_startup (struct usb_serial *serial); | 92 | static void empeg_throttle(struct tty_struct *tty); |
90 | static void empeg_shutdown (struct usb_serial *serial); | 93 | static void empeg_unthrottle(struct tty_struct *tty); |
91 | static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios); | 94 | static int empeg_startup(struct usb_serial *serial); |
92 | static void empeg_write_bulk_callback (struct urb *urb); | 95 | static void empeg_shutdown(struct usb_serial *serial); |
93 | static void empeg_read_bulk_callback (struct urb *urb); | 96 | static void empeg_set_termios(struct tty_struct *tty, |
97 | struct usb_serial_port *port, struct ktermios *old_termios); | ||
98 | static void empeg_write_bulk_callback(struct urb *urb); | ||
99 | static void empeg_read_bulk_callback(struct urb *urb); | ||
94 | 100 | ||
95 | static struct usb_device_id id_table [] = { | 101 | static struct usb_device_id id_table [] = { |
96 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, | 102 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, |
97 | { } /* Terminating entry */ | 103 | { } /* Terminating entry */ |
98 | }; | 104 | }; |
99 | 105 | ||
100 | MODULE_DEVICE_TABLE (usb, id_table); | 106 | MODULE_DEVICE_TABLE(usb, id_table); |
101 | 107 | ||
102 | static struct usb_driver empeg_driver = { | 108 | static struct usb_driver empeg_driver = { |
103 | .name = "empeg", | 109 | .name = "empeg", |
@@ -149,7 +155,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
149 | dbg("%s - port %d", __func__, port->number); | 155 | dbg("%s - port %d", __func__, port->number); |
150 | 156 | ||
151 | /* Force default termio settings */ | 157 | /* Force default termio settings */ |
152 | empeg_set_termios (tty, port, NULL) ; | 158 | empeg_set_termios(tty, port, NULL) ; |
153 | 159 | ||
154 | bytes_in = 0; | 160 | bytes_in = 0; |
155 | bytes_out = 0; | 161 | bytes_out = 0; |
@@ -157,7 +163,7 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
157 | /* Start reading from the device */ | 163 | /* Start reading from the device */ |
158 | usb_fill_bulk_urb( | 164 | usb_fill_bulk_urb( |
159 | port->read_urb, | 165 | port->read_urb, |
160 | serial->dev, | 166 | serial->dev, |
161 | usb_rcvbulkpipe(serial->dev, | 167 | usb_rcvbulkpipe(serial->dev, |
162 | port->bulk_in_endpointAddress), | 168 | port->bulk_in_endpointAddress), |
163 | port->read_urb->transfer_buffer, | 169 | port->read_urb->transfer_buffer, |
@@ -168,14 +174,16 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, | |||
168 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 174 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
169 | 175 | ||
170 | if (result) | 176 | if (result) |
171 | dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); | 177 | dev_err(&port->dev, |
178 | "%s - failed submitting read urb, error %d\n", | ||
179 | __func__, result); | ||
172 | 180 | ||
173 | return result; | 181 | return result; |
174 | } | 182 | } |
175 | 183 | ||
176 | 184 | ||
177 | static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, | 185 | static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, |
178 | struct file * filp) | 186 | struct file *filp) |
179 | { | 187 | { |
180 | dbg("%s - port %d", __func__, port->number); | 188 | dbg("%s - port %d", __func__, port->number); |
181 | 189 | ||
@@ -186,7 +194,8 @@ static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port, | |||
186 | } | 194 | } |
187 | 195 | ||
188 | 196 | ||
189 | static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) | 197 | static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, |
198 | const unsigned char *buf, int count) | ||
190 | { | 199 | { |
191 | struct usb_serial *serial = port->serial; | 200 | struct usb_serial *serial = port->serial; |
192 | struct urb *urb; | 201 | struct urb *urb; |
@@ -203,7 +212,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con | |||
203 | /* try to find a free urb in our list of them */ | 212 | /* try to find a free urb in our list of them */ |
204 | urb = NULL; | 213 | urb = NULL; |
205 | 214 | ||
206 | spin_lock_irqsave (&write_urb_pool_lock, flags); | 215 | spin_lock_irqsave(&write_urb_pool_lock, flags); |
207 | 216 | ||
208 | for (i = 0; i < NUM_URBS; ++i) { | 217 | for (i = 0; i < NUM_URBS; ++i) { |
209 | if (write_urb_pool[i]->status != -EINPROGRESS) { | 218 | if (write_urb_pool[i]->status != -EINPROGRESS) { |
@@ -212,7 +221,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con | |||
212 | } | 221 | } |
213 | } | 222 | } |
214 | 223 | ||
215 | spin_unlock_irqrestore (&write_urb_pool_lock, flags); | 224 | spin_unlock_irqrestore(&write_urb_pool_lock, flags); |
216 | 225 | ||
217 | if (urb == NULL) { | 226 | if (urb == NULL) { |
218 | dbg("%s - no more free urbs", __func__); | 227 | dbg("%s - no more free urbs", __func__); |
@@ -220,25 +229,27 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con | |||
220 | } | 229 | } |
221 | 230 | ||
222 | if (urb->transfer_buffer == NULL) { | 231 | if (urb->transfer_buffer == NULL) { |
223 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); | 232 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC); |
224 | if (urb->transfer_buffer == NULL) { | 233 | if (urb->transfer_buffer == NULL) { |
225 | dev_err(&port->dev, "%s no more kernel memory...\n", __func__); | 234 | dev_err(&port->dev, |
235 | "%s no more kernel memory...\n", | ||
236 | __func__); | ||
226 | goto exit; | 237 | goto exit; |
227 | } | 238 | } |
228 | } | 239 | } |
229 | 240 | ||
230 | transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); | 241 | transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); |
231 | 242 | ||
232 | memcpy (urb->transfer_buffer, current_position, transfer_size); | 243 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
233 | 244 | ||
234 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer); | 245 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer); |
235 | 246 | ||
236 | /* build up our urb */ | 247 | /* build up our urb */ |
237 | usb_fill_bulk_urb ( | 248 | usb_fill_bulk_urb( |
238 | urb, | 249 | urb, |
239 | serial->dev, | 250 | serial->dev, |
240 | usb_sndbulkpipe(serial->dev, | 251 | usb_sndbulkpipe(serial->dev, |
241 | port->bulk_out_endpointAddress), | 252 | port->bulk_out_endpointAddress), |
242 | urb->transfer_buffer, | 253 | urb->transfer_buffer, |
243 | transfer_size, | 254 | transfer_size, |
244 | empeg_write_bulk_callback, | 255 | empeg_write_bulk_callback, |
@@ -260,7 +271,7 @@ static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, con | |||
260 | } | 271 | } |
261 | exit: | 272 | exit: |
262 | return bytes_sent; | 273 | return bytes_sent; |
263 | } | 274 | } |
264 | 275 | ||
265 | 276 | ||
266 | static int empeg_write_room(struct tty_struct *tty) | 277 | static int empeg_write_room(struct tty_struct *tty) |
@@ -272,14 +283,13 @@ static int empeg_write_room(struct tty_struct *tty) | |||
272 | 283 | ||
273 | dbg("%s - port %d", __func__, port->number); | 284 | dbg("%s - port %d", __func__, port->number); |
274 | 285 | ||
275 | spin_lock_irqsave (&write_urb_pool_lock, flags); | 286 | spin_lock_irqsave(&write_urb_pool_lock, flags); |
276 | /* tally up the number of bytes available */ | 287 | /* tally up the number of bytes available */ |
277 | for (i = 0; i < NUM_URBS; ++i) { | 288 | for (i = 0; i < NUM_URBS; ++i) { |
278 | if (write_urb_pool[i]->status != -EINPROGRESS) { | 289 | if (write_urb_pool[i]->status != -EINPROGRESS) |
279 | room += URB_TRANSFER_BUFFER_SIZE; | 290 | room += URB_TRANSFER_BUFFER_SIZE; |
280 | } | 291 | } |
281 | } | 292 | spin_unlock_irqrestore(&write_urb_pool_lock, flags); |
282 | spin_unlock_irqrestore (&write_urb_pool_lock, flags); | ||
283 | dbg("%s - returns %d", __func__, room); | 293 | dbg("%s - returns %d", __func__, room); |
284 | return room; | 294 | return room; |
285 | 295 | ||
@@ -295,25 +305,21 @@ static int empeg_chars_in_buffer(struct tty_struct *tty) | |||
295 | 305 | ||
296 | dbg("%s - port %d", __func__, port->number); | 306 | dbg("%s - port %d", __func__, port->number); |
297 | 307 | ||
298 | spin_lock_irqsave (&write_urb_pool_lock, flags); | 308 | spin_lock_irqsave(&write_urb_pool_lock, flags); |
299 | 309 | ||
300 | /* tally up the number of bytes waiting */ | 310 | /* tally up the number of bytes waiting */ |
301 | for (i = 0; i < NUM_URBS; ++i) { | 311 | for (i = 0; i < NUM_URBS; ++i) { |
302 | if (write_urb_pool[i]->status == -EINPROGRESS) { | 312 | if (write_urb_pool[i]->status == -EINPROGRESS) |
303 | chars += URB_TRANSFER_BUFFER_SIZE; | 313 | chars += URB_TRANSFER_BUFFER_SIZE; |
304 | } | ||
305 | } | 314 | } |
306 | 315 | ||
307 | spin_unlock_irqrestore (&write_urb_pool_lock, flags); | 316 | spin_unlock_irqrestore(&write_urb_pool_lock, flags); |
308 | |||
309 | dbg("%s - returns %d", __func__, chars); | 317 | dbg("%s - returns %d", __func__, chars); |
310 | 318 | return chars; | |
311 | return (chars); | ||
312 | |||
313 | } | 319 | } |
314 | 320 | ||
315 | 321 | ||
316 | static void empeg_write_bulk_callback (struct urb *urb) | 322 | static void empeg_write_bulk_callback(struct urb *urb) |
317 | { | 323 | { |
318 | struct usb_serial_port *port = urb->context; | 324 | struct usb_serial_port *port = urb->context; |
319 | int status = urb->status; | 325 | int status = urb->status; |
@@ -330,7 +336,7 @@ static void empeg_write_bulk_callback (struct urb *urb) | |||
330 | } | 336 | } |
331 | 337 | ||
332 | 338 | ||
333 | static void empeg_read_bulk_callback (struct urb *urb) | 339 | static void empeg_read_bulk_callback(struct urb *urb) |
334 | { | 340 | { |
335 | struct usb_serial_port *port = urb->context; | 341 | struct usb_serial_port *port = urb->context; |
336 | struct tty_struct *tty; | 342 | struct tty_struct *tty; |
@@ -346,8 +352,8 @@ static void empeg_read_bulk_callback (struct urb *urb) | |||
346 | return; | 352 | return; |
347 | } | 353 | } |
348 | 354 | ||
349 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); | 355 | usb_serial_debug_data(debug, &port->dev, __func__, |
350 | 356 | urb->actual_length, data); | |
351 | tty = port->port.tty; | 357 | tty = port->port.tty; |
352 | 358 | ||
353 | if (urb->actual_length) { | 359 | if (urb->actual_length) { |
@@ -360,7 +366,7 @@ static void empeg_read_bulk_callback (struct urb *urb) | |||
360 | /* Continue trying to always read */ | 366 | /* Continue trying to always read */ |
361 | usb_fill_bulk_urb( | 367 | usb_fill_bulk_urb( |
362 | port->read_urb, | 368 | port->read_urb, |
363 | port->serial->dev, | 369 | port->serial->dev, |
364 | usb_rcvbulkpipe(port->serial->dev, | 370 | usb_rcvbulkpipe(port->serial->dev, |
365 | port->bulk_in_endpointAddress), | 371 | port->bulk_in_endpointAddress), |
366 | port->read_urb->transfer_buffer, | 372 | port->read_urb->transfer_buffer, |
@@ -371,7 +377,9 @@ static void empeg_read_bulk_callback (struct urb *urb) | |||
371 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 377 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
372 | 378 | ||
373 | if (result) | 379 | if (result) |
374 | dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); | 380 | dev_err(&urb->dev->dev, |
381 | "%s - failed resubmitting read urb, error %d\n", | ||
382 | __func__, result); | ||
375 | 383 | ||
376 | return; | 384 | return; |
377 | 385 | ||
@@ -395,11 +403,13 @@ static void empeg_unthrottle(struct tty_struct *tty) | |||
395 | port->read_urb->dev = port->serial->dev; | 403 | port->read_urb->dev = port->serial->dev; |
396 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 404 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
397 | if (result) | 405 | if (result) |
398 | dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); | 406 | dev_err(&port->dev, |
407 | "%s - failed submitting read urb, error %d\n", | ||
408 | __func__, result); | ||
399 | } | 409 | } |
400 | 410 | ||
401 | 411 | ||
402 | static int empeg_startup (struct usb_serial *serial) | 412 | static int empeg_startup(struct usb_serial *serial) |
403 | { | 413 | { |
404 | int r; | 414 | int r; |
405 | 415 | ||
@@ -411,7 +421,7 @@ static int empeg_startup (struct usb_serial *serial) | |||
411 | return -ENODEV; | 421 | return -ENODEV; |
412 | } | 422 | } |
413 | dbg("%s - reset config", __func__); | 423 | dbg("%s - reset config", __func__); |
414 | r = usb_reset_configuration (serial->dev); | 424 | r = usb_reset_configuration(serial->dev); |
415 | 425 | ||
416 | /* continue on with initialization */ | 426 | /* continue on with initialization */ |
417 | return r; | 427 | return r; |
@@ -419,9 +429,9 @@ static int empeg_startup (struct usb_serial *serial) | |||
419 | } | 429 | } |
420 | 430 | ||
421 | 431 | ||
422 | static void empeg_shutdown (struct usb_serial *serial) | 432 | static void empeg_shutdown(struct usb_serial *serial) |
423 | { | 433 | { |
424 | dbg ("%s", __func__); | 434 | dbg("%s", __func__); |
425 | } | 435 | } |
426 | 436 | ||
427 | 437 | ||
@@ -432,14 +442,14 @@ static void empeg_set_termios(struct tty_struct *tty, | |||
432 | dbg("%s - port %d", __func__, port->number); | 442 | dbg("%s - port %d", __func__, port->number); |
433 | 443 | ||
434 | /* | 444 | /* |
435 | * The empeg-car player wants these particular tty settings. | 445 | * The empeg-car player wants these particular tty settings. |
436 | * You could, for example, change the baud rate, however the | 446 | * You could, for example, change the baud rate, however the |
437 | * player only supports 115200 (currently), so there is really | 447 | * player only supports 115200 (currently), so there is really |
438 | * no point in support for changes to the tty settings. | 448 | * no point in support for changes to the tty settings. |
439 | * (at least for now) | 449 | * (at least for now) |
440 | * | 450 | * |
441 | * The default requirements for this device are: | 451 | * The default requirements for this device are: |
442 | */ | 452 | */ |
443 | termios->c_iflag | 453 | termios->c_iflag |
444 | &= ~(IGNBRK /* disable ignore break */ | 454 | &= ~(IGNBRK /* disable ignore break */ |
445 | | BRKINT /* disable break causes interrupt */ | 455 | | BRKINT /* disable break causes interrupt */ |
@@ -478,13 +488,13 @@ static void empeg_set_termios(struct tty_struct *tty, | |||
478 | } | 488 | } |
479 | 489 | ||
480 | 490 | ||
481 | static int __init empeg_init (void) | 491 | static int __init empeg_init(void) |
482 | { | 492 | { |
483 | struct urb *urb; | 493 | struct urb *urb; |
484 | int i, retval; | 494 | int i, retval; |
485 | 495 | ||
486 | /* create our write urb pool and transfer buffers */ | 496 | /* create our write urb pool and transfer buffers */ |
487 | spin_lock_init (&write_urb_pool_lock); | 497 | spin_lock_init(&write_urb_pool_lock); |
488 | for (i = 0; i < NUM_URBS; ++i) { | 498 | for (i = 0; i < NUM_URBS; ++i) { |
489 | urb = usb_alloc_urb(0, GFP_KERNEL); | 499 | urb = usb_alloc_urb(0, GFP_KERNEL); |
490 | write_urb_pool[i] = urb; | 500 | write_urb_pool[i] = urb; |
@@ -493,9 +503,10 @@ static int __init empeg_init (void) | |||
493 | continue; | 503 | continue; |
494 | } | 504 | } |
495 | 505 | ||
496 | urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 506 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
507 | GFP_KERNEL); | ||
497 | if (!urb->transfer_buffer) { | 508 | if (!urb->transfer_buffer) { |
498 | err("%s - out of memory for urb buffers.", | 509 | err("%s - out of memory for urb buffers.", |
499 | __func__); | 510 | __func__); |
500 | continue; | 511 | continue; |
501 | } | 512 | } |
@@ -524,36 +535,36 @@ failed_usb_serial_register: | |||
524 | } | 535 | } |
525 | 536 | ||
526 | 537 | ||
527 | static void __exit empeg_exit (void) | 538 | static void __exit empeg_exit(void) |
528 | { | 539 | { |
529 | int i; | 540 | int i; |
530 | unsigned long flags; | 541 | unsigned long flags; |
531 | 542 | ||
532 | usb_deregister(&empeg_driver); | 543 | usb_deregister(&empeg_driver); |
533 | usb_serial_deregister (&empeg_device); | 544 | usb_serial_deregister(&empeg_device); |
534 | 545 | ||
535 | spin_lock_irqsave (&write_urb_pool_lock, flags); | 546 | spin_lock_irqsave(&write_urb_pool_lock, flags); |
536 | 547 | ||
537 | for (i = 0; i < NUM_URBS; ++i) { | 548 | for (i = 0; i < NUM_URBS; ++i) { |
538 | if (write_urb_pool[i]) { | 549 | if (write_urb_pool[i]) { |
539 | /* FIXME - uncomment the following usb_kill_urb call when | 550 | /* FIXME - uncomment the following usb_kill_urb call |
540 | * the host controllers get fixed to set urb->dev = NULL after | 551 | * when the host controllers get fixed to set urb->dev |
541 | * the urb is finished. Otherwise this call oopses. */ | 552 | * = NULL after the urb is finished. Otherwise this |
553 | * call oopses. */ | ||
542 | /* usb_kill_urb(write_urb_pool[i]); */ | 554 | /* usb_kill_urb(write_urb_pool[i]); */ |
543 | kfree(write_urb_pool[i]->transfer_buffer); | 555 | kfree(write_urb_pool[i]->transfer_buffer); |
544 | usb_free_urb (write_urb_pool[i]); | 556 | usb_free_urb(write_urb_pool[i]); |
545 | } | 557 | } |
546 | } | 558 | } |
547 | 559 | spin_unlock_irqrestore(&write_urb_pool_lock, flags); | |
548 | spin_unlock_irqrestore (&write_urb_pool_lock, flags); | ||
549 | } | 560 | } |
550 | 561 | ||
551 | 562 | ||
552 | module_init(empeg_init); | 563 | module_init(empeg_init); |
553 | module_exit(empeg_exit); | 564 | module_exit(empeg_exit); |
554 | 565 | ||
555 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 566 | MODULE_AUTHOR(DRIVER_AUTHOR); |
556 | MODULE_DESCRIPTION( DRIVER_DESC ); | 567 | MODULE_DESCRIPTION(DRIVER_DESC); |
557 | MODULE_LICENSE("GPL"); | 568 | MODULE_LICENSE("GPL"); |
558 | 569 | ||
559 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 570 | module_param(debug, bool, S_IRUGO | S_IWUSR); |