aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/whiteheat.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/whiteheat.c')
-rw-r--r--drivers/usb/serial/whiteheat.c121
1 files changed, 72 insertions, 49 deletions
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 11c8b97a5177..5335d3211c07 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -303,12 +303,15 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
303 303
304 if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", 304 if (request_ihex_firmware(&firmware_fw, "whiteheat.fw",
305 &serial->dev->dev)) { 305 &serial->dev->dev)) {
306 err("%s - request \"whiteheat.fw\" failed", __func__); 306 dev_err(&serial->dev->dev,
307 "%s - request \"whiteheat.fw\" failed\n", __func__);
307 goto out; 308 goto out;
308 } 309 }
309 if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", 310 if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw",
310 &serial->dev->dev)) { 311 &serial->dev->dev)) {
311 err("%s - request \"whiteheat_loader.fw\" failed", __func__); 312 dev_err(&serial->dev->dev,
313 "%s - request \"whiteheat_loader.fw\" failed\n",
314 __func__);
312 goto out; 315 goto out;
313 } 316 }
314 ret = 0; 317 ret = 0;
@@ -320,9 +323,10 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
320 (unsigned char *)record->data, 323 (unsigned char *)record->data,
321 be16_to_cpu(record->len), 0xa0); 324 be16_to_cpu(record->len), 0xa0);
322 if (response < 0) { 325 if (response < 0) {
323 err("%s - ezusb_writememory failed for loader (%d %04X %p %d)", 326 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
324 __func__, response, be32_to_cpu(record->addr), 327 "failed for loader (%d %04X %p %d)\n",
325 record->data, be16_to_cpu(record->len)); 328 __func__, response, be32_to_cpu(record->addr),
329 record->data, be16_to_cpu(record->len));
326 break; 330 break;
327 } 331 }
328 record = ihex_next_binrec(record); 332 record = ihex_next_binrec(record);
@@ -338,9 +342,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
338 (unsigned char *)record->data, 342 (unsigned char *)record->data,
339 be16_to_cpu(record->len), 0xa3); 343 be16_to_cpu(record->len), 0xa3);
340 if (response < 0) { 344 if (response < 0) {
341 err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", 345 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
342 __func__, response, be32_to_cpu(record->addr), 346 "failed for first firmware step "
343 record->data, be16_to_cpu(record->len)); 347 "(%d %04X %p %d)\n", __func__, response,
348 be32_to_cpu(record->addr), record->data,
349 be16_to_cpu(record->len));
344 break; 350 break;
345 } 351 }
346 ++record; 352 ++record;
@@ -354,9 +360,11 @@ static int whiteheat_firmware_download(struct usb_serial *serial,
354 (unsigned char *)record->data, 360 (unsigned char *)record->data,
355 be16_to_cpu(record->len), 0xa0); 361 be16_to_cpu(record->len), 0xa0);
356 if (response < 0) { 362 if (response < 0) {
357 err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", 363 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
358 __func__, response, be32_to_cpu(record->addr), 364 "failed for second firmware step "
359 record->data, be16_to_cpu(record->len)); 365 "(%d %04X %p %d)\n", __func__, response,
366 be32_to_cpu(record->addr), record->data,
367 be16_to_cpu(record->len));
360 break; 368 break;
361 } 369 }
362 ++record; 370 ++record;
@@ -421,12 +429,12 @@ static int whiteheat_attach(struct usb_serial *serial)
421 ret = usb_bulk_msg(serial->dev, pipe, command, 2, 429 ret = usb_bulk_msg(serial->dev, pipe, command, 2,
422 &alen, COMMAND_TIMEOUT_MS); 430 &alen, COMMAND_TIMEOUT_MS);
423 if (ret) { 431 if (ret) {
424 err("%s: Couldn't send command [%d]", 432 dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n",
425 serial->type->description, ret); 433 serial->type->description, ret);
426 goto no_firmware; 434 goto no_firmware;
427 } else if (alen != 2) { 435 } else if (alen != 2) {
428 err("%s: Send command incomplete [%d]", 436 dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n",
429 serial->type->description, alen); 437 serial->type->description, alen);
430 goto no_firmware; 438 goto no_firmware;
431 } 439 }
432 440
@@ -437,31 +445,33 @@ static int whiteheat_attach(struct usb_serial *serial)
437 ret = usb_bulk_msg(serial->dev, pipe, result, 445 ret = usb_bulk_msg(serial->dev, pipe, result,
438 sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); 446 sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);
439 if (ret) { 447 if (ret) {
440 err("%s: Couldn't get results [%d]", 448 dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n",
441 serial->type->description, ret); 449 serial->type->description, ret);
442 goto no_firmware; 450 goto no_firmware;
443 } else if (alen != sizeof(*hw_info) + 1) { 451 } else if (alen != sizeof(*hw_info) + 1) {
444 err("%s: Get results incomplete [%d]", 452 dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n",
445 serial->type->description, alen); 453 serial->type->description, alen);
446 goto no_firmware; 454 goto no_firmware;
447 } else if (result[0] != command[0]) { 455 } else if (result[0] != command[0]) {
448 err("%s: Command failed [%d]", 456 dev_err(&serial->dev->dev, "%s: Command failed [%d]\n",
449 serial->type->description, result[0]); 457 serial->type->description, result[0]);
450 goto no_firmware; 458 goto no_firmware;
451 } 459 }
452 460
453 hw_info = (struct whiteheat_hw_info *)&result[1]; 461 hw_info = (struct whiteheat_hw_info *)&result[1];
454 462
455 info("%s: Driver %s: Firmware v%d.%02d", serial->type->description, 463 dev_info(&serial->dev->dev, "%s: Driver %s: Firmware v%d.%02d\n",
456 DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); 464 serial->type->description, DRIVER_VERSION,
465 hw_info->sw_major_rev, hw_info->sw_minor_rev);
457 466
458 for (i = 0; i < serial->num_ports; i++) { 467 for (i = 0; i < serial->num_ports; i++) {
459 port = serial->port[i]; 468 port = serial->port[i];
460 469
461 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); 470 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
462 if (info == NULL) { 471 if (info == NULL) {
463 err("%s: Out of memory for port structures\n", 472 dev_err(&port->dev,
464 serial->type->description); 473 "%s: Out of memory for port structures\n",
474 serial->type->description);
465 goto no_private; 475 goto no_private;
466 } 476 }
467 477
@@ -481,18 +491,20 @@ static int whiteheat_attach(struct usb_serial *serial)
481 for (j = 0; j < urb_pool_size; j++) { 491 for (j = 0; j < urb_pool_size; j++) {
482 urb = usb_alloc_urb(0, GFP_KERNEL); 492 urb = usb_alloc_urb(0, GFP_KERNEL);
483 if (!urb) { 493 if (!urb) {
484 err("No free urbs available"); 494 dev_err(&port->dev, "No free urbs available\n");
485 goto no_rx_urb; 495 goto no_rx_urb;
486 } 496 }
487 buf_size = port->read_urb->transfer_buffer_length; 497 buf_size = port->read_urb->transfer_buffer_length;
488 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); 498 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL);
489 if (!urb->transfer_buffer) { 499 if (!urb->transfer_buffer) {
490 err("Couldn't allocate urb buffer"); 500 dev_err(&port->dev,
501 "Couldn't allocate urb buffer\n");
491 goto no_rx_buf; 502 goto no_rx_buf;
492 } 503 }
493 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); 504 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL);
494 if (!wrap) { 505 if (!wrap) {
495 err("Couldn't allocate urb wrapper"); 506 dev_err(&port->dev,
507 "Couldn't allocate urb wrapper\n");
496 goto no_rx_wrap; 508 goto no_rx_wrap;
497 } 509 }
498 usb_fill_bulk_urb(urb, serial->dev, 510 usb_fill_bulk_urb(urb, serial->dev,
@@ -505,18 +517,20 @@ static int whiteheat_attach(struct usb_serial *serial)
505 517
506 urb = usb_alloc_urb(0, GFP_KERNEL); 518 urb = usb_alloc_urb(0, GFP_KERNEL);
507 if (!urb) { 519 if (!urb) {
508 err("No free urbs available"); 520 dev_err(&port->dev, "No free urbs available\n");
509 goto no_tx_urb; 521 goto no_tx_urb;
510 } 522 }
511 buf_size = port->write_urb->transfer_buffer_length; 523 buf_size = port->write_urb->transfer_buffer_length;
512 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); 524 urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL);
513 if (!urb->transfer_buffer) { 525 if (!urb->transfer_buffer) {
514 err("Couldn't allocate urb buffer"); 526 dev_err(&port->dev,
527 "Couldn't allocate urb buffer\n");
515 goto no_tx_buf; 528 goto no_tx_buf;
516 } 529 }
517 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); 530 wrap = kmalloc(sizeof(*wrap), GFP_KERNEL);
518 if (!wrap) { 531 if (!wrap) {
519 err("Couldn't allocate urb wrapper"); 532 dev_err(&port->dev,
533 "Couldn't allocate urb wrapper\n");
520 goto no_tx_wrap; 534 goto no_tx_wrap;
521 } 535 }
522 usb_fill_bulk_urb(urb, serial->dev, 536 usb_fill_bulk_urb(urb, serial->dev,
@@ -534,8 +548,9 @@ static int whiteheat_attach(struct usb_serial *serial)
534 command_info = kmalloc(sizeof(struct whiteheat_command_private), 548 command_info = kmalloc(sizeof(struct whiteheat_command_private),
535 GFP_KERNEL); 549 GFP_KERNEL);
536 if (command_info == NULL) { 550 if (command_info == NULL) {
537 err("%s: Out of memory for port structures\n", 551 dev_err(&serial->dev->dev,
538 serial->type->description); 552 "%s: Out of memory for port structures\n",
553 serial->type->description);
539 goto no_command_private; 554 goto no_command_private;
540 } 555 }
541 556
@@ -552,12 +567,15 @@ static int whiteheat_attach(struct usb_serial *serial)
552 567
553no_firmware: 568no_firmware:
554 /* Firmware likely not running */ 569 /* Firmware likely not running */
555 err("%s: Unable to retrieve firmware version, try replugging\n", 570 dev_err(&serial->dev->dev,
556 serial->type->description); 571 "%s: Unable to retrieve firmware version, try replugging\n",
557 err("%s: If the firmware is not running (status led not blinking)\n", 572 serial->type->description);
558 serial->type->description); 573 dev_err(&serial->dev->dev,
559 err("%s: please contact support@connecttech.com\n", 574 "%s: If the firmware is not running (status led not blinking)\n",
560 serial->type->description); 575 serial->type->description);
576 dev_err(&serial->dev->dev,
577 "%s: please contact support@connecttech.com\n",
578 serial->type->description);
561 kfree(result); 579 kfree(result);
562 return -ENODEV; 580 return -ENODEV;
563 581
@@ -680,8 +698,9 @@ static int whiteheat_open(struct tty_struct *tty,
680 /* Start reading from the device */ 698 /* Start reading from the device */
681 retval = start_port_read(port); 699 retval = start_port_read(port);
682 if (retval) { 700 if (retval) {
683 err("%s - failed submitting read urb, error %d", 701 dev_err(&port->dev,
684 __func__, retval); 702 "%s - failed submitting read urb, error %d\n",
703 __func__, retval);
685 firm_close(port); 704 firm_close(port);
686 stop_command_port(port->serial); 705 stop_command_port(port->serial);
687 goto exit; 706 goto exit;
@@ -806,8 +825,9 @@ static int whiteheat_write(struct tty_struct *tty,
806 urb->transfer_buffer_length = bytes; 825 urb->transfer_buffer_length = bytes;
807 result = usb_submit_urb(urb, GFP_ATOMIC); 826 result = usb_submit_urb(urb, GFP_ATOMIC);
808 if (result) { 827 if (result) {
809 err("%s - failed submitting write urb, error %d", 828 dev_err(&port->dev,
810 __func__, result); 829 "%s - failed submitting write urb, error %d\n",
830 __func__, result);
811 sent = result; 831 sent = result;
812 spin_lock_irqsave(&info->lock, flags); 832 spin_lock_irqsave(&info->lock, flags);
813 list_add(tmp, &info->tx_urbs_free); 833 list_add(tmp, &info->tx_urbs_free);
@@ -1075,7 +1095,7 @@ static void whiteheat_read_callback(struct urb *urb)
1075 wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); 1095 wrap = urb_to_wrap(urb, &info->rx_urbs_submitted);
1076 if (!wrap) { 1096 if (!wrap) {
1077 spin_unlock(&info->lock); 1097 spin_unlock(&info->lock);
1078 err("%s - Not my urb!", __func__); 1098 dev_err(&port->dev, "%s - Not my urb!\n", __func__);
1079 return; 1099 return;
1080 } 1100 }
1081 list_del(&wrap->list); 1101 list_del(&wrap->list);
@@ -1119,7 +1139,7 @@ static void whiteheat_write_callback(struct urb *urb)
1119 wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); 1139 wrap = urb_to_wrap(urb, &info->tx_urbs_submitted);
1120 if (!wrap) { 1140 if (!wrap) {
1121 spin_unlock(&info->lock); 1141 spin_unlock(&info->lock);
1122 err("%s - Not my urb!", __func__); 1142 dev_err(&port->dev, "%s - Not my urb!\n", __func__);
1123 return; 1143 return;
1124 } 1144 }
1125 list_move(&wrap->list, &info->tx_urbs_free); 1145 list_move(&wrap->list, &info->tx_urbs_free);
@@ -1383,8 +1403,9 @@ static int start_command_port(struct usb_serial *serial)
1383 command_port->read_urb->dev = serial->dev; 1403 command_port->read_urb->dev = serial->dev;
1384 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); 1404 retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
1385 if (retval) { 1405 if (retval) {
1386 err("%s - failed submitting read urb, error %d", 1406 dev_err(&serial->dev->dev,
1387 __func__, retval); 1407 "%s - failed submitting read urb, error %d\n",
1408 __func__, retval);
1388 goto exit; 1409 goto exit;
1389 } 1410 }
1390 } 1411 }
@@ -1522,7 +1543,8 @@ static void rx_data_softint(struct work_struct *work)
1522 urb->dev = port->serial->dev; 1543 urb->dev = port->serial->dev;
1523 result = usb_submit_urb(urb, GFP_ATOMIC); 1544 result = usb_submit_urb(urb, GFP_ATOMIC);
1524 if (result) { 1545 if (result) {
1525 err("%s - failed resubmitting read urb, error %d", 1546 dev_err(&port->dev,
1547 "%s - failed resubmitting read urb, error %d\n",
1526 __func__, result); 1548 __func__, result);
1527 spin_lock_irqsave(&info->lock, flags); 1549 spin_lock_irqsave(&info->lock, flags);
1528 list_add(tmp, &info->rx_urbs_free); 1550 list_add(tmp, &info->rx_urbs_free);
@@ -1556,7 +1578,8 @@ static int __init whiteheat_init(void)
1556 retval = usb_register(&whiteheat_driver); 1578 retval = usb_register(&whiteheat_driver);
1557 if (retval) 1579 if (retval)
1558 goto failed_usb_register; 1580 goto failed_usb_register;
1559 info(DRIVER_DESC " " DRIVER_VERSION); 1581 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
1582 DRIVER_DESC "\n");
1560 return 0; 1583 return 0;
1561failed_usb_register: 1584failed_usb_register:
1562 usb_serial_deregister(&whiteheat_device); 1585 usb_serial_deregister(&whiteheat_device);