diff options
Diffstat (limited to 'drivers/usb/serial/kobil_sct.c')
-rw-r--r-- | drivers/usb/serial/kobil_sct.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 17b3baead4ad..693f00da7c03 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -113,10 +113,6 @@ static struct usb_serial_driver kobil_device = { | |||
113 | .description = "KOBIL USB smart card terminal", | 113 | .description = "KOBIL USB smart card terminal", |
114 | .usb_driver = &kobil_driver, | 114 | .usb_driver = &kobil_driver, |
115 | .id_table = id_table, | 115 | .id_table = id_table, |
116 | .num_interrupt_in = NUM_DONT_CARE, | ||
117 | .num_interrupt_out = NUM_DONT_CARE, | ||
118 | .num_bulk_in = 0, | ||
119 | .num_bulk_out = 0, | ||
120 | .num_ports = 1, | 116 | .num_ports = 1, |
121 | .attach = kobil_startup, | 117 | .attach = kobil_startup, |
122 | .shutdown = kobil_shutdown, | 118 | .shutdown = kobil_shutdown, |
@@ -139,7 +135,6 @@ struct kobil_private { | |||
139 | int filled; // index of the last char in buf | 135 | int filled; // index of the last char in buf |
140 | int cur_pos; // index of the next char to send in buf | 136 | int cur_pos; // index of the next char to send in buf |
141 | __u16 device_type; | 137 | __u16 device_type; |
142 | int line_state; | ||
143 | }; | 138 | }; |
144 | 139 | ||
145 | 140 | ||
@@ -161,7 +156,6 @@ static int kobil_startup (struct usb_serial *serial) | |||
161 | priv->filled = 0; | 156 | priv->filled = 0; |
162 | priv->cur_pos = 0; | 157 | priv->cur_pos = 0; |
163 | priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); | 158 | priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); |
164 | priv->line_state = 0; | ||
165 | 159 | ||
166 | switch (priv->device_type){ | 160 | switch (priv->device_type){ |
167 | case KOBIL_ADAPTER_B_PRODUCT_ID: | 161 | case KOBIL_ADAPTER_B_PRODUCT_ID: |
@@ -189,11 +183,11 @@ static int kobil_startup (struct usb_serial *serial) | |||
189 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { | 183 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { |
190 | endpoint = &altsetting->endpoint[i]; | 184 | endpoint = &altsetting->endpoint[i]; |
191 | if (usb_endpoint_is_int_out(&endpoint->desc)) { | 185 | if (usb_endpoint_is_int_out(&endpoint->desc)) { |
192 | dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); | 186 | dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); |
193 | priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; | 187 | priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; |
194 | } | 188 | } |
195 | if (usb_endpoint_is_int_in(&endpoint->desc)) { | 189 | if (usb_endpoint_is_int_in(&endpoint->desc)) { |
196 | dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); | 190 | dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); |
197 | priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; | 191 | priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; |
198 | } | 192 | } |
199 | } | 193 | } |
@@ -204,7 +198,7 @@ static int kobil_startup (struct usb_serial *serial) | |||
204 | static void kobil_shutdown (struct usb_serial *serial) | 198 | static void kobil_shutdown (struct usb_serial *serial) |
205 | { | 199 | { |
206 | int i; | 200 | int i; |
207 | dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); | 201 | dbg("%s - port %d", __func__, serial->port[0]->number); |
208 | 202 | ||
209 | for (i=0; i < serial->num_ports; ++i) { | 203 | for (i=0; i < serial->num_ports; ++i) { |
210 | while (serial->port[i]->open_count > 0) { | 204 | while (serial->port[i]->open_count > 0) { |
@@ -224,9 +218,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
224 | int transfer_buffer_length = 8; | 218 | int transfer_buffer_length = 8; |
225 | int write_urb_transfer_buffer_length = 8; | 219 | int write_urb_transfer_buffer_length = 8; |
226 | 220 | ||
227 | dbg("%s - port %d", __FUNCTION__, port->number); | 221 | dbg("%s - port %d", __func__, port->number); |
228 | priv = usb_get_serial_port_data(port); | 222 | priv = usb_get_serial_port_data(port); |
229 | priv->line_state = 0; | ||
230 | 223 | ||
231 | // someone sets the dev to 0 if the close method has been called | 224 | // someone sets the dev to 0 if the close method has been called |
232 | port->interrupt_in_urb->dev = port->serial->dev; | 225 | port->interrupt_in_urb->dev = port->serial->dev; |
@@ -252,10 +245,10 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
252 | 245 | ||
253 | // allocate write_urb | 246 | // allocate write_urb |
254 | if (!port->write_urb) { | 247 | if (!port->write_urb) { |
255 | dbg("%s - port %d Allocating port->write_urb", __FUNCTION__, port->number); | 248 | dbg("%s - port %d Allocating port->write_urb", __func__, port->number); |
256 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); | 249 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); |
257 | if (!port->write_urb) { | 250 | if (!port->write_urb) { |
258 | dbg("%s - port %d usb_alloc_urb failed", __FUNCTION__, port->number); | 251 | dbg("%s - port %d usb_alloc_urb failed", __func__, port->number); |
259 | kfree(transfer_buffer); | 252 | kfree(transfer_buffer); |
260 | return -ENOMEM; | 253 | return -ENOMEM; |
261 | } | 254 | } |
@@ -281,7 +274,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
281 | transfer_buffer_length, | 274 | transfer_buffer_length, |
282 | KOBIL_TIMEOUT | 275 | KOBIL_TIMEOUT |
283 | ); | 276 | ); |
284 | dbg("%s - port %d Send get_HW_version URB returns: %i", __FUNCTION__, port->number, result); | 277 | dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result); |
285 | dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); | 278 | dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); |
286 | 279 | ||
287 | // get firmware version | 280 | // get firmware version |
@@ -295,7 +288,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
295 | transfer_buffer_length, | 288 | transfer_buffer_length, |
296 | KOBIL_TIMEOUT | 289 | KOBIL_TIMEOUT |
297 | ); | 290 | ); |
298 | dbg("%s - port %d Send get_FW_version URB returns: %i", __FUNCTION__, port->number, result); | 291 | dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result); |
299 | dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); | 292 | dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); |
300 | 293 | ||
301 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | 294 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { |
@@ -310,7 +303,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
310 | 0, | 303 | 0, |
311 | KOBIL_TIMEOUT | 304 | KOBIL_TIMEOUT |
312 | ); | 305 | ); |
313 | dbg("%s - port %d Send set_baudrate URB returns: %i", __FUNCTION__, port->number, result); | 306 | dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result); |
314 | 307 | ||
315 | // reset all queues | 308 | // reset all queues |
316 | result = usb_control_msg( port->serial->dev, | 309 | result = usb_control_msg( port->serial->dev, |
@@ -323,13 +316,13 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
323 | 0, | 316 | 0, |
324 | KOBIL_TIMEOUT | 317 | KOBIL_TIMEOUT |
325 | ); | 318 | ); |
326 | dbg("%s - port %d Send reset_all_queues URB returns: %i", __FUNCTION__, port->number, result); | 319 | dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result); |
327 | } | 320 | } |
328 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | 321 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || |
329 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { | 322 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { |
330 | // start reading (Adapter B 'cause PNP string) | 323 | // start reading (Adapter B 'cause PNP string) |
331 | result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); | 324 | result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); |
332 | dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); | 325 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); |
333 | } | 326 | } |
334 | 327 | ||
335 | kfree(transfer_buffer); | 328 | kfree(transfer_buffer); |
@@ -339,7 +332,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
339 | 332 | ||
340 | static void kobil_close (struct usb_serial_port *port, struct file *filp) | 333 | static void kobil_close (struct usb_serial_port *port, struct file *filp) |
341 | { | 334 | { |
342 | dbg("%s - port %d", __FUNCTION__, port->number); | 335 | dbg("%s - port %d", __func__, port->number); |
343 | 336 | ||
344 | if (port->write_urb) { | 337 | if (port->write_urb) { |
345 | usb_kill_urb(port->write_urb); | 338 | usb_kill_urb(port->write_urb); |
@@ -359,11 +352,11 @@ static void kobil_read_int_callback(struct urb *urb) | |||
359 | int status = urb->status; | 352 | int status = urb->status; |
360 | // char *dbg_data; | 353 | // char *dbg_data; |
361 | 354 | ||
362 | dbg("%s - port %d", __FUNCTION__, port->number); | 355 | dbg("%s - port %d", __func__, port->number); |
363 | 356 | ||
364 | if (status) { | 357 | if (status) { |
365 | dbg("%s - port %d Read int status not zero: %d", | 358 | dbg("%s - port %d Read int status not zero: %d", |
366 | __FUNCTION__, port->number, status); | 359 | __func__, port->number, status); |
367 | return; | 360 | return; |
368 | } | 361 | } |
369 | 362 | ||
@@ -393,7 +386,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
393 | port->interrupt_in_urb->dev = port->serial->dev; | 386 | port->interrupt_in_urb->dev = port->serial->dev; |
394 | 387 | ||
395 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 388 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
396 | dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); | 389 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); |
397 | } | 390 | } |
398 | 391 | ||
399 | 392 | ||
@@ -411,21 +404,21 @@ static int kobil_write (struct usb_serial_port *port, | |||
411 | struct kobil_private * priv; | 404 | struct kobil_private * priv; |
412 | 405 | ||
413 | if (count == 0) { | 406 | if (count == 0) { |
414 | dbg("%s - port %d write request of 0 bytes", __FUNCTION__, port->number); | 407 | dbg("%s - port %d write request of 0 bytes", __func__, port->number); |
415 | return 0; | 408 | return 0; |
416 | } | 409 | } |
417 | 410 | ||
418 | priv = usb_get_serial_port_data(port); | 411 | priv = usb_get_serial_port_data(port); |
419 | 412 | ||
420 | if (count > (KOBIL_BUF_LENGTH - priv->filled)) { | 413 | if (count > (KOBIL_BUF_LENGTH - priv->filled)) { |
421 | dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); | 414 | dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number); |
422 | return -ENOMEM; | 415 | return -ENOMEM; |
423 | } | 416 | } |
424 | 417 | ||
425 | // Copy data to buffer | 418 | // Copy data to buffer |
426 | memcpy (priv->buf + priv->filled, buf, count); | 419 | memcpy (priv->buf + priv->filled, buf, count); |
427 | 420 | ||
428 | usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, priv->buf + priv->filled); | 421 | usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); |
429 | 422 | ||
430 | priv->filled = priv->filled + count; | 423 | priv->filled = priv->filled + count; |
431 | 424 | ||
@@ -457,7 +450,7 @@ static int kobil_write (struct usb_serial_port *port, | |||
457 | 450 | ||
458 | priv->cur_pos = priv->cur_pos + length; | 451 | priv->cur_pos = priv->cur_pos + length; |
459 | result = usb_submit_urb( port->write_urb, GFP_NOIO ); | 452 | result = usb_submit_urb( port->write_urb, GFP_NOIO ); |
460 | dbg("%s - port %d Send write URB returns: %i", __FUNCTION__, port->number, result); | 453 | dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result); |
461 | todo = priv->filled - priv->cur_pos; | 454 | todo = priv->filled - priv->cur_pos; |
462 | 455 | ||
463 | if (todo > 0) { | 456 | if (todo > 0) { |
@@ -478,7 +471,7 @@ static int kobil_write (struct usb_serial_port *port, | |||
478 | port->interrupt_in_urb->dev = port->serial->dev; | 471 | port->interrupt_in_urb->dev = port->serial->dev; |
479 | 472 | ||
480 | result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); | 473 | result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); |
481 | dbg("%s - port %d Send read URB returns: %i", __FUNCTION__, port->number, result); | 474 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); |
482 | } | 475 | } |
483 | } | 476 | } |
484 | return count; | 477 | return count; |
@@ -487,7 +480,7 @@ static int kobil_write (struct usb_serial_port *port, | |||
487 | 480 | ||
488 | static int kobil_write_room (struct usb_serial_port *port) | 481 | static int kobil_write_room (struct usb_serial_port *port) |
489 | { | 482 | { |
490 | //dbg("%s - port %d", __FUNCTION__, port->number); | 483 | //dbg("%s - port %d", __func__, port->number); |
491 | return 8; | 484 | return 8; |
492 | } | 485 | } |
493 | 486 | ||
@@ -522,16 +515,13 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) | |||
522 | KOBIL_TIMEOUT); | 515 | KOBIL_TIMEOUT); |
523 | 516 | ||
524 | dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", | 517 | dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", |
525 | __FUNCTION__, port->number, result, transfer_buffer[0]); | 518 | __func__, port->number, result, transfer_buffer[0]); |
526 | |||
527 | if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) { | ||
528 | priv->line_state |= TIOCM_DSR; | ||
529 | } else { | ||
530 | priv->line_state &= ~TIOCM_DSR; | ||
531 | } | ||
532 | 519 | ||
520 | result = 0; | ||
521 | if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) | ||
522 | result = TIOCM_DSR; | ||
533 | kfree(transfer_buffer); | 523 | kfree(transfer_buffer); |
534 | return priv->line_state; | 524 | return result; |
535 | } | 525 | } |
536 | 526 | ||
537 | static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | 527 | static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, |
@@ -544,6 +534,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
544 | unsigned char *transfer_buffer; | 534 | unsigned char *transfer_buffer; |
545 | int transfer_buffer_length = 8; | 535 | int transfer_buffer_length = 8; |
546 | 536 | ||
537 | /* FIXME: locking ? */ | ||
547 | priv = usb_get_serial_port_data(port); | 538 | priv = usb_get_serial_port_data(port); |
548 | if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { | 539 | if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { |
549 | // This device doesn't support ioctl calls | 540 | // This device doesn't support ioctl calls |
@@ -567,9 +558,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
567 | 558 | ||
568 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { | 559 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { |
569 | if (dtr != 0) | 560 | if (dtr != 0) |
570 | dbg("%s - port %d Setting DTR", __FUNCTION__, port->number); | 561 | dbg("%s - port %d Setting DTR", __func__, port->number); |
571 | else | 562 | else |
572 | dbg("%s - port %d Clearing DTR", __FUNCTION__, port->number); | 563 | dbg("%s - port %d Clearing DTR", __func__, port->number); |
573 | result = usb_control_msg( port->serial->dev, | 564 | result = usb_control_msg( port->serial->dev, |
574 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 565 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
575 | SUSBCRequest_SetStatusLinesOrQueues, | 566 | SUSBCRequest_SetStatusLinesOrQueues, |
@@ -581,9 +572,9 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
581 | KOBIL_TIMEOUT); | 572 | KOBIL_TIMEOUT); |
582 | } else { | 573 | } else { |
583 | if (rts != 0) | 574 | if (rts != 0) |
584 | dbg("%s - port %d Setting RTS", __FUNCTION__, port->number); | 575 | dbg("%s - port %d Setting RTS", __func__, port->number); |
585 | else | 576 | else |
586 | dbg("%s - port %d Clearing RTS", __FUNCTION__, port->number); | 577 | dbg("%s - port %d Clearing RTS", __func__, port->number); |
587 | result = usb_control_msg( port->serial->dev, | 578 | result = usb_control_msg( port->serial->dev, |
588 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 579 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
589 | SUSBCRequest_SetStatusLinesOrQueues, | 580 | SUSBCRequest_SetStatusLinesOrQueues, |
@@ -594,7 +585,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
594 | 0, | 585 | 0, |
595 | KOBIL_TIMEOUT); | 586 | KOBIL_TIMEOUT); |
596 | } | 587 | } |
597 | dbg("%s - port %d Send set_status_line URB returns: %i", __FUNCTION__, port->number, result); | 588 | dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result); |
598 | kfree(transfer_buffer); | 589 | kfree(transfer_buffer); |
599 | return (result < 0) ? result : 0; | 590 | return (result < 0) ? result : 0; |
600 | } | 591 | } |
@@ -687,7 +678,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne | |||
687 | KOBIL_TIMEOUT | 678 | KOBIL_TIMEOUT |
688 | ); | 679 | ); |
689 | 680 | ||
690 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); | 681 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); |
691 | kfree(transfer_buffer); | 682 | kfree(transfer_buffer); |
692 | return (result < 0) ? -EFAULT : 0; | 683 | return (result < 0) ? -EFAULT : 0; |
693 | default: | 684 | default: |