diff options
Diffstat (limited to 'drivers/usb/serial/garmin_gps.c')
-rw-r--r-- | drivers/usb/serial/garmin_gps.c | 129 |
1 files changed, 59 insertions, 70 deletions
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 346c15a51066..3ee92648c02d 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -41,9 +41,6 @@ | |||
41 | /* the mode to be set when the port ist opened */ | 41 | /* the mode to be set when the port ist opened */ |
42 | static int initial_mode = 1; | 42 | static int initial_mode = 1; |
43 | 43 | ||
44 | /* debug flag */ | ||
45 | static bool debug; | ||
46 | |||
47 | #define GARMIN_VENDOR_ID 0x091E | 44 | #define GARMIN_VENDOR_ID 0x091E |
48 | 45 | ||
49 | /* | 46 | /* |
@@ -258,10 +255,7 @@ static void send_to_tty(struct usb_serial_port *port, | |||
258 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 255 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
259 | 256 | ||
260 | if (tty && actual_length) { | 257 | if (tty && actual_length) { |
261 | 258 | usb_serial_debug_data(&port->dev, __func__, actual_length, data); | |
262 | usb_serial_debug_data(debug, &port->dev, | ||
263 | __func__, actual_length, data); | ||
264 | |||
265 | tty_insert_flip_string(tty, data, actual_length); | 259 | tty_insert_flip_string(tty, data, actual_length); |
266 | tty_flip_buffer_push(tty); | 260 | tty_flip_buffer_push(tty); |
267 | } | 261 | } |
@@ -303,8 +297,9 @@ static int pkt_add(struct garmin_data *garmin_data_p, | |||
303 | state = garmin_data_p->state; | 297 | state = garmin_data_p->state; |
304 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 298 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
305 | 299 | ||
306 | dbg("%s - added: pkt: %d - %d bytes", | 300 | dev_dbg(&garmin_data_p->port->dev, |
307 | __func__, pkt->seq, data_length); | 301 | "%s - added: pkt: %d - %d bytes\n", __func__, |
302 | pkt->seq, data_length); | ||
308 | 303 | ||
309 | /* in serial mode, if someone is waiting for data from | 304 | /* in serial mode, if someone is waiting for data from |
310 | the device, convert and send the next packet to tty. */ | 305 | the device, convert and send the next packet to tty. */ |
@@ -359,7 +354,8 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) | |||
359 | __u8 *ptr = pkt; | 354 | __u8 *ptr = pkt; |
360 | unsigned l = 0; | 355 | unsigned l = 0; |
361 | 356 | ||
362 | dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id); | 357 | dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__, |
358 | 0xFF & pkt_id); | ||
363 | 359 | ||
364 | *ptr++ = DLE; | 360 | *ptr++ = DLE; |
365 | *ptr++ = ACK; | 361 | *ptr++ = ACK; |
@@ -399,20 +395,20 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) | |||
399 | */ | 395 | */ |
400 | static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | 396 | static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) |
401 | { | 397 | { |
398 | struct device *dev = &garmin_data_p->port->dev; | ||
402 | unsigned long flags; | 399 | unsigned long flags; |
403 | const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; | 400 | const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; |
404 | __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; | 401 | __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; |
405 | |||
406 | int cksum = 0; | 402 | int cksum = 0; |
407 | int n = 0; | 403 | int n = 0; |
408 | int pktid = recpkt[0]; | 404 | int pktid = recpkt[0]; |
409 | int size = recpkt[1]; | 405 | int size = recpkt[1]; |
410 | 406 | ||
411 | usb_serial_debug_data(debug, &garmin_data_p->port->dev, | 407 | usb_serial_debug_data(&garmin_data_p->port->dev, __func__, |
412 | __func__, count-GSP_INITIAL_OFFSET, recpkt); | 408 | count-GSP_INITIAL_OFFSET, recpkt); |
413 | 409 | ||
414 | if (size != (count-GSP_INITIAL_OFFSET-3)) { | 410 | if (size != (count-GSP_INITIAL_OFFSET-3)) { |
415 | dbg("%s - invalid size, expected %d bytes, got %d", | 411 | dev_dbg(dev, "%s - invalid size, expected %d bytes, got %d\n", |
416 | __func__, size, (count-GSP_INITIAL_OFFSET-3)); | 412 | __func__, size, (count-GSP_INITIAL_OFFSET-3)); |
417 | return -EINVPKT; | 413 | return -EINVPKT; |
418 | } | 414 | } |
@@ -422,8 +418,8 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
422 | 418 | ||
423 | /* sanity check, remove after test ... */ | 419 | /* sanity check, remove after test ... */ |
424 | if ((__u8 *)&(usbdata[3]) != recpkt) { | 420 | if ((__u8 *)&(usbdata[3]) != recpkt) { |
425 | dbg("%s - ptr mismatch %p - %p", | 421 | dev_dbg(dev, "%s - ptr mismatch %p - %p\n", __func__, |
426 | __func__, &(usbdata[4]), recpkt); | 422 | &(usbdata[4]), recpkt); |
427 | return -EINVPKT; | 423 | return -EINVPKT; |
428 | } | 424 | } |
429 | 425 | ||
@@ -433,7 +429,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
433 | } | 429 | } |
434 | 430 | ||
435 | if ((0xff & (cksum + *recpkt)) != 0) { | 431 | if ((0xff & (cksum + *recpkt)) != 0) { |
436 | dbg("%s - invalid checksum, expected %02x, got %02x", | 432 | dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n", |
437 | __func__, 0xff & -cksum, 0xff & *recpkt); | 433 | __func__, 0xff & -cksum, 0xff & *recpkt); |
438 | return -EINVPKT; | 434 | return -EINVPKT; |
439 | } | 435 | } |
@@ -480,6 +476,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) | |||
480 | static int gsp_receive(struct garmin_data *garmin_data_p, | 476 | static int gsp_receive(struct garmin_data *garmin_data_p, |
481 | const unsigned char *buf, int count) | 477 | const unsigned char *buf, int count) |
482 | { | 478 | { |
479 | struct device *dev = &garmin_data_p->port->dev; | ||
483 | unsigned long flags; | 480 | unsigned long flags; |
484 | int offs = 0; | 481 | int offs = 0; |
485 | int ack_or_nak_seen = 0; | 482 | int ack_or_nak_seen = 0; |
@@ -500,7 +497,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
500 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; | 497 | skip = garmin_data_p->flags & FLAGS_GSP_SKIP; |
501 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 498 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
502 | 499 | ||
503 | /* dbg("%s - dle=%d skip=%d size=%d count=%d", | 500 | /* dev_dbg(dev, "%s - dle=%d skip=%d size=%d count=%d\n", |
504 | __func__, dleSeen, skip, size, count); */ | 501 | __func__, dleSeen, skip, size, count); */ |
505 | 502 | ||
506 | if (size == 0) | 503 | if (size == 0) |
@@ -530,12 +527,12 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
530 | 527 | ||
531 | if (data == ACK) { | 528 | if (data == ACK) { |
532 | ack_or_nak_seen = ACK; | 529 | ack_or_nak_seen = ACK; |
533 | dbg("ACK packet complete."); | 530 | dev_dbg(dev, "ACK packet complete.\n"); |
534 | } else if (data == NAK) { | 531 | } else if (data == NAK) { |
535 | ack_or_nak_seen = NAK; | 532 | ack_or_nak_seen = NAK; |
536 | dbg("NAK packet complete."); | 533 | dev_dbg(dev, "NAK packet complete.\n"); |
537 | } else { | 534 | } else { |
538 | dbg("packet complete - id=0x%X.", | 535 | dev_dbg(dev, "packet complete - id=0x%X.\n", |
539 | 0xFF & data); | 536 | 0xFF & data); |
540 | gsp_rec_packet(garmin_data_p, size); | 537 | gsp_rec_packet(garmin_data_p, size); |
541 | } | 538 | } |
@@ -557,7 +554,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
557 | } | 554 | } |
558 | 555 | ||
559 | if (size >= GPS_IN_BUFSIZ) { | 556 | if (size >= GPS_IN_BUFSIZ) { |
560 | dbg("%s - packet too large.", __func__); | 557 | dev_dbg(dev, "%s - packet too large.\n", __func__); |
561 | skip = 1; | 558 | skip = 1; |
562 | size = GSP_INITIAL_OFFSET; | 559 | size = GSP_INITIAL_OFFSET; |
563 | dleSeen = 0; | 560 | dleSeen = 0; |
@@ -602,6 +599,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, | |||
602 | static int gsp_send(struct garmin_data *garmin_data_p, | 599 | static int gsp_send(struct garmin_data *garmin_data_p, |
603 | const unsigned char *buf, int count) | 600 | const unsigned char *buf, int count) |
604 | { | 601 | { |
602 | struct device *dev = &garmin_data_p->port->dev; | ||
605 | const unsigned char *src; | 603 | const unsigned char *src; |
606 | unsigned char *dst; | 604 | unsigned char *dst; |
607 | int pktid = 0; | 605 | int pktid = 0; |
@@ -610,12 +608,12 @@ static int gsp_send(struct garmin_data *garmin_data_p, | |||
610 | int i = 0; | 608 | int i = 0; |
611 | int k; | 609 | int k; |
612 | 610 | ||
613 | dbg("%s - state %d - %d bytes.", __func__, | 611 | dev_dbg(dev, "%s - state %d - %d bytes.\n", __func__, |
614 | garmin_data_p->state, count); | 612 | garmin_data_p->state, count); |
615 | 613 | ||
616 | k = garmin_data_p->outsize; | 614 | k = garmin_data_p->outsize; |
617 | if ((k+count) > GPS_OUT_BUFSIZ) { | 615 | if ((k+count) > GPS_OUT_BUFSIZ) { |
618 | dbg("packet too large"); | 616 | dev_dbg(dev, "packet too large\n"); |
619 | garmin_data_p->outsize = 0; | 617 | garmin_data_p->outsize = 0; |
620 | return -4; | 618 | return -4; |
621 | } | 619 | } |
@@ -634,28 +632,28 @@ static int gsp_send(struct garmin_data *garmin_data_p, | |||
634 | return 0; | 632 | return 0; |
635 | } | 633 | } |
636 | 634 | ||
637 | dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); | 635 | dev_dbg(dev, "%s - %d bytes in buffer, %d bytes in pkt.\n", __func__, k, i); |
638 | 636 | ||
639 | /* garmin_data_p->outbuffer now contains a complete packet */ | 637 | /* garmin_data_p->outbuffer now contains a complete packet */ |
640 | 638 | ||
641 | usb_serial_debug_data(debug, &garmin_data_p->port->dev, | 639 | usb_serial_debug_data(&garmin_data_p->port->dev, __func__, k, |
642 | __func__, k, garmin_data_p->outbuffer); | 640 | garmin_data_p->outbuffer); |
643 | 641 | ||
644 | garmin_data_p->outsize = 0; | 642 | garmin_data_p->outsize = 0; |
645 | 643 | ||
646 | if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { | 644 | if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { |
647 | dbg("not an application packet (%d)", | 645 | dev_dbg(dev, "not an application packet (%d)\n", |
648 | getLayerId(garmin_data_p->outbuffer)); | 646 | getLayerId(garmin_data_p->outbuffer)); |
649 | return -1; | 647 | return -1; |
650 | } | 648 | } |
651 | 649 | ||
652 | if (pktid > 255) { | 650 | if (pktid > 255) { |
653 | dbg("packet-id %d too large", pktid); | 651 | dev_dbg(dev, "packet-id %d too large\n", pktid); |
654 | return -2; | 652 | return -2; |
655 | } | 653 | } |
656 | 654 | ||
657 | if (datalen > 255) { | 655 | if (datalen > 255) { |
658 | dbg("packet-size %d too large", datalen); | 656 | dev_dbg(dev, "packet-size %d too large\n", datalen); |
659 | return -3; | 657 | return -3; |
660 | } | 658 | } |
661 | 659 | ||
@@ -722,7 +720,7 @@ static int gsp_next_packet(struct garmin_data *garmin_data_p) | |||
722 | struct garmin_packet *pkt = NULL; | 720 | struct garmin_packet *pkt = NULL; |
723 | 721 | ||
724 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { | 722 | while ((pkt = pkt_pop(garmin_data_p)) != NULL) { |
725 | dbg("%s - next pkt: %d", __func__, pkt->seq); | 723 | dev_dbg(&garmin_data_p->port->dev, "%s - next pkt: %d\n", __func__, pkt->seq); |
726 | result = gsp_send(garmin_data_p, pkt->data, pkt->size); | 724 | result = gsp_send(garmin_data_p, pkt->data, pkt->size); |
727 | if (result > 0) { | 725 | if (result > 0) { |
728 | kfree(pkt); | 726 | kfree(pkt); |
@@ -768,7 +766,9 @@ static int nat_receive(struct garmin_data *garmin_data_p, | |||
768 | if (len >= GPS_IN_BUFSIZ) { | 766 | if (len >= GPS_IN_BUFSIZ) { |
769 | /* seems to be an invalid packet, ignore rest | 767 | /* seems to be an invalid packet, ignore rest |
770 | of input */ | 768 | of input */ |
771 | dbg("%s - packet size too large: %d", __func__, len); | 769 | dev_dbg(&garmin_data_p->port->dev, |
770 | "%s - packet size too large: %d\n", | ||
771 | __func__, len); | ||
772 | garmin_data_p->insize = 0; | 772 | garmin_data_p->insize = 0; |
773 | count = 0; | 773 | count = 0; |
774 | result = -EINVPKT; | 774 | result = -EINVPKT; |
@@ -849,10 +849,10 @@ static int process_resetdev_request(struct usb_serial_port *port) | |||
849 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 849 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
850 | 850 | ||
851 | usb_kill_urb(port->interrupt_in_urb); | 851 | usb_kill_urb(port->interrupt_in_urb); |
852 | dbg("%s - usb_reset_device", __func__); | 852 | dev_dbg(&port->dev, "%s - usb_reset_device\n", __func__); |
853 | status = usb_reset_device(port->serial->dev); | 853 | status = usb_reset_device(port->serial->dev); |
854 | if (status) | 854 | if (status) |
855 | dbg("%s - usb_reset_device failed: %d", | 855 | dev_dbg(&port->dev, "%s - usb_reset_device failed: %d\n", |
856 | __func__, status); | 856 | __func__, status); |
857 | return status; | 857 | return status; |
858 | } | 858 | } |
@@ -889,7 +889,7 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
889 | if (status == 0) { | 889 | if (status == 0) { |
890 | usb_kill_urb(port->interrupt_in_urb); | 890 | usb_kill_urb(port->interrupt_in_urb); |
891 | 891 | ||
892 | dbg("%s - adding interrupt input", __func__); | 892 | dev_dbg(&serial->dev->dev, "%s - adding interrupt input\n", __func__); |
893 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 893 | status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
894 | if (status) | 894 | if (status) |
895 | dev_err(&serial->dev->dev, | 895 | dev_err(&serial->dev->dev, |
@@ -902,7 +902,7 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
902 | * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() | 902 | * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() |
903 | */ | 903 | */ |
904 | if (status == 0) { | 904 | if (status == 0) { |
905 | dbg("%s - starting session ...", __func__); | 905 | dev_dbg(&serial->dev->dev, "%s - starting session ...\n", __func__); |
906 | garmin_data_p->state = STATE_ACTIVE; | 906 | garmin_data_p->state = STATE_ACTIVE; |
907 | 907 | ||
908 | for (i = 0; i < 3; i++) { | 908 | for (i = 0; i < 3; i++) { |
@@ -952,8 +952,8 @@ static void garmin_close(struct usb_serial_port *port) | |||
952 | struct usb_serial *serial = port->serial; | 952 | struct usb_serial *serial = port->serial; |
953 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 953 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
954 | 954 | ||
955 | dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, | 955 | dev_dbg(&port->dev, "%s - port %d - mode=%d state=%d flags=0x%X\n", |
956 | port->number, garmin_data_p->mode, | 956 | __func__, port->number, garmin_data_p->mode, |
957 | garmin_data_p->state, garmin_data_p->flags); | 957 | garmin_data_p->state, garmin_data_p->flags); |
958 | 958 | ||
959 | if (!serial) | 959 | if (!serial) |
@@ -1032,7 +1032,7 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1032 | 1032 | ||
1033 | memcpy(buffer, buf, count); | 1033 | memcpy(buffer, buf, count); |
1034 | 1034 | ||
1035 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 1035 | usb_serial_debug_data(&port->dev, __func__, count, buffer); |
1036 | 1036 | ||
1037 | usb_fill_bulk_urb(urb, serial->dev, | 1037 | usb_fill_bulk_urb(urb, serial->dev, |
1038 | usb_sndbulkpipe(serial->dev, | 1038 | usb_sndbulkpipe(serial->dev, |
@@ -1073,11 +1073,12 @@ static int garmin_write_bulk(struct usb_serial_port *port, | |||
1073 | static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | 1073 | static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, |
1074 | const unsigned char *buf, int count) | 1074 | const unsigned char *buf, int count) |
1075 | { | 1075 | { |
1076 | struct device *dev = &port->dev; | ||
1076 | int pktid, pktsiz, len; | 1077 | int pktid, pktsiz, len; |
1077 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); | 1078 | struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); |
1078 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; | 1079 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; |
1079 | 1080 | ||
1080 | usb_serial_debug_data(debug, &port->dev, __func__, count, buf); | 1081 | usb_serial_debug_data(dev, __func__, count, buf); |
1081 | 1082 | ||
1082 | if (garmin_data_p->state == STATE_RESET) | 1083 | if (garmin_data_p->state == STATE_RESET) |
1083 | return -EIO; | 1084 | return -EIO; |
@@ -1097,27 +1098,18 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1097 | && GARMIN_LAYERID_PRIVATE == | 1098 | && GARMIN_LAYERID_PRIVATE == |
1098 | getLayerId(garmin_data_p->privpkt)) { | 1099 | getLayerId(garmin_data_p->privpkt)) { |
1099 | 1100 | ||
1100 | dbg("%s - processing private request %d", | 1101 | dev_dbg(dev, "%s - processing private request %d\n", |
1101 | __func__, pktid); | 1102 | __func__, pktid); |
1102 | 1103 | ||
1103 | /* drop all unfinished transfers */ | 1104 | /* drop all unfinished transfers */ |
1104 | garmin_clear(garmin_data_p); | 1105 | garmin_clear(garmin_data_p); |
1105 | 1106 | ||
1106 | switch (pktid) { | 1107 | switch (pktid) { |
1107 | |||
1108 | case PRIV_PKTID_SET_DEBUG: | ||
1109 | if (pktsiz != 4) | ||
1110 | return -EINVPKT; | ||
1111 | debug = __le32_to_cpu(privpkt[3]); | ||
1112 | dbg("%s - debug level set to 0x%X", | ||
1113 | __func__, debug); | ||
1114 | break; | ||
1115 | |||
1116 | case PRIV_PKTID_SET_MODE: | 1108 | case PRIV_PKTID_SET_MODE: |
1117 | if (pktsiz != 4) | 1109 | if (pktsiz != 4) |
1118 | return -EINVPKT; | 1110 | return -EINVPKT; |
1119 | garmin_data_p->mode = __le32_to_cpu(privpkt[3]); | 1111 | garmin_data_p->mode = __le32_to_cpu(privpkt[3]); |
1120 | dbg("%s - mode set to %d", | 1112 | dev_dbg(dev, "%s - mode set to %d\n", |
1121 | __func__, garmin_data_p->mode); | 1113 | __func__, garmin_data_p->mode); |
1122 | break; | 1114 | break; |
1123 | 1115 | ||
@@ -1133,7 +1125,7 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1133 | if (pktsiz != 4) | 1125 | if (pktsiz != 4) |
1134 | return -EINVPKT; | 1126 | return -EINVPKT; |
1135 | initial_mode = __le32_to_cpu(privpkt[3]); | 1127 | initial_mode = __le32_to_cpu(privpkt[3]); |
1136 | dbg("%s - initial_mode set to %d", | 1128 | dev_dbg(dev, "%s - initial_mode set to %d\n", |
1137 | __func__, | 1129 | __func__, |
1138 | garmin_data_p->mode); | 1130 | garmin_data_p->mode); |
1139 | break; | 1131 | break; |
@@ -1169,7 +1161,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p, | |||
1169 | 1161 | ||
1170 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { | 1162 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { |
1171 | /* abort-transfer cmd is actice */ | 1163 | /* abort-transfer cmd is actice */ |
1172 | dbg("%s - pkt dropped", __func__); | 1164 | dev_dbg(&garmin_data_p->port->dev, "%s - pkt dropped\n", __func__); |
1173 | } else if (garmin_data_p->state != STATE_DISCONNECTED && | 1165 | } else if (garmin_data_p->state != STATE_DISCONNECTED && |
1174 | garmin_data_p->state != STATE_RESET) { | 1166 | garmin_data_p->state != STATE_RESET) { |
1175 | 1167 | ||
@@ -1178,7 +1170,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p, | |||
1178 | send it directly to the tty port */ | 1170 | send it directly to the tty port */ |
1179 | if (garmin_data_p->flags & FLAGS_QUEUING) { | 1171 | if (garmin_data_p->flags & FLAGS_QUEUING) { |
1180 | pkt_add(garmin_data_p, data, data_length); | 1172 | pkt_add(garmin_data_p, data, data_length); |
1181 | } else if (bulk_data || | 1173 | } else if (bulk_data || |
1182 | getLayerId(data) == GARMIN_LAYERID_APPL) { | 1174 | getLayerId(data) == GARMIN_LAYERID_APPL) { |
1183 | 1175 | ||
1184 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1176 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
@@ -1208,18 +1200,17 @@ static void garmin_read_bulk_callback(struct urb *urb) | |||
1208 | int retval; | 1200 | int retval; |
1209 | 1201 | ||
1210 | if (!serial) { | 1202 | if (!serial) { |
1211 | dbg("%s - bad serial pointer, exiting", __func__); | 1203 | dev_dbg(&urb->dev->dev, "%s - bad serial pointer, exiting\n", __func__); |
1212 | return; | 1204 | return; |
1213 | } | 1205 | } |
1214 | 1206 | ||
1215 | if (status) { | 1207 | if (status) { |
1216 | dbg("%s - nonzero read bulk status received: %d", | 1208 | dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", |
1217 | __func__, status); | 1209 | __func__, status); |
1218 | return; | 1210 | return; |
1219 | } | 1211 | } |
1220 | 1212 | ||
1221 | usb_serial_debug_data(debug, &port->dev, | 1213 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); |
1222 | __func__, urb->actual_length, data); | ||
1223 | 1214 | ||
1224 | garmin_read_process(garmin_data_p, data, urb->actual_length, 1); | 1215 | garmin_read_process(garmin_data_p, data, urb->actual_length, 1); |
1225 | 1216 | ||
@@ -1239,11 +1230,11 @@ static void garmin_read_bulk_callback(struct urb *urb) | |||
1239 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1230 | retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1240 | if (retval) | 1231 | if (retval) |
1241 | dev_err(&port->dev, | 1232 | dev_err(&port->dev, |
1242 | "%s - failed resubmitting read urb, " | 1233 | "%s - failed resubmitting read urb, error %d\n", |
1243 | "error %d\n", __func__, retval); | 1234 | __func__, retval); |
1244 | } | 1235 | } |
1245 | } else { | 1236 | } else { |
1246 | dbg("%s - end of bulk data", __func__); | 1237 | dev_dbg(&port->dev, "%s - end of bulk data\n", __func__); |
1247 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1238 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
1248 | garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; | 1239 | garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; |
1249 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 1240 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
@@ -1268,23 +1259,23 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1268 | case -ENOENT: | 1259 | case -ENOENT: |
1269 | case -ESHUTDOWN: | 1260 | case -ESHUTDOWN: |
1270 | /* this urb is terminated, clean up */ | 1261 | /* this urb is terminated, clean up */ |
1271 | dbg("%s - urb shutting down with status: %d", | 1262 | dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", |
1272 | __func__, status); | 1263 | __func__, status); |
1273 | return; | 1264 | return; |
1274 | default: | 1265 | default: |
1275 | dbg("%s - nonzero urb status received: %d", | 1266 | dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", |
1276 | __func__, status); | 1267 | __func__, status); |
1277 | return; | 1268 | return; |
1278 | } | 1269 | } |
1279 | 1270 | ||
1280 | usb_serial_debug_data(debug, &port->dev, __func__, | 1271 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, |
1281 | urb->actual_length, urb->transfer_buffer); | 1272 | urb->transfer_buffer); |
1282 | 1273 | ||
1283 | if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && | 1274 | if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && |
1284 | 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, | 1275 | 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, |
1285 | sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { | 1276 | sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { |
1286 | 1277 | ||
1287 | dbg("%s - bulk data available.", __func__); | 1278 | dev_dbg(&port->dev, "%s - bulk data available.\n", __func__); |
1288 | 1279 | ||
1289 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { | 1280 | if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { |
1290 | 1281 | ||
@@ -1319,7 +1310,7 @@ static void garmin_read_int_callback(struct urb *urb) | |||
1319 | garmin_data_p->serial_num = __le32_to_cpup( | 1310 | garmin_data_p->serial_num = __le32_to_cpup( |
1320 | (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); | 1311 | (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); |
1321 | 1312 | ||
1322 | dbg("%s - start-of-session reply seen - serial %u.", | 1313 | dev_dbg(&port->dev, "%s - start-of-session reply seen - serial %u.\n", |
1323 | __func__, garmin_data_p->serial_num); | 1314 | __func__, garmin_data_p->serial_num); |
1324 | } | 1315 | } |
1325 | 1316 | ||
@@ -1495,7 +1486,5 @@ MODULE_AUTHOR(DRIVER_AUTHOR); | |||
1495 | MODULE_DESCRIPTION(DRIVER_DESC); | 1486 | MODULE_DESCRIPTION(DRIVER_DESC); |
1496 | MODULE_LICENSE("GPL"); | 1487 | MODULE_LICENSE("GPL"); |
1497 | 1488 | ||
1498 | module_param(debug, bool, S_IWUSR | S_IRUGO); | ||
1499 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
1500 | module_param(initial_mode, int, S_IRUGO); | 1489 | module_param(initial_mode, int, S_IRUGO); |
1501 | MODULE_PARM_DESC(initial_mode, "Initial mode"); | 1490 | MODULE_PARM_DESC(initial_mode, "Initial mode"); |