diff options
Diffstat (limited to 'drivers/usb/serial/generic.c')
-rw-r--r-- | drivers/usb/serial/generic.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 7cfce9dabb90..537f12a027c2 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -62,9 +62,6 @@ struct usb_serial_driver usb_serial_generic_device = { | |||
62 | }, | 62 | }, |
63 | .id_table = generic_device_ids, | 63 | .id_table = generic_device_ids, |
64 | .usb_driver = &generic_driver, | 64 | .usb_driver = &generic_driver, |
65 | .num_interrupt_in = NUM_DONT_CARE, | ||
66 | .num_bulk_in = NUM_DONT_CARE, | ||
67 | .num_bulk_out = NUM_DONT_CARE, | ||
68 | .num_ports = 1, | 65 | .num_ports = 1, |
69 | .shutdown = usb_serial_generic_shutdown, | 66 | .shutdown = usb_serial_generic_shutdown, |
70 | .throttle = usb_serial_generic_throttle, | 67 | .throttle = usb_serial_generic_throttle, |
@@ -121,7 +118,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) | |||
121 | int result = 0; | 118 | int result = 0; |
122 | unsigned long flags; | 119 | unsigned long flags; |
123 | 120 | ||
124 | dbg("%s - port %d", __FUNCTION__, port->number); | 121 | dbg("%s - port %d", __func__, port->number); |
125 | 122 | ||
126 | /* force low_latency on so that our tty_push actually forces the data through, | 123 | /* force low_latency on so that our tty_push actually forces the data through, |
127 | otherwise it is scheduled, and with high data rates (like with OHCI) data | 124 | otherwise it is scheduled, and with high data rates (like with OHCI) data |
@@ -148,7 +145,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) | |||
148 | port); | 145 | port); |
149 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 146 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
150 | if (result) | 147 | if (result) |
151 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); | 148 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); |
152 | } | 149 | } |
153 | 150 | ||
154 | return result; | 151 | return result; |
@@ -159,7 +156,7 @@ static void generic_cleanup (struct usb_serial_port *port) | |||
159 | { | 156 | { |
160 | struct usb_serial *serial = port->serial; | 157 | struct usb_serial *serial = port->serial; |
161 | 158 | ||
162 | dbg("%s - port %d", __FUNCTION__, port->number); | 159 | dbg("%s - port %d", __func__, port->number); |
163 | 160 | ||
164 | if (serial->dev) { | 161 | if (serial->dev) { |
165 | /* shutdown any bulk reads that might be going on */ | 162 | /* shutdown any bulk reads that might be going on */ |
@@ -197,7 +194,7 @@ int usb_serial_generic_resume(struct usb_serial *serial) | |||
197 | 194 | ||
198 | void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) | 195 | void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) |
199 | { | 196 | { |
200 | dbg("%s - port %d", __FUNCTION__, port->number); | 197 | dbg("%s - port %d", __func__, port->number); |
201 | generic_cleanup (port); | 198 | generic_cleanup (port); |
202 | } | 199 | } |
203 | 200 | ||
@@ -207,10 +204,10 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
207 | int result; | 204 | int result; |
208 | unsigned char *data; | 205 | unsigned char *data; |
209 | 206 | ||
210 | dbg("%s - port %d", __FUNCTION__, port->number); | 207 | dbg("%s - port %d", __func__, port->number); |
211 | 208 | ||
212 | if (count == 0) { | 209 | if (count == 0) { |
213 | dbg("%s - write request of 0 bytes", __FUNCTION__); | 210 | dbg("%s - write request of 0 bytes", __func__); |
214 | return (0); | 211 | return (0); |
215 | } | 212 | } |
216 | 213 | ||
@@ -220,7 +217,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
220 | spin_lock_irqsave(&port->lock, flags); | 217 | spin_lock_irqsave(&port->lock, flags); |
221 | if (port->write_urb_busy) { | 218 | if (port->write_urb_busy) { |
222 | spin_unlock_irqrestore(&port->lock, flags); | 219 | spin_unlock_irqrestore(&port->lock, flags); |
223 | dbg("%s - already writing", __FUNCTION__); | 220 | dbg("%s - already writing", __func__); |
224 | return 0; | 221 | return 0; |
225 | } | 222 | } |
226 | port->write_urb_busy = 1; | 223 | port->write_urb_busy = 1; |
@@ -230,7 +227,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
230 | 227 | ||
231 | memcpy (port->write_urb->transfer_buffer, buf, count); | 228 | memcpy (port->write_urb->transfer_buffer, buf, count); |
232 | data = port->write_urb->transfer_buffer; | 229 | data = port->write_urb->transfer_buffer; |
233 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, data); | 230 | usb_serial_debug_data(debug, &port->dev, __func__, count, data); |
234 | 231 | ||
235 | /* set up our urb */ | 232 | /* set up our urb */ |
236 | usb_fill_bulk_urb (port->write_urb, serial->dev, | 233 | usb_fill_bulk_urb (port->write_urb, serial->dev, |
@@ -245,7 +242,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * | |||
245 | port->write_urb_busy = 1; | 242 | port->write_urb_busy = 1; |
246 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 243 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
247 | if (result) { | 244 | if (result) { |
248 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); | 245 | dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result); |
249 | /* don't have to grab the lock here, as we will retry if != 0 */ | 246 | /* don't have to grab the lock here, as we will retry if != 0 */ |
250 | port->write_urb_busy = 0; | 247 | port->write_urb_busy = 0; |
251 | } else | 248 | } else |
@@ -263,15 +260,16 @@ int usb_serial_generic_write_room (struct usb_serial_port *port) | |||
263 | struct usb_serial *serial = port->serial; | 260 | struct usb_serial *serial = port->serial; |
264 | int room = 0; | 261 | int room = 0; |
265 | 262 | ||
266 | dbg("%s - port %d", __FUNCTION__, port->number); | 263 | dbg("%s - port %d", __func__, port->number); |
267 | 264 | ||
265 | /* FIXME: Locking */ | ||
268 | if (serial->num_bulk_out) { | 266 | if (serial->num_bulk_out) { |
269 | if (!(port->write_urb_busy)) | 267 | if (!(port->write_urb_busy)) |
270 | room = port->bulk_out_size; | 268 | room = port->bulk_out_size; |
271 | } | 269 | } |
272 | 270 | ||
273 | dbg("%s - returns %d", __FUNCTION__, room); | 271 | dbg("%s - returns %d", __func__, room); |
274 | return (room); | 272 | return room; |
275 | } | 273 | } |
276 | 274 | ||
277 | int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) | 275 | int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) |
@@ -279,14 +277,15 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) | |||
279 | struct usb_serial *serial = port->serial; | 277 | struct usb_serial *serial = port->serial; |
280 | int chars = 0; | 278 | int chars = 0; |
281 | 279 | ||
282 | dbg("%s - port %d", __FUNCTION__, port->number); | 280 | dbg("%s - port %d", __func__, port->number); |
283 | 281 | ||
282 | /* FIXME: Locking */ | ||
284 | if (serial->num_bulk_out) { | 283 | if (serial->num_bulk_out) { |
285 | if (port->write_urb_busy) | 284 | if (port->write_urb_busy) |
286 | chars = port->write_urb->transfer_buffer_length; | 285 | chars = port->write_urb->transfer_buffer_length; |
287 | } | 286 | } |
288 | 287 | ||
289 | dbg("%s - returns %d", __FUNCTION__, chars); | 288 | dbg("%s - returns %d", __func__, chars); |
290 | return (chars); | 289 | return (chars); |
291 | } | 290 | } |
292 | 291 | ||
@@ -308,7 +307,7 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) | |||
308 | usb_serial_generic_read_bulk_callback), port); | 307 | usb_serial_generic_read_bulk_callback), port); |
309 | result = usb_submit_urb(urb, mem_flags); | 308 | result = usb_submit_urb(urb, mem_flags); |
310 | if (result) | 309 | if (result) |
311 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); | 310 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); |
312 | } | 311 | } |
313 | 312 | ||
314 | /* Push data to tty layer and resubmit the bulk read URB */ | 313 | /* Push data to tty layer and resubmit the bulk read URB */ |
@@ -332,20 +331,20 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port) | |||
332 | 331 | ||
333 | void usb_serial_generic_read_bulk_callback (struct urb *urb) | 332 | void usb_serial_generic_read_bulk_callback (struct urb *urb) |
334 | { | 333 | { |
335 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 334 | struct usb_serial_port *port = urb->context; |
336 | unsigned char *data = urb->transfer_buffer; | 335 | unsigned char *data = urb->transfer_buffer; |
337 | int status = urb->status; | 336 | int status = urb->status; |
338 | unsigned long flags; | 337 | unsigned long flags; |
339 | 338 | ||
340 | dbg("%s - port %d", __FUNCTION__, port->number); | 339 | dbg("%s - port %d", __func__, port->number); |
341 | 340 | ||
342 | if (unlikely(status != 0)) { | 341 | if (unlikely(status != 0)) { |
343 | dbg("%s - nonzero read bulk status received: %d", | 342 | dbg("%s - nonzero read bulk status received: %d", |
344 | __FUNCTION__, status); | 343 | __func__, status); |
345 | return; | 344 | return; |
346 | } | 345 | } |
347 | 346 | ||
348 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); | 347 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); |
349 | 348 | ||
350 | /* Throttle the device if requested by tty */ | 349 | /* Throttle the device if requested by tty */ |
351 | spin_lock_irqsave(&port->lock, flags); | 350 | spin_lock_irqsave(&port->lock, flags); |
@@ -360,18 +359,17 @@ EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); | |||
360 | 359 | ||
361 | void usb_serial_generic_write_bulk_callback (struct urb *urb) | 360 | void usb_serial_generic_write_bulk_callback (struct urb *urb) |
362 | { | 361 | { |
363 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 362 | struct usb_serial_port *port = urb->context; |
364 | int status = urb->status; | 363 | int status = urb->status; |
365 | 364 | ||
366 | dbg("%s - port %d", __FUNCTION__, port->number); | 365 | dbg("%s - port %d", __func__, port->number); |
367 | 366 | ||
368 | port->write_urb_busy = 0; | 367 | port->write_urb_busy = 0; |
369 | if (status) { | 368 | if (status) { |
370 | dbg("%s - nonzero write bulk status received: %d", | 369 | dbg("%s - nonzero write bulk status received: %d", |
371 | __FUNCTION__, status); | 370 | __func__, status); |
372 | return; | 371 | return; |
373 | } | 372 | } |
374 | |||
375 | usb_serial_port_softint(port); | 373 | usb_serial_port_softint(port); |
376 | } | 374 | } |
377 | EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); | 375 | EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); |
@@ -380,7 +378,7 @@ void usb_serial_generic_throttle (struct usb_serial_port *port) | |||
380 | { | 378 | { |
381 | unsigned long flags; | 379 | unsigned long flags; |
382 | 380 | ||
383 | dbg("%s - port %d", __FUNCTION__, port->number); | 381 | dbg("%s - port %d", __func__, port->number); |
384 | 382 | ||
385 | /* Set the throttle request flag. It will be picked up | 383 | /* Set the throttle request flag. It will be picked up |
386 | * by usb_serial_generic_read_bulk_callback(). */ | 384 | * by usb_serial_generic_read_bulk_callback(). */ |
@@ -394,7 +392,7 @@ void usb_serial_generic_unthrottle (struct usb_serial_port *port) | |||
394 | int was_throttled; | 392 | int was_throttled; |
395 | unsigned long flags; | 393 | unsigned long flags; |
396 | 394 | ||
397 | dbg("%s - port %d", __FUNCTION__, port->number); | 395 | dbg("%s - port %d", __func__, port->number); |
398 | 396 | ||
399 | /* Clear the throttle flags */ | 397 | /* Clear the throttle flags */ |
400 | spin_lock_irqsave(&port->lock, flags); | 398 | spin_lock_irqsave(&port->lock, flags); |
@@ -412,7 +410,7 @@ void usb_serial_generic_shutdown (struct usb_serial *serial) | |||
412 | { | 410 | { |
413 | int i; | 411 | int i; |
414 | 412 | ||
415 | dbg("%s", __FUNCTION__); | 413 | dbg("%s", __func__); |
416 | 414 | ||
417 | /* stop reads and writes on all ports */ | 415 | /* stop reads and writes on all ports */ |
418 | for (i=0; i < serial->num_ports; ++i) { | 416 | for (i=0; i < serial->num_ports; ++i) { |