2 * USB driver for Gigaset 307x directly or using M105 Data.
4 * Copyright (c) 2001 by Stefan Eilers
5 * and Hansjoerg Lipp <hjlipp@web.de>.
7 * This driver was derived from the USB skeleton driver by
8 * Greg Kroah-Hartman <greg@kroah.com>
10 * =====================================================================
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 * =====================================================================
19 #include <linux/usb.h>
20 #include <linux/module.h>
21 #include <linux/moduleparam.h>
23 /* Version Information */
24 #define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Stefan Eilers"
25 #define DRIVER_DESC "USB Driver for Gigaset 307x using M105"
27 /* Module parameters */
29 static int startmode
= SM_ISDN
;
30 static int cidmode
= 1;
32 module_param(startmode
, int, S_IRUGO
);
33 module_param(cidmode
, int, S_IRUGO
);
34 MODULE_PARM_DESC(startmode
, "start in isdn4linux mode");
35 MODULE_PARM_DESC(cidmode
, "Call-ID mode");
37 #define GIGASET_MINORS 1
38 #define GIGASET_MINOR 8
39 #define GIGASET_MODULENAME "usb_gigaset"
40 #define GIGASET_DEVNAME "ttyGU"
42 /* length limit according to Siemens 3070usb-protokoll.doc ch. 2.1 */
43 #define IF_WRITEBUF 264
45 /* Values for the Gigaset M105 Data */
46 #define USB_M105_VENDOR_ID 0x0681
47 #define USB_M105_PRODUCT_ID 0x0009
49 /* table of devices that work with this driver */
50 static const struct usb_device_id gigaset_table
[] = {
51 { USB_DEVICE(USB_M105_VENDOR_ID
, USB_M105_PRODUCT_ID
) },
52 { } /* Terminating entry */
55 MODULE_DEVICE_TABLE(usb
, gigaset_table
);
58 /* functions called if a device of this driver is connected/disconnected */
59 static int gigaset_probe(struct usb_interface
*interface
,
60 const struct usb_device_id
*id
);
61 static void gigaset_disconnect(struct usb_interface
*interface
);
63 /* functions called before/after suspend */
64 static int gigaset_suspend(struct usb_interface
*intf
, pm_message_t message
);
65 static int gigaset_resume(struct usb_interface
*intf
);
66 static int gigaset_pre_reset(struct usb_interface
*intf
);
68 static struct gigaset_driver
*driver
;
70 /* usb specific object needed to register this driver with the usb subsystem */
71 static struct usb_driver gigaset_usb_driver
= {
72 .name
= GIGASET_MODULENAME
,
73 .probe
= gigaset_probe
,
74 .disconnect
= gigaset_disconnect
,
75 .id_table
= gigaset_table
,
76 .suspend
= gigaset_suspend
,
77 .resume
= gigaset_resume
,
78 .reset_resume
= gigaset_resume
,
79 .pre_reset
= gigaset_pre_reset
,
80 .post_reset
= gigaset_resume
,
83 struct usb_cardstate
{
84 struct usb_device
*udev
; /* usb device pointer */
85 struct usb_interface
*interface
; /* interface for this device */
86 int busy
; /* bulk output in progress */
89 unsigned char *bulk_out_buffer
;
91 __u8 bulk_out_endpointAddr
;
92 struct urb
*bulk_out_urb
;
95 unsigned char *rcvbuf
;
98 __u8 int_in_endpointAddr
;
100 char bchars
[6]; /* for request 0x19 */
103 static inline unsigned tiocm_to_gigaset(unsigned state
)
105 return ((state
& TIOCM_DTR
) ? 1 : 0) | ((state
& TIOCM_RTS
) ? 2 : 0);
108 static int gigaset_set_modem_ctrl(struct cardstate
*cs
, unsigned old_state
,
111 struct usb_device
*udev
= cs
->hw
.usb
->udev
;
115 mask
= tiocm_to_gigaset(old_state
^ new_state
);
116 val
= tiocm_to_gigaset(new_state
);
118 gig_dbg(DEBUG_USBREQ
, "set flags 0x%02x with mask 0x%02x", val
, mask
);
119 r
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), 7, 0x41,
120 (val
& 0xff) | ((mask
& 0xff) << 8), 0,
121 NULL
, 0, 2000 /* timeout? */);
128 * Set M105 configuration value
129 * using undocumented device commands reverse engineered from USB traces
130 * of the Siemens Windows driver
132 static int set_value(struct cardstate
*cs
, u8 req
, u16 val
)
134 struct usb_device
*udev
= cs
->hw
.usb
->udev
;
137 gig_dbg(DEBUG_USBREQ
, "request %02x (%04x)",
138 (unsigned)req
, (unsigned)val
);
139 r
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), 0x12, 0x41,
140 0xf /*?*/, 0, NULL
, 0, 2000 /*?*/);
141 /* no idea what this does */
143 dev_err(&udev
->dev
, "error %d on request 0x12\n", -r
);
147 r
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), req
, 0x41,
148 val
, 0, NULL
, 0, 2000 /*?*/);
150 dev_err(&udev
->dev
, "error %d on request 0x%02x\n",
153 r2
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), 0x19, 0x41,
154 0, 0, cs
->hw
.usb
->bchars
, 6, 2000 /*?*/);
156 dev_err(&udev
->dev
, "error %d on request 0x19\n", -r2
);
158 return r
< 0 ? r
: (r2
< 0 ? r2
: 0);
162 * set the baud rate on the internal serial adapter
163 * using the undocumented parameter setting command
165 static int gigaset_baud_rate(struct cardstate
*cs
, unsigned cflag
)
173 case B300
: rate
= 300; break;
174 case B600
: rate
= 600; break;
175 case B1200
: rate
= 1200; break;
176 case B2400
: rate
= 2400; break;
177 case B4800
: rate
= 4800; break;
178 case B9600
: rate
= 9600; break;
179 case B19200
: rate
= 19200; break;
180 case B38400
: rate
= 38400; break;
181 case B57600
: rate
= 57600; break;
182 case B115200
: rate
= 115200; break;
185 dev_err(cs
->dev
, "unsupported baudrate request 0x%x,"
186 " using default of B9600\n", cflag
);
189 val
= 0x383fff / rate
+ 1;
191 return set_value(cs
, 1, val
);
195 * set the line format on the internal serial adapter
196 * using the undocumented parameter setting command
198 static int gigaset_set_line_ctrl(struct cardstate
*cs
, unsigned cflag
)
204 val
|= (cflag
& PARODD
) ? 0x10 : 0x20;
206 /* set the number of data bits */
207 switch (cflag
& CSIZE
) {
209 val
|= 5 << 8; break;
211 val
|= 6 << 8; break;
213 val
|= 7 << 8; break;
215 val
|= 8 << 8; break;
217 dev_err(cs
->dev
, "CSIZE was not CS5-CS8, using default of 8\n");
222 /* set the number of stop bits */
223 if (cflag
& CSTOPB
) {
224 if ((cflag
& CSIZE
) == CS5
)
225 val
|= 1; /* 1.5 stop bits */
227 val
|= 2; /* 2 stop bits */
230 return set_value(cs
, 3, val
);
234 /*============================================================================*/
235 static int gigaset_init_bchannel(struct bc_state
*bcs
)
237 /* nothing to do for M10x */
238 gigaset_bchannel_up(bcs
);
242 static int gigaset_close_bchannel(struct bc_state
*bcs
)
244 /* nothing to do for M10x */
245 gigaset_bchannel_down(bcs
);
249 static int write_modem(struct cardstate
*cs
);
250 static int send_cb(struct cardstate
*cs
, struct cmdbuf_t
*cb
);
253 /* Write tasklet handler: Continue sending current skb, or send command, or
254 * start sending an skb from the send queue.
256 static void gigaset_modem_fill(unsigned long data
)
258 struct cardstate
*cs
= (struct cardstate
*) data
;
259 struct bc_state
*bcs
= &cs
->bcs
[0]; /* only one channel */
263 gig_dbg(DEBUG_OUTPUT
, "modem_fill");
265 if (cs
->hw
.usb
->busy
) {
266 gig_dbg(DEBUG_OUTPUT
, "modem_fill: busy");
272 if (!bcs
->tx_skb
) { /* no skb is being sent */
274 if (cb
) { /* commands to send? */
275 gig_dbg(DEBUG_OUTPUT
, "modem_fill: cb");
276 if (send_cb(cs
, cb
) < 0) {
277 gig_dbg(DEBUG_OUTPUT
,
278 "modem_fill: send_cb failed");
279 again
= 1; /* no callback will be
282 } else { /* skbs to send? */
283 bcs
->tx_skb
= skb_dequeue(&bcs
->squeue
);
286 "Dequeued skb (Adr: %lx)!",
287 (unsigned long) bcs
->tx_skb
);
292 gig_dbg(DEBUG_OUTPUT
, "modem_fill: tx_skb");
293 if (write_modem(cs
) < 0) {
294 gig_dbg(DEBUG_OUTPUT
,
295 "modem_fill: write_modem failed");
296 again
= 1; /* no callback will be called! */
303 * Interrupt Input URB completion routine
305 static void gigaset_read_int_callback(struct urb
*urb
)
307 struct cardstate
*cs
= urb
->context
;
308 struct inbuf_t
*inbuf
= cs
->inbuf
;
309 int status
= urb
->status
;
316 numbytes
= urb
->actual_length
;
319 src
= cs
->hw
.usb
->rcvbuf
;
322 "%s: There was no leading 0, but 0x%02x!\n",
323 __func__
, (unsigned) *src
);
324 ++src
; /* skip leading 0x00 */
326 if (gigaset_fill_inbuf(inbuf
, src
, numbytes
)) {
327 gig_dbg(DEBUG_INTR
, "%s-->BH", __func__
);
328 gigaset_schedule_event(inbuf
->cs
);
331 gig_dbg(DEBUG_INTR
, "Received zero block length");
333 /* The urb might have been killed. */
334 gig_dbg(DEBUG_ANY
, "%s - nonzero status received: %d",
336 if (status
== -ENOENT
|| status
== -ESHUTDOWN
)
337 /* killed or endpoint shutdown: don't resubmit */
342 spin_lock_irqsave(&cs
->lock
, flags
);
343 if (!cs
->connected
) {
344 spin_unlock_irqrestore(&cs
->lock
, flags
);
345 pr_err("%s: disconnected\n", __func__
);
348 r
= usb_submit_urb(urb
, GFP_ATOMIC
);
349 spin_unlock_irqrestore(&cs
->lock
, flags
);
351 dev_err(cs
->dev
, "error %d resubmitting URB\n", -r
);
355 /* This callback routine is called when data was transmitted to the device. */
356 static void gigaset_write_bulk_callback(struct urb
*urb
)
358 struct cardstate
*cs
= urb
->context
;
359 int status
= urb
->status
;
363 case 0: /* normal completion */
365 case -ENOENT
: /* killed */
366 gig_dbg(DEBUG_ANY
, "%s: killed", __func__
);
367 cs
->hw
.usb
->busy
= 0;
370 dev_err(cs
->dev
, "bulk transfer failed (status %d)\n",
372 /* That's all we can do. Communication problems
373 are handled by timeouts or network protocols. */
376 spin_lock_irqsave(&cs
->lock
, flags
);
377 if (!cs
->connected
) {
378 pr_err("%s: disconnected\n", __func__
);
380 cs
->hw
.usb
->busy
= 0;
381 tasklet_schedule(&cs
->write_tasklet
);
383 spin_unlock_irqrestore(&cs
->lock
, flags
);
386 static int send_cb(struct cardstate
*cs
, struct cmdbuf_t
*cb
)
388 struct cmdbuf_t
*tcb
;
391 int status
= -ENOENT
;
392 struct usb_cardstate
*ucs
= cs
->hw
.usb
;
398 spin_lock_irqsave(&cs
->cmdlock
, flags
);
399 cs
->cmdbytes
-= cs
->curlen
;
400 gig_dbg(DEBUG_OUTPUT
, "send_cb: sent %u bytes, %u left",
401 cs
->curlen
, cs
->cmdbytes
);
402 cs
->cmdbuf
= cb
= cb
->next
;
405 cs
->curlen
= cb
->len
;
407 cs
->lastcmdbuf
= NULL
;
410 spin_unlock_irqrestore(&cs
->cmdlock
, flags
);
412 if (tcb
->wake_tasklet
)
413 tasklet_schedule(tcb
->wake_tasklet
);
417 count
= min(cb
->len
, ucs
->bulk_out_size
);
418 gig_dbg(DEBUG_OUTPUT
, "send_cb: send %d bytes", count
);
420 usb_fill_bulk_urb(ucs
->bulk_out_urb
, ucs
->udev
,
421 usb_sndbulkpipe(ucs
->udev
,
422 ucs
->bulk_out_endpointAddr
& 0x0f),
423 cb
->buf
+ cb
->offset
, count
,
424 gigaset_write_bulk_callback
, cs
);
430 spin_lock_irqsave(&cs
->lock
, flags
);
431 status
= cs
->connected
?
432 usb_submit_urb(ucs
->bulk_out_urb
, GFP_ATOMIC
) :
434 spin_unlock_irqrestore(&cs
->lock
, flags
);
439 "could not submit urb (error %d)\n",
441 cb
->len
= 0; /* skip urb => remove cb+wakeup
442 in next loop cycle */
445 } while (cb
&& status
); /* next command on error */
450 /* Send command to device. */
451 static int gigaset_write_cmd(struct cardstate
*cs
, struct cmdbuf_t
*cb
)
455 gigaset_dbg_buffer(cs
->mstate
!= MS_LOCKED
?
456 DEBUG_TRANSCMD
: DEBUG_LOCKCMD
,
457 "CMD Transmit", cb
->len
, cb
->buf
);
459 spin_lock_irqsave(&cs
->cmdlock
, flags
);
460 cb
->prev
= cs
->lastcmdbuf
;
462 cs
->lastcmdbuf
->next
= cb
;
465 cs
->curlen
= cb
->len
;
467 cs
->cmdbytes
+= cb
->len
;
469 spin_unlock_irqrestore(&cs
->cmdlock
, flags
);
471 spin_lock_irqsave(&cs
->lock
, flags
);
473 tasklet_schedule(&cs
->write_tasklet
);
474 spin_unlock_irqrestore(&cs
->lock
, flags
);
478 static int gigaset_write_room(struct cardstate
*cs
)
482 bytes
= cs
->cmdbytes
;
483 return bytes
< IF_WRITEBUF
? IF_WRITEBUF
- bytes
: 0;
486 static int gigaset_chars_in_buffer(struct cardstate
*cs
)
492 * set the break characters on the internal serial adapter
493 * using undocumented device commands reverse engineered from USB traces
494 * of the Siemens Windows driver
496 static int gigaset_brkchars(struct cardstate
*cs
, const unsigned char buf
[6])
498 struct usb_device
*udev
= cs
->hw
.usb
->udev
;
500 gigaset_dbg_buffer(DEBUG_USBREQ
, "brkchars", 6, buf
);
501 memcpy(cs
->hw
.usb
->bchars
, buf
, 6);
502 return usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), 0x19, 0x41,
503 0, 0, &buf
, 6, 2000);
506 static int gigaset_freebcshw(struct bc_state
*bcs
)
512 /* Initialize the b-channel structure */
513 static int gigaset_initbcshw(struct bc_state
*bcs
)
520 static void gigaset_reinitbcshw(struct bc_state
*bcs
)
522 /* nothing to do for M10x */
525 static void gigaset_freecshw(struct cardstate
*cs
)
527 tasklet_kill(&cs
->write_tasklet
);
531 static int gigaset_initcshw(struct cardstate
*cs
)
533 struct usb_cardstate
*ucs
;
536 kmalloc(sizeof(struct usb_cardstate
), GFP_KERNEL
);
538 pr_err("out of memory\n");
546 ucs
->bchars
[4] = 0x11;
547 ucs
->bchars
[5] = 0x13;
548 ucs
->bulk_out_buffer
= NULL
;
549 ucs
->bulk_out_urb
= NULL
;
550 ucs
->read_urb
= NULL
;
551 tasklet_init(&cs
->write_tasklet
,
552 gigaset_modem_fill
, (unsigned long) cs
);
557 /* Send data from current skb to the device. */
558 static int write_modem(struct cardstate
*cs
)
562 struct bc_state
*bcs
= &cs
->bcs
[0]; /* only one channel */
563 struct usb_cardstate
*ucs
= cs
->hw
.usb
;
566 gig_dbg(DEBUG_OUTPUT
, "len: %d...", bcs
->tx_skb
->len
);
568 if (!bcs
->tx_skb
->len
) {
569 dev_kfree_skb_any(bcs
->tx_skb
);
574 /* Copy data to bulk out buffer and transmit data */
575 count
= min(bcs
->tx_skb
->len
, (unsigned) ucs
->bulk_out_size
);
576 skb_copy_from_linear_data(bcs
->tx_skb
, ucs
->bulk_out_buffer
, count
);
577 skb_pull(bcs
->tx_skb
, count
);
579 gig_dbg(DEBUG_OUTPUT
, "write_modem: send %d bytes", count
);
581 spin_lock_irqsave(&cs
->lock
, flags
);
583 usb_fill_bulk_urb(ucs
->bulk_out_urb
, ucs
->udev
,
584 usb_sndbulkpipe(ucs
->udev
,
585 ucs
->bulk_out_endpointAddr
&
587 ucs
->bulk_out_buffer
, count
,
588 gigaset_write_bulk_callback
, cs
);
589 ret
= usb_submit_urb(ucs
->bulk_out_urb
, GFP_ATOMIC
);
593 spin_unlock_irqrestore(&cs
->lock
, flags
);
596 dev_err(cs
->dev
, "could not submit urb (error %d)\n", -ret
);
600 if (!bcs
->tx_skb
->len
) {
601 /* skb sent completely */
602 gigaset_skb_sent(bcs
, bcs
->tx_skb
);
604 gig_dbg(DEBUG_INTR
, "kfree skb (Adr: %lx)!",
605 (unsigned long) bcs
->tx_skb
);
606 dev_kfree_skb_any(bcs
->tx_skb
);
613 static int gigaset_probe(struct usb_interface
*interface
,
614 const struct usb_device_id
*id
)
617 struct usb_device
*udev
= interface_to_usbdev(interface
);
618 struct usb_host_interface
*hostif
= interface
->cur_altsetting
;
619 struct cardstate
*cs
= NULL
;
620 struct usb_cardstate
*ucs
= NULL
;
621 struct usb_endpoint_descriptor
*endpoint
;
624 gig_dbg(DEBUG_ANY
, "%s: Check if device matches ...", __func__
);
626 /* See if the device offered us matches what we can accept */
627 if ((le16_to_cpu(udev
->descriptor
.idVendor
) != USB_M105_VENDOR_ID
) ||
628 (le16_to_cpu(udev
->descriptor
.idProduct
) != USB_M105_PRODUCT_ID
)) {
629 gig_dbg(DEBUG_ANY
, "device ID (0x%x, 0x%x) not for me - skip",
630 le16_to_cpu(udev
->descriptor
.idVendor
),
631 le16_to_cpu(udev
->descriptor
.idProduct
));
634 if (hostif
->desc
.bInterfaceNumber
!= 0) {
635 gig_dbg(DEBUG_ANY
, "interface %d not for me - skip",
636 hostif
->desc
.bInterfaceNumber
);
639 if (hostif
->desc
.bAlternateSetting
!= 0) {
640 dev_notice(&udev
->dev
, "unsupported altsetting %d - skip",
641 hostif
->desc
.bAlternateSetting
);
644 if (hostif
->desc
.bInterfaceClass
!= 255) {
645 dev_notice(&udev
->dev
, "unsupported interface class %d - skip",
646 hostif
->desc
.bInterfaceClass
);
650 dev_info(&udev
->dev
, "%s: Device matched ... !\n", __func__
);
652 /* allocate memory for our device state and intialize it */
653 cs
= gigaset_initcs(driver
, 1, 1, 0, cidmode
, GIGASET_MODULENAME
);
658 /* save off device structure ptrs for later use */
661 ucs
->interface
= interface
;
662 cs
->dev
= &interface
->dev
;
664 /* save address of controller structure */
665 usb_set_intfdata(interface
, cs
);
667 endpoint
= &hostif
->endpoint
[0].desc
;
669 buffer_size
= le16_to_cpu(endpoint
->wMaxPacketSize
);
670 ucs
->bulk_out_size
= buffer_size
;
671 ucs
->bulk_out_endpointAddr
= endpoint
->bEndpointAddress
;
672 ucs
->bulk_out_buffer
= kmalloc(buffer_size
, GFP_KERNEL
);
673 if (!ucs
->bulk_out_buffer
) {
674 dev_err(cs
->dev
, "Couldn't allocate bulk_out_buffer\n");
679 ucs
->bulk_out_urb
= usb_alloc_urb(0, GFP_KERNEL
);
680 if (!ucs
->bulk_out_urb
) {
681 dev_err(cs
->dev
, "Couldn't allocate bulk_out_urb\n");
686 endpoint
= &hostif
->endpoint
[1].desc
;
690 ucs
->read_urb
= usb_alloc_urb(0, GFP_KERNEL
);
691 if (!ucs
->read_urb
) {
692 dev_err(cs
->dev
, "No free urbs available\n");
696 buffer_size
= le16_to_cpu(endpoint
->wMaxPacketSize
);
697 ucs
->rcvbuf_size
= buffer_size
;
698 ucs
->int_in_endpointAddr
= endpoint
->bEndpointAddress
;
699 ucs
->rcvbuf
= kmalloc(buffer_size
, GFP_KERNEL
);
701 dev_err(cs
->dev
, "Couldn't allocate rcvbuf\n");
705 /* Fill the interrupt urb and send it to the core */
706 usb_fill_int_urb(ucs
->read_urb
, udev
,
708 endpoint
->bEndpointAddress
& 0x0f),
709 ucs
->rcvbuf
, buffer_size
,
710 gigaset_read_int_callback
,
711 cs
, endpoint
->bInterval
);
713 retval
= usb_submit_urb(ucs
->read_urb
, GFP_KERNEL
);
715 dev_err(cs
->dev
, "Could not submit URB (error %d)\n", -retval
);
719 /* tell common part that the device is ready */
720 if (startmode
== SM_LOCKED
)
721 cs
->mstate
= MS_LOCKED
;
723 if (!gigaset_start(cs
)) {
724 tasklet_kill(&cs
->write_tasklet
);
731 usb_kill_urb(ucs
->read_urb
);
732 kfree(ucs
->bulk_out_buffer
);
733 usb_free_urb(ucs
->bulk_out_urb
);
735 usb_free_urb(ucs
->read_urb
);
736 usb_set_intfdata(interface
, NULL
);
737 ucs
->read_urb
= ucs
->bulk_out_urb
= NULL
;
738 ucs
->rcvbuf
= ucs
->bulk_out_buffer
= NULL
;
739 usb_put_dev(ucs
->udev
);
741 ucs
->interface
= NULL
;
746 static void gigaset_disconnect(struct usb_interface
*interface
)
748 struct cardstate
*cs
;
749 struct usb_cardstate
*ucs
;
751 cs
= usb_get_intfdata(interface
);
754 dev_info(cs
->dev
, "disconnecting Gigaset USB adapter\n");
756 usb_kill_urb(ucs
->read_urb
);
760 usb_set_intfdata(interface
, NULL
);
761 tasklet_kill(&cs
->write_tasklet
);
763 usb_kill_urb(ucs
->bulk_out_urb
);
765 kfree(ucs
->bulk_out_buffer
);
766 usb_free_urb(ucs
->bulk_out_urb
);
768 usb_free_urb(ucs
->read_urb
);
769 ucs
->read_urb
= ucs
->bulk_out_urb
= NULL
;
770 ucs
->rcvbuf
= ucs
->bulk_out_buffer
= NULL
;
772 usb_put_dev(ucs
->udev
);
773 ucs
->interface
= NULL
;
780 * This function is called before the USB connection is suspended or reset.
782 static int gigaset_suspend(struct usb_interface
*intf
, pm_message_t message
)
784 struct cardstate
*cs
= usb_get_intfdata(intf
);
787 cs
->connected
= 0; /* prevent rescheduling */
788 usb_kill_urb(cs
->hw
.usb
->read_urb
);
789 tasklet_kill(&cs
->write_tasklet
);
790 usb_kill_urb(cs
->hw
.usb
->bulk_out_urb
);
792 gig_dbg(DEBUG_SUSPEND
, "suspend complete");
797 * This function is called after the USB connection has been resumed or reset.
799 static int gigaset_resume(struct usb_interface
*intf
)
801 struct cardstate
*cs
= usb_get_intfdata(intf
);
804 /* resubmit interrupt URB */
806 rc
= usb_submit_urb(cs
->hw
.usb
->read_urb
, GFP_KERNEL
);
808 dev_err(cs
->dev
, "Could not submit read URB (error %d)\n", -rc
);
812 gig_dbg(DEBUG_SUSPEND
, "resume complete");
817 * This function is called before the USB connection is reset.
819 static int gigaset_pre_reset(struct usb_interface
*intf
)
821 /* same as suspend */
822 return gigaset_suspend(intf
, PMSG_ON
);
825 static const struct gigaset_ops ops
= {
828 gigaset_chars_in_buffer
,
830 gigaset_init_bchannel
,
831 gigaset_close_bchannel
,
837 gigaset_set_modem_ctrl
,
839 gigaset_set_line_ctrl
,
840 gigaset_m10x_send_skb
,
845 * This function is called while kernel-module is loaded
847 static int __init
usb_gigaset_init(void)
851 /* allocate memory for our driver state and intialize it */
852 driver
= gigaset_initdriver(GIGASET_MINOR
, GIGASET_MINORS
,
853 GIGASET_MODULENAME
, GIGASET_DEVNAME
,
858 /* register this driver with the USB subsystem */
859 result
= usb_register(&gigaset_usb_driver
);
861 pr_err("error %d registering USB driver\n", -result
);
865 pr_info(DRIVER_DESC
"\n");
870 gigaset_freedriver(driver
);
876 * This function is called while unloading the kernel-module
878 static void __exit
usb_gigaset_exit(void)
882 gigaset_blockdriver(driver
); /* => probe will fail
883 * => no gigaset_start any more
886 /* stop all connected devices */
887 for (i
= 0; i
< driver
->minors
; i
++)
888 gigaset_shutdown(driver
->cs
+ i
);
890 /* from now on, no isdn callback should be possible */
892 /* deregister this driver with the USB subsystem */
893 usb_deregister(&gigaset_usb_driver
);
894 /* this will call the disconnect-callback */
895 /* from now on, no disconnect/probe callback should be running */
897 gigaset_freedriver(driver
);
902 module_init(usb_gigaset_init
);
903 module_exit(usb_gigaset_exit
);
905 MODULE_AUTHOR(DRIVER_AUTHOR
);
906 MODULE_DESCRIPTION(DRIVER_DESC
);
908 MODULE_LICENSE("GPL");