diff options
Diffstat (limited to 'drivers/usb/serial/whiteheat.c')
-rw-r--r-- | drivers/usb/serial/whiteheat.c | 113 |
1 files changed, 67 insertions, 46 deletions
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 39f7f8d291d6..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,16 +445,16 @@ 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 | ||
@@ -461,8 +469,9 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
461 | 469 | ||
462 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 470 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
463 | if (info == NULL) { | 471 | if (info == NULL) { |
464 | err("%s: Out of memory for port structures\n", | 472 | dev_err(&port->dev, |
465 | serial->type->description); | 473 | "%s: Out of memory for port structures\n", |
474 | serial->type->description); | ||
466 | goto no_private; | 475 | goto no_private; |
467 | } | 476 | } |
468 | 477 | ||
@@ -482,18 +491,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
482 | for (j = 0; j < urb_pool_size; j++) { | 491 | for (j = 0; j < urb_pool_size; j++) { |
483 | urb = usb_alloc_urb(0, GFP_KERNEL); | 492 | urb = usb_alloc_urb(0, GFP_KERNEL); |
484 | if (!urb) { | 493 | if (!urb) { |
485 | err("No free urbs available"); | 494 | dev_err(&port->dev, "No free urbs available\n"); |
486 | goto no_rx_urb; | 495 | goto no_rx_urb; |
487 | } | 496 | } |
488 | buf_size = port->read_urb->transfer_buffer_length; | 497 | buf_size = port->read_urb->transfer_buffer_length; |
489 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 498 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
490 | if (!urb->transfer_buffer) { | 499 | if (!urb->transfer_buffer) { |
491 | err("Couldn't allocate urb buffer"); | 500 | dev_err(&port->dev, |
501 | "Couldn't allocate urb buffer\n"); | ||
492 | goto no_rx_buf; | 502 | goto no_rx_buf; |
493 | } | 503 | } |
494 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 504 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
495 | if (!wrap) { | 505 | if (!wrap) { |
496 | err("Couldn't allocate urb wrapper"); | 506 | dev_err(&port->dev, |
507 | "Couldn't allocate urb wrapper\n"); | ||
497 | goto no_rx_wrap; | 508 | goto no_rx_wrap; |
498 | } | 509 | } |
499 | usb_fill_bulk_urb(urb, serial->dev, | 510 | usb_fill_bulk_urb(urb, serial->dev, |
@@ -506,18 +517,20 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
506 | 517 | ||
507 | urb = usb_alloc_urb(0, GFP_KERNEL); | 518 | urb = usb_alloc_urb(0, GFP_KERNEL); |
508 | if (!urb) { | 519 | if (!urb) { |
509 | err("No free urbs available"); | 520 | dev_err(&port->dev, "No free urbs available\n"); |
510 | goto no_tx_urb; | 521 | goto no_tx_urb; |
511 | } | 522 | } |
512 | buf_size = port->write_urb->transfer_buffer_length; | 523 | buf_size = port->write_urb->transfer_buffer_length; |
513 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); | 524 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
514 | if (!urb->transfer_buffer) { | 525 | if (!urb->transfer_buffer) { |
515 | err("Couldn't allocate urb buffer"); | 526 | dev_err(&port->dev, |
527 | "Couldn't allocate urb buffer\n"); | ||
516 | goto no_tx_buf; | 528 | goto no_tx_buf; |
517 | } | 529 | } |
518 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); | 530 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
519 | if (!wrap) { | 531 | if (!wrap) { |
520 | err("Couldn't allocate urb wrapper"); | 532 | dev_err(&port->dev, |
533 | "Couldn't allocate urb wrapper\n"); | ||
521 | goto no_tx_wrap; | 534 | goto no_tx_wrap; |
522 | } | 535 | } |
523 | usb_fill_bulk_urb(urb, serial->dev, | 536 | usb_fill_bulk_urb(urb, serial->dev, |
@@ -535,8 +548,9 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
535 | command_info = kmalloc(sizeof(struct whiteheat_command_private), | 548 | command_info = kmalloc(sizeof(struct whiteheat_command_private), |
536 | GFP_KERNEL); | 549 | GFP_KERNEL); |
537 | if (command_info == NULL) { | 550 | if (command_info == NULL) { |
538 | err("%s: Out of memory for port structures\n", | 551 | dev_err(&serial->dev->dev, |
539 | serial->type->description); | 552 | "%s: Out of memory for port structures\n", |
553 | serial->type->description); | ||
540 | goto no_command_private; | 554 | goto no_command_private; |
541 | } | 555 | } |
542 | 556 | ||
@@ -553,12 +567,15 @@ static int whiteheat_attach(struct usb_serial *serial) | |||
553 | 567 | ||
554 | no_firmware: | 568 | no_firmware: |
555 | /* Firmware likely not running */ | 569 | /* Firmware likely not running */ |
556 | err("%s: Unable to retrieve firmware version, try replugging\n", | 570 | dev_err(&serial->dev->dev, |
557 | serial->type->description); | 571 | "%s: Unable to retrieve firmware version, try replugging\n", |
558 | err("%s: If the firmware is not running (status led not blinking)\n", | 572 | serial->type->description); |
559 | serial->type->description); | 573 | dev_err(&serial->dev->dev, |
560 | err("%s: please contact support@connecttech.com\n", | 574 | "%s: If the firmware is not running (status led not blinking)\n", |
561 | 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); | ||
562 | kfree(result); | 579 | kfree(result); |
563 | return -ENODEV; | 580 | return -ENODEV; |
564 | 581 | ||
@@ -681,8 +698,9 @@ static int whiteheat_open(struct tty_struct *tty, | |||
681 | /* Start reading from the device */ | 698 | /* Start reading from the device */ |
682 | retval = start_port_read(port); | 699 | retval = start_port_read(port); |
683 | if (retval) { | 700 | if (retval) { |
684 | err("%s - failed submitting read urb, error %d", | 701 | dev_err(&port->dev, |
685 | __func__, retval); | 702 | "%s - failed submitting read urb, error %d\n", |
703 | __func__, retval); | ||
686 | firm_close(port); | 704 | firm_close(port); |
687 | stop_command_port(port->serial); | 705 | stop_command_port(port->serial); |
688 | goto exit; | 706 | goto exit; |
@@ -807,8 +825,9 @@ static int whiteheat_write(struct tty_struct *tty, | |||
807 | urb->transfer_buffer_length = bytes; | 825 | urb->transfer_buffer_length = bytes; |
808 | result = usb_submit_urb(urb, GFP_ATOMIC); | 826 | result = usb_submit_urb(urb, GFP_ATOMIC); |
809 | if (result) { | 827 | if (result) { |
810 | err("%s - failed submitting write urb, error %d", | 828 | dev_err(&port->dev, |
811 | __func__, result); | 829 | "%s - failed submitting write urb, error %d\n", |
830 | __func__, result); | ||
812 | sent = result; | 831 | sent = result; |
813 | spin_lock_irqsave(&info->lock, flags); | 832 | spin_lock_irqsave(&info->lock, flags); |
814 | list_add(tmp, &info->tx_urbs_free); | 833 | list_add(tmp, &info->tx_urbs_free); |
@@ -1076,7 +1095,7 @@ static void whiteheat_read_callback(struct urb *urb) | |||
1076 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); | 1095 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); |
1077 | if (!wrap) { | 1096 | if (!wrap) { |
1078 | spin_unlock(&info->lock); | 1097 | spin_unlock(&info->lock); |
1079 | err("%s - Not my urb!", __func__); | 1098 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
1080 | return; | 1099 | return; |
1081 | } | 1100 | } |
1082 | list_del(&wrap->list); | 1101 | list_del(&wrap->list); |
@@ -1120,7 +1139,7 @@ static void whiteheat_write_callback(struct urb *urb) | |||
1120 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); | 1139 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); |
1121 | if (!wrap) { | 1140 | if (!wrap) { |
1122 | spin_unlock(&info->lock); | 1141 | spin_unlock(&info->lock); |
1123 | err("%s - Not my urb!", __func__); | 1142 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
1124 | return; | 1143 | return; |
1125 | } | 1144 | } |
1126 | list_move(&wrap->list, &info->tx_urbs_free); | 1145 | list_move(&wrap->list, &info->tx_urbs_free); |
@@ -1384,8 +1403,9 @@ static int start_command_port(struct usb_serial *serial) | |||
1384 | command_port->read_urb->dev = serial->dev; | 1403 | command_port->read_urb->dev = serial->dev; |
1385 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); | 1404 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
1386 | if (retval) { | 1405 | if (retval) { |
1387 | err("%s - failed submitting read urb, error %d", | 1406 | dev_err(&serial->dev->dev, |
1388 | __func__, retval); | 1407 | "%s - failed submitting read urb, error %d\n", |
1408 | __func__, retval); | ||
1389 | goto exit; | 1409 | goto exit; |
1390 | } | 1410 | } |
1391 | } | 1411 | } |
@@ -1523,7 +1543,8 @@ static void rx_data_softint(struct work_struct *work) | |||
1523 | urb->dev = port->serial->dev; | 1543 | urb->dev = port->serial->dev; |
1524 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1544 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1525 | if (result) { | 1545 | if (result) { |
1526 | err("%s - failed resubmitting read urb, error %d", | 1546 | dev_err(&port->dev, |
1547 | "%s - failed resubmitting read urb, error %d\n", | ||
1527 | __func__, result); | 1548 | __func__, result); |
1528 | spin_lock_irqsave(&info->lock, flags); | 1549 | spin_lock_irqsave(&info->lock, flags); |
1529 | list_add(tmp, &info->rx_urbs_free); | 1550 | list_add(tmp, &info->rx_urbs_free); |