diff options
Diffstat (limited to 'drivers/isdn/gigaset/usb-gigaset.c')
-rw-r--r-- | drivers/isdn/gigaset/usb-gigaset.c | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c index 4deb1ab0dbf8..76dbb20f3065 100644 --- a/drivers/isdn/gigaset/usb-gigaset.c +++ b/drivers/isdn/gigaset/usb-gigaset.c | |||
@@ -16,10 +16,6 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "gigaset.h" | 18 | #include "gigaset.h" |
19 | |||
20 | #include <linux/errno.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/usb.h> | 19 | #include <linux/usb.h> |
24 | #include <linux/module.h> | 20 | #include <linux/module.h> |
25 | #include <linux/moduleparam.h> | 21 | #include <linux/moduleparam.h> |
@@ -43,14 +39,14 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode"); | |||
43 | #define GIGASET_MODULENAME "usb_gigaset" | 39 | #define GIGASET_MODULENAME "usb_gigaset" |
44 | #define GIGASET_DEVNAME "ttyGU" | 40 | #define GIGASET_DEVNAME "ttyGU" |
45 | 41 | ||
46 | #define IF_WRITEBUF 2000 //FIXME // WAKEUP_CHARS: 256 | 42 | #define IF_WRITEBUF 2000 /* arbitrary limit */ |
47 | 43 | ||
48 | /* Values for the Gigaset M105 Data */ | 44 | /* Values for the Gigaset M105 Data */ |
49 | #define USB_M105_VENDOR_ID 0x0681 | 45 | #define USB_M105_VENDOR_ID 0x0681 |
50 | #define USB_M105_PRODUCT_ID 0x0009 | 46 | #define USB_M105_PRODUCT_ID 0x0009 |
51 | 47 | ||
52 | /* table of devices that work with this driver */ | 48 | /* table of devices that work with this driver */ |
53 | static const struct usb_device_id gigaset_table [] = { | 49 | static const struct usb_device_id gigaset_table[] = { |
54 | { USB_DEVICE(USB_M105_VENDOR_ID, USB_M105_PRODUCT_ID) }, | 50 | { USB_DEVICE(USB_M105_VENDOR_ID, USB_M105_PRODUCT_ID) }, |
55 | { } /* Terminating entry */ | 51 | { } /* Terminating entry */ |
56 | }; | 52 | }; |
@@ -97,8 +93,8 @@ MODULE_DEVICE_TABLE(usb, gigaset_table); | |||
97 | * 41 19 -- -- -- -- 06 00 00 00 00 xx 11 13 | 93 | * 41 19 -- -- -- -- 06 00 00 00 00 xx 11 13 |
98 | * Used after every "configuration sequence" (RQ 12, RQs 01/03/13). | 94 | * Used after every "configuration sequence" (RQ 12, RQs 01/03/13). |
99 | * xx is usually 0x00 but was 0x7e before starting data transfer | 95 | * xx is usually 0x00 but was 0x7e before starting data transfer |
100 | * in unimodem mode. So, this might be an array of characters that need | 96 | * in unimodem mode. So, this might be an array of characters that |
101 | * special treatment ("commit all bufferd data"?), 11=^Q, 13=^S. | 97 | * need special treatment ("commit all bufferd data"?), 11=^Q, 13=^S. |
102 | * | 98 | * |
103 | * Unimodem mode: use "modprobe ppp_async flag_time=0" as the device _needs_ two | 99 | * Unimodem mode: use "modprobe ppp_async flag_time=0" as the device _needs_ two |
104 | * flags per packet. | 100 | * flags per packet. |
@@ -114,7 +110,7 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message); | |||
114 | static int gigaset_resume(struct usb_interface *intf); | 110 | static int gigaset_resume(struct usb_interface *intf); |
115 | static int gigaset_pre_reset(struct usb_interface *intf); | 111 | static int gigaset_pre_reset(struct usb_interface *intf); |
116 | 112 | ||
117 | static struct gigaset_driver *driver = NULL; | 113 | static struct gigaset_driver *driver; |
118 | 114 | ||
119 | /* usb specific object needed to register this driver with the usb subsystem */ | 115 | /* usb specific object needed to register this driver with the usb subsystem */ |
120 | static struct usb_driver gigaset_usb_driver = { | 116 | static struct usb_driver gigaset_usb_driver = { |
@@ -141,6 +137,7 @@ struct usb_cardstate { | |||
141 | struct urb *bulk_out_urb; | 137 | struct urb *bulk_out_urb; |
142 | 138 | ||
143 | /* Input buffer */ | 139 | /* Input buffer */ |
140 | unsigned char *rcvbuf; | ||
144 | int rcvbuf_size; | 141 | int rcvbuf_size; |
145 | struct urb *read_urb; | 142 | struct urb *read_urb; |
146 | __u8 int_in_endpointAddr; | 143 | __u8 int_in_endpointAddr; |
@@ -164,13 +161,11 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, | |||
164 | val = tiocm_to_gigaset(new_state); | 161 | val = tiocm_to_gigaset(new_state); |
165 | 162 | ||
166 | gig_dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask); | 163 | gig_dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask); |
167 | // don't use this in an interrupt/BH | ||
168 | r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41, | 164 | r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 7, 0x41, |
169 | (val & 0xff) | ((mask & 0xff) << 8), 0, | 165 | (val & 0xff) | ((mask & 0xff) << 8), 0, |
170 | NULL, 0, 2000 /* timeout? */); | 166 | NULL, 0, 2000 /* timeout? */); |
171 | if (r < 0) | 167 | if (r < 0) |
172 | return r; | 168 | return r; |
173 | //.. | ||
174 | return 0; | 169 | return 0; |
175 | } | 170 | } |
176 | 171 | ||
@@ -220,7 +215,6 @@ static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) | |||
220 | cflag &= CBAUD; | 215 | cflag &= CBAUD; |
221 | 216 | ||
222 | switch (cflag) { | 217 | switch (cflag) { |
223 | //FIXME more values? | ||
224 | case B300: rate = 300; break; | 218 | case B300: rate = 300; break; |
225 | case B600: rate = 600; break; | 219 | case B600: rate = 600; break; |
226 | case B1200: rate = 1200; break; | 220 | case B1200: rate = 1200; break; |
@@ -273,7 +267,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) | |||
273 | /* set the number of stop bits */ | 267 | /* set the number of stop bits */ |
274 | if (cflag & CSTOPB) { | 268 | if (cflag & CSTOPB) { |
275 | if ((cflag & CSIZE) == CS5) | 269 | if ((cflag & CSIZE) == CS5) |
276 | val |= 1; /* 1.5 stop bits */ //FIXME is this okay? | 270 | val |= 1; /* 1.5 stop bits */ |
277 | else | 271 | else |
278 | val |= 2; /* 2 stop bits */ | 272 | val |= 2; /* 2 stop bits */ |
279 | } | 273 | } |
@@ -282,7 +276,7 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) | |||
282 | } | 276 | } |
283 | 277 | ||
284 | 278 | ||
285 | /*================================================================================================================*/ | 279 | /*============================================================================*/ |
286 | static int gigaset_init_bchannel(struct bc_state *bcs) | 280 | static int gigaset_init_bchannel(struct bc_state *bcs) |
287 | { | 281 | { |
288 | /* nothing to do for M10x */ | 282 | /* nothing to do for M10x */ |
@@ -344,7 +338,6 @@ static void gigaset_modem_fill(unsigned long data) | |||
344 | if (write_modem(cs) < 0) { | 338 | if (write_modem(cs) < 0) { |
345 | gig_dbg(DEBUG_OUTPUT, | 339 | gig_dbg(DEBUG_OUTPUT, |
346 | "modem_fill: write_modem failed"); | 340 | "modem_fill: write_modem failed"); |
347 | // FIXME should we tell the LL? | ||
348 | again = 1; /* no callback will be called! */ | 341 | again = 1; /* no callback will be called! */ |
349 | } | 342 | } |
350 | } | 343 | } |
@@ -356,8 +349,8 @@ static void gigaset_modem_fill(unsigned long data) | |||
356 | */ | 349 | */ |
357 | static void gigaset_read_int_callback(struct urb *urb) | 350 | static void gigaset_read_int_callback(struct urb *urb) |
358 | { | 351 | { |
359 | struct inbuf_t *inbuf = urb->context; | 352 | struct cardstate *cs = urb->context; |
360 | struct cardstate *cs = inbuf->cs; | 353 | struct inbuf_t *inbuf = cs->inbuf; |
361 | int status = urb->status; | 354 | int status = urb->status; |
362 | int r; | 355 | int r; |
363 | unsigned numbytes; | 356 | unsigned numbytes; |
@@ -368,7 +361,7 @@ static void gigaset_read_int_callback(struct urb *urb) | |||
368 | numbytes = urb->actual_length; | 361 | numbytes = urb->actual_length; |
369 | 362 | ||
370 | if (numbytes) { | 363 | if (numbytes) { |
371 | src = inbuf->rcvbuf; | 364 | src = cs->hw.usb->rcvbuf; |
372 | if (unlikely(*src)) | 365 | if (unlikely(*src)) |
373 | dev_warn(cs->dev, | 366 | dev_warn(cs->dev, |
374 | "%s: There was no leading 0, but 0x%02x!\n", | 367 | "%s: There was no leading 0, but 0x%02x!\n", |
@@ -440,7 +433,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb) | |||
440 | struct cmdbuf_t *tcb; | 433 | struct cmdbuf_t *tcb; |
441 | unsigned long flags; | 434 | unsigned long flags; |
442 | int count; | 435 | int count; |
443 | int status = -ENOENT; // FIXME | 436 | int status = -ENOENT; |
444 | struct usb_cardstate *ucs = cs->hw.usb; | 437 | struct usb_cardstate *ucs = cs->hw.usb; |
445 | 438 | ||
446 | do { | 439 | do { |
@@ -480,7 +473,9 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb) | |||
480 | ucs->busy = 1; | 473 | ucs->busy = 1; |
481 | 474 | ||
482 | spin_lock_irqsave(&cs->lock, flags); | 475 | spin_lock_irqsave(&cs->lock, flags); |
483 | status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV; | 476 | status = cs->connected ? |
477 | usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : | ||
478 | -ENODEV; | ||
484 | spin_unlock_irqrestore(&cs->lock, flags); | 479 | spin_unlock_irqrestore(&cs->lock, flags); |
485 | 480 | ||
486 | if (status) { | 481 | if (status) { |
@@ -510,8 +505,8 @@ static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, | |||
510 | 505 | ||
511 | if (len <= 0) | 506 | if (len <= 0) |
512 | return 0; | 507 | return 0; |
513 | 508 | cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC); | |
514 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { | 509 | if (!cb) { |
515 | dev_err(cs->dev, "%s: out of memory\n", __func__); | 510 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
516 | return -ENOMEM; | 511 | return -ENOMEM; |
517 | } | 512 | } |
@@ -615,7 +610,7 @@ static int gigaset_initcshw(struct cardstate *cs) | |||
615 | ucs->bulk_out_urb = NULL; | 610 | ucs->bulk_out_urb = NULL; |
616 | ucs->read_urb = NULL; | 611 | ucs->read_urb = NULL; |
617 | tasklet_init(&cs->write_tasklet, | 612 | tasklet_init(&cs->write_tasklet, |
618 | &gigaset_modem_fill, (unsigned long) cs); | 613 | gigaset_modem_fill, (unsigned long) cs); |
619 | 614 | ||
620 | return 1; | 615 | return 1; |
621 | } | 616 | } |
@@ -629,7 +624,7 @@ static int write_modem(struct cardstate *cs) | |||
629 | struct usb_cardstate *ucs = cs->hw.usb; | 624 | struct usb_cardstate *ucs = cs->hw.usb; |
630 | unsigned long flags; | 625 | unsigned long flags; |
631 | 626 | ||
632 | gig_dbg(DEBUG_WRITE, "len: %d...", bcs->tx_skb->len); | 627 | gig_dbg(DEBUG_OUTPUT, "len: %d...", bcs->tx_skb->len); |
633 | 628 | ||
634 | if (!bcs->tx_skb->len) { | 629 | if (!bcs->tx_skb->len) { |
635 | dev_kfree_skb_any(bcs->tx_skb); | 630 | dev_kfree_skb_any(bcs->tx_skb); |
@@ -637,9 +632,7 @@ static int write_modem(struct cardstate *cs) | |||
637 | return -EINVAL; | 632 | return -EINVAL; |
638 | } | 633 | } |
639 | 634 | ||
640 | /* Copy data to bulk out buffer and // FIXME copying not necessary | 635 | /* Copy data to bulk out buffer and transmit data */ |
641 | * transmit data | ||
642 | */ | ||
643 | count = min(bcs->tx_skb->len, (unsigned) ucs->bulk_out_size); | 636 | count = min(bcs->tx_skb->len, (unsigned) ucs->bulk_out_size); |
644 | skb_copy_from_linear_data(bcs->tx_skb, ucs->bulk_out_buffer, count); | 637 | skb_copy_from_linear_data(bcs->tx_skb, ucs->bulk_out_buffer, count); |
645 | skb_pull(bcs->tx_skb, count); | 638 | skb_pull(bcs->tx_skb, count); |
@@ -650,7 +643,8 @@ static int write_modem(struct cardstate *cs) | |||
650 | if (cs->connected) { | 643 | if (cs->connected) { |
651 | usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev, | 644 | usb_fill_bulk_urb(ucs->bulk_out_urb, ucs->udev, |
652 | usb_sndbulkpipe(ucs->udev, | 645 | usb_sndbulkpipe(ucs->udev, |
653 | ucs->bulk_out_endpointAddr & 0x0f), | 646 | ucs->bulk_out_endpointAddr & |
647 | 0x0f), | ||
654 | ucs->bulk_out_buffer, count, | 648 | ucs->bulk_out_buffer, count, |
655 | gigaset_write_bulk_callback, cs); | 649 | gigaset_write_bulk_callback, cs); |
656 | ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC); | 650 | ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC); |
@@ -666,7 +660,7 @@ static int write_modem(struct cardstate *cs) | |||
666 | 660 | ||
667 | if (!bcs->tx_skb->len) { | 661 | if (!bcs->tx_skb->len) { |
668 | /* skb sent completely */ | 662 | /* skb sent completely */ |
669 | gigaset_skb_sent(bcs, bcs->tx_skb); //FIXME also, when ret<0? | 663 | gigaset_skb_sent(bcs, bcs->tx_skb); |
670 | 664 | ||
671 | gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!", | 665 | gig_dbg(DEBUG_INTR, "kfree skb (Adr: %lx)!", |
672 | (unsigned long) bcs->tx_skb); | 666 | (unsigned long) bcs->tx_skb); |
@@ -763,8 +757,8 @@ static int gigaset_probe(struct usb_interface *interface, | |||
763 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 757 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
764 | ucs->rcvbuf_size = buffer_size; | 758 | ucs->rcvbuf_size = buffer_size; |
765 | ucs->int_in_endpointAddr = endpoint->bEndpointAddress; | 759 | ucs->int_in_endpointAddr = endpoint->bEndpointAddress; |
766 | cs->inbuf[0].rcvbuf = kmalloc(buffer_size, GFP_KERNEL); | 760 | ucs->rcvbuf = kmalloc(buffer_size, GFP_KERNEL); |
767 | if (!cs->inbuf[0].rcvbuf) { | 761 | if (!ucs->rcvbuf) { |
768 | dev_err(cs->dev, "Couldn't allocate rcvbuf\n"); | 762 | dev_err(cs->dev, "Couldn't allocate rcvbuf\n"); |
769 | retval = -ENOMEM; | 763 | retval = -ENOMEM; |
770 | goto error; | 764 | goto error; |
@@ -773,9 +767,9 @@ static int gigaset_probe(struct usb_interface *interface, | |||
773 | usb_fill_int_urb(ucs->read_urb, udev, | 767 | usb_fill_int_urb(ucs->read_urb, udev, |
774 | usb_rcvintpipe(udev, | 768 | usb_rcvintpipe(udev, |
775 | endpoint->bEndpointAddress & 0x0f), | 769 | endpoint->bEndpointAddress & 0x0f), |
776 | cs->inbuf[0].rcvbuf, buffer_size, | 770 | ucs->rcvbuf, buffer_size, |
777 | gigaset_read_int_callback, | 771 | gigaset_read_int_callback, |
778 | cs->inbuf + 0, endpoint->bInterval); | 772 | cs, endpoint->bInterval); |
779 | 773 | ||
780 | retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL); | 774 | retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL); |
781 | if (retval) { | 775 | if (retval) { |
@@ -789,7 +783,7 @@ static int gigaset_probe(struct usb_interface *interface, | |||
789 | 783 | ||
790 | if (!gigaset_start(cs)) { | 784 | if (!gigaset_start(cs)) { |
791 | tasklet_kill(&cs->write_tasklet); | 785 | tasklet_kill(&cs->write_tasklet); |
792 | retval = -ENODEV; //FIXME | 786 | retval = -ENODEV; |
793 | goto error; | 787 | goto error; |
794 | } | 788 | } |
795 | return 0; | 789 | return 0; |
@@ -798,11 +792,11 @@ error: | |||
798 | usb_kill_urb(ucs->read_urb); | 792 | usb_kill_urb(ucs->read_urb); |
799 | kfree(ucs->bulk_out_buffer); | 793 | kfree(ucs->bulk_out_buffer); |
800 | usb_free_urb(ucs->bulk_out_urb); | 794 | usb_free_urb(ucs->bulk_out_urb); |
801 | kfree(cs->inbuf[0].rcvbuf); | 795 | kfree(ucs->rcvbuf); |
802 | usb_free_urb(ucs->read_urb); | 796 | usb_free_urb(ucs->read_urb); |
803 | usb_set_intfdata(interface, NULL); | 797 | usb_set_intfdata(interface, NULL); |
804 | ucs->read_urb = ucs->bulk_out_urb = NULL; | 798 | ucs->read_urb = ucs->bulk_out_urb = NULL; |
805 | cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; | 799 | ucs->rcvbuf = ucs->bulk_out_buffer = NULL; |
806 | usb_put_dev(ucs->udev); | 800 | usb_put_dev(ucs->udev); |
807 | ucs->udev = NULL; | 801 | ucs->udev = NULL; |
808 | ucs->interface = NULL; | 802 | ucs->interface = NULL; |
@@ -831,10 +825,10 @@ static void gigaset_disconnect(struct usb_interface *interface) | |||
831 | 825 | ||
832 | kfree(ucs->bulk_out_buffer); | 826 | kfree(ucs->bulk_out_buffer); |
833 | usb_free_urb(ucs->bulk_out_urb); | 827 | usb_free_urb(ucs->bulk_out_urb); |
834 | kfree(cs->inbuf[0].rcvbuf); | 828 | kfree(ucs->rcvbuf); |
835 | usb_free_urb(ucs->read_urb); | 829 | usb_free_urb(ucs->read_urb); |
836 | ucs->read_urb = ucs->bulk_out_urb = NULL; | 830 | ucs->read_urb = ucs->bulk_out_urb = NULL; |
837 | cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; | 831 | ucs->rcvbuf = ucs->bulk_out_buffer = NULL; |
838 | 832 | ||
839 | usb_put_dev(ucs->udev); | 833 | usb_put_dev(ucs->udev); |
840 | ucs->interface = NULL; | 834 | ucs->interface = NULL; |
@@ -916,9 +910,10 @@ static int __init usb_gigaset_init(void) | |||
916 | int result; | 910 | int result; |
917 | 911 | ||
918 | /* allocate memory for our driver state and intialize it */ | 912 | /* allocate memory for our driver state and intialize it */ |
919 | if ((driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, | 913 | driver = gigaset_initdriver(GIGASET_MINOR, GIGASET_MINORS, |
920 | GIGASET_MODULENAME, GIGASET_DEVNAME, | 914 | GIGASET_MODULENAME, GIGASET_DEVNAME, |
921 | &ops, THIS_MODULE)) == NULL) | 915 | &ops, THIS_MODULE); |
916 | if (driver == NULL) | ||
922 | goto error; | 917 | goto error; |
923 | 918 | ||
924 | /* register this driver with the USB subsystem */ | 919 | /* register this driver with the USB subsystem */ |