Lines Matching +full:usb +full:- +full:plugin

1 // SPDX-License-Identifier: GPL-2.0+
3 * usbatm.c - Generic USB xDSL driver core
13 * 1.7+: - See the check-in logs
15 * 1.6: - No longer opens a connection if the firmware is not loaded
16 * - Added support for the speedtouch 330
17 * - Removed the limit on the number of devices
18 * - Module now autoloads on device plugin
19 * - Merged relevant parts of sarlib
20 * - Replaced the kernel thread with a tasklet
21 * - New packet transmission code
22 * - Changed proc file contents
23 * - Fixed all known SMP races
24 * - Many fixes and cleanups
25 * - Various fixes by Oliver Neukum (oliver@neukum.name)
27 * 1.5A: - Version for inclusion in 2.5 series kernel
28 * - Modifications by Richard Purdie (rpurdie@rpsys.net)
29 * - made compatible with kernel 2.5.6 onwards by changing
30 * usbatm_usb_send_data_context->urb to a pointer and adding code
32 * - remove_wait_queue() added to usbatm_atm_processqueue_thread()
34 * 1.5: - fixed memory leak when atmsar_decode_aal5 returned NULL.
37 * 1.4: - changed the spin_lock() under interrupt to spin_lock_irqsave()
38 * - unlink all active send urbs of a vcc that is being closed.
40 * 1.3.1: - added the version number
42 * 1.3: - Added multiple send urb support
43 * - fixed memory leak and vcc->tx_inuse starvation bug
46 * 1.2: - Fixed race condition in usbatm_usb_send_data()
47 * 1.1: - Turned off packet debugging
82 #define DRIVER_DESC "Generic USB ATM/DSL I/O"
94 #define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
105 "Number of urbs used for reception (range: 0-"
111 "Number of urbs used for transmission (range: 0-"
117 "Size of the buffers used for reception, in bytes (range: 1-"
123 "Size of the buffers used for transmission, in bytes (range: 1-"
150 #define UDSL_SKB(x) ((struct usbatm_control *)(x)->cb)
179 length += ATM_CELL_PAYLOAD - 1 + ATM_AAL5_TRAILER; in usbatm_pdu_length()
180 return length - length % ATM_CELL_PAYLOAD; in usbatm_pdu_length()
185 if (vcc->pop) in usbatm_pop()
186 vcc->pop(vcc, skb); in usbatm_pop()
200 spin_lock_irq(&channel->lock); in usbatm_pop_urb()
201 if (list_empty(&channel->list)) { in usbatm_pop_urb()
202 spin_unlock_irq(&channel->lock); in usbatm_pop_urb()
206 urb = list_entry(channel->list.next, struct urb, urb_list); in usbatm_pop_urb()
207 list_del(&urb->urb_list); in usbatm_pop_urb()
208 spin_unlock_irq(&channel->lock); in usbatm_pop_urb()
215 struct usbatm_channel *channel = urb->context; in usbatm_submit_urb()
219 __func__, urb, urb->transfer_buffer_length); */ in usbatm_submit_urb()
224 atm_warn(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n", in usbatm_submit_urb()
228 urb->status = -EAGAIN; in usbatm_submit_urb()
229 spin_lock_irq(&channel->lock); in usbatm_submit_urb()
232 list_add(&urb->urb_list, &channel->list); in usbatm_submit_urb()
234 spin_unlock_irq(&channel->lock); in usbatm_submit_urb()
237 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS)); in usbatm_submit_urb()
245 struct usbatm_channel *channel = urb->context; in usbatm_complete()
247 int status = urb->status; in usbatm_complete()
250 __func__, urb, status, urb->actual_length); */ in usbatm_complete()
253 spin_lock_irqsave(&channel->lock, flags); in usbatm_complete()
256 list_add_tail(&urb->urb_list, &channel->list); in usbatm_complete()
258 spin_unlock_irqrestore(&channel->lock, flags); in usbatm_complete()
261 (!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) || in usbatm_complete()
262 status != -EILSEQ)) { in usbatm_complete()
263 if (status == -ESHUTDOWN) in usbatm_complete()
267 atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n", in usbatm_complete()
270 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS)); in usbatm_complete()
272 tasklet_schedule(&channel->tasklet); in usbatm_complete()
285 list_for_each_entry(vcc_data, &instance->vcc_list, list) in usbatm_find_vcc()
286 if ((vcc_data->vci == vci) && (vcc_data->vpi == vpi)) in usbatm_find_vcc()
299 if ((vci != instance->cached_vci) || (vpi != instance->cached_vpi)) { in usbatm_extract_one_cell()
300 instance->cached_vpi = vpi; in usbatm_extract_one_cell()
301 instance->cached_vci = vci; in usbatm_extract_one_cell()
303 instance->cached_vcc = usbatm_find_vcc(instance, vpi, vci); in usbatm_extract_one_cell()
305 if (!instance->cached_vcc) in usbatm_extract_one_cell()
309 if (!instance->cached_vcc) in usbatm_extract_one_cell()
312 vcc = instance->cached_vcc->vcc; in usbatm_extract_one_cell()
314 /* OAM F5 end-to-end */ in usbatm_extract_one_cell()
319 atomic_inc(&vcc->stats->rx_err); in usbatm_extract_one_cell()
323 sarb = instance->cached_vcc->sarb; in usbatm_extract_one_cell()
325 if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) { in usbatm_extract_one_cell()
326 atm_rldbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n", in usbatm_extract_one_cell()
327 __func__, sarb->len, vcc); in usbatm_extract_one_cell()
340 length = (source[ATM_CELL_SIZE - 6] << 8) + source[ATM_CELL_SIZE - 5]; in usbatm_extract_one_cell()
346 atomic_inc(&vcc->stats->rx_err); in usbatm_extract_one_cell()
352 if (sarb->len < pdu_length) { in usbatm_extract_one_cell()
353 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n", in usbatm_extract_one_cell()
354 __func__, pdu_length, sarb->len, vcc); in usbatm_extract_one_cell()
355 atomic_inc(&vcc->stats->rx_err); in usbatm_extract_one_cell()
359 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) { in usbatm_extract_one_cell()
362 atomic_inc(&vcc->stats->rx_err); in usbatm_extract_one_cell()
366 vdbg(&instance->usb_intf->dev, in usbatm_extract_one_cell()
375 atomic_inc(&vcc->stats->rx_drop); in usbatm_extract_one_cell()
379 vdbg(&instance->usb_intf->dev, in usbatm_extract_one_cell()
380 "%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", in usbatm_extract_one_cell()
381 __func__, skb, skb->truesize); in usbatm_extract_one_cell()
383 if (!atm_charge(vcc, skb->truesize)) { in usbatm_extract_one_cell()
384 atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", in usbatm_extract_one_cell()
385 __func__, skb->truesize); in usbatm_extract_one_cell()
391 skb_tail_pointer(sarb) - pdu_length, in usbatm_extract_one_cell()
395 vdbg(&instance->usb_intf->dev, in usbatm_extract_one_cell()
396 "%s: sending skb 0x%p, skb->len %u, skb->truesize %u", in usbatm_extract_one_cell()
397 __func__, skb, skb->len, skb->truesize); in usbatm_extract_one_cell()
399 PACKETDEBUG(instance, skb->data, skb->len); in usbatm_extract_one_cell()
401 vcc->push(vcc, skb); in usbatm_extract_one_cell()
403 atomic_inc(&vcc->stats->rx); in usbatm_extract_one_cell()
412 unsigned int stride = instance->rx_channel.stride; in usbatm_extract_cells()
413 unsigned int buf_usage = instance->buf_usage; in usbatm_extract_cells()
420 unsigned char *cell_buf = instance->cell_buf; in usbatm_extract_cells()
421 unsigned int space_left = stride - buf_usage; in usbatm_extract_cells()
427 avail_data -= space_left; in usbatm_extract_cells()
429 instance->buf_usage = 0; in usbatm_extract_cells()
433 instance->buf_usage = buf_usage + avail_data; in usbatm_extract_cells()
438 for (; avail_data >= stride; avail_data -= stride, source += stride) in usbatm_extract_cells()
442 /* length was not a multiple of stride - in usbatm_extract_cells()
444 memcpy(instance->cell_buf, source, avail_data); in usbatm_extract_cells()
445 instance->buf_usage = avail_data; in usbatm_extract_cells()
459 struct atm_vcc *vcc = ctrl->atm.vcc; in usbatm_write_cells()
461 unsigned int stride = instance->tx_channel.stride; in usbatm_write_cells()
463 for (bytes_written = 0; bytes_written < avail_space && ctrl->len; in usbatm_write_cells()
465 unsigned int data_len = min_t(unsigned int, skb->len, ATM_CELL_PAYLOAD); in usbatm_write_cells()
466 unsigned int left = ATM_CELL_PAYLOAD - data_len; in usbatm_write_cells()
469 ptr[0] = vcc->vpi >> 4; in usbatm_write_cells()
470 ptr[1] = (vcc->vpi << 4) | (vcc->vci >> 12); in usbatm_write_cells()
471 ptr[2] = vcc->vci >> 4; in usbatm_write_cells()
472 ptr[3] = vcc->vci << 4; in usbatm_write_cells()
486 u8 *trailer = target + ATM_CELL_SIZE - ATM_AAL5_TRAILER; in usbatm_write_cells()
489 trailer[2] = ctrl->len >> 8; in usbatm_write_cells()
490 trailer[3] = ctrl->len; in usbatm_write_cells()
492 ctrl->crc = ~crc32_be(ctrl->crc, ptr, left - 4); in usbatm_write_cells()
494 trailer[4] = ctrl->crc >> 24; in usbatm_write_cells()
495 trailer[5] = ctrl->crc >> 16; in usbatm_write_cells()
496 trailer[6] = ctrl->crc >> 8; in usbatm_write_cells()
497 trailer[7] = ctrl->crc; in usbatm_write_cells()
501 ctrl->len = 0; /* tag this skb finished */ in usbatm_write_cells()
503 ctrl->crc = crc32_be(ctrl->crc, ptr, left); in usbatm_write_cells()
520 while ((urb = usbatm_pop_urb(&instance->rx_channel))) { in usbatm_rx_process()
521 vdbg(&instance->usb_intf->dev, in usbatm_rx_process()
524 if (usb_pipeisoc(urb->pipe)) { in usbatm_rx_process()
527 const unsigned int packet_size = instance->rx_channel.packet_size; in usbatm_rx_process()
530 for (i = 0; i < urb->number_of_packets; i++) { in usbatm_rx_process()
531 if (!urb->iso_frame_desc[i].status) { in usbatm_rx_process()
532 unsigned int actual_length = urb->iso_frame_desc[i].actual_length; in usbatm_rx_process()
535 merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; in usbatm_rx_process()
542 atm_rldbg(instance, "%s: status %d in frame %d!\n", __func__, urb->status, i); in usbatm_rx_process()
546 instance->buf_usage = 0; in usbatm_rx_process()
553 if (!urb->status) in usbatm_rx_process()
554 usbatm_extract_cells(instance, urb->transfer_buffer, urb->actual_length); in usbatm_rx_process()
556 instance->buf_usage = 0; in usbatm_rx_process()
572 struct sk_buff *skb = instance->current_skb; in usbatm_tx_process()
574 const unsigned int buf_size = instance->tx_channel.buf_size; in usbatm_tx_process()
579 skb = skb_dequeue(&instance->sndqueue); in usbatm_tx_process()
583 urb = usbatm_pop_urb(&instance->tx_channel); in usbatm_tx_process()
586 buffer = urb->transfer_buffer; in usbatm_tx_process()
587 bytes_written = (urb->status == -EAGAIN) ? in usbatm_tx_process()
588 urb->transfer_buffer_length : 0; in usbatm_tx_process()
593 buf_size - bytes_written); in usbatm_tx_process()
595 vdbg(&instance->usb_intf->dev, in usbatm_tx_process()
599 if (!UDSL_SKB(skb)->len) { in usbatm_tx_process()
600 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc; in usbatm_tx_process()
603 atomic_inc(&vcc->stats->tx); in usbatm_tx_process()
605 skb = skb_dequeue(&instance->sndqueue); in usbatm_tx_process()
609 urb->transfer_buffer_length = bytes_written; in usbatm_tx_process()
617 instance->current_skb = skb; in usbatm_tx_process()
625 spin_lock_irq(&instance->sndqueue.lock); in usbatm_cancel_send()
626 skb_queue_walk_safe(&instance->sndqueue, skb, n) { in usbatm_cancel_send()
627 if (UDSL_SKB(skb)->atm.vcc == vcc) { in usbatm_cancel_send()
629 __skb_unlink(skb, &instance->sndqueue); in usbatm_cancel_send()
633 spin_unlock_irq(&instance->sndqueue.lock); in usbatm_cancel_send()
635 tasklet_disable(&instance->tx_channel.tasklet); in usbatm_cancel_send()
636 if ((skb = instance->current_skb) && (UDSL_SKB(skb)->atm.vcc == vcc)) { in usbatm_cancel_send()
638 instance->current_skb = NULL; in usbatm_cancel_send()
641 tasklet_enable(&instance->tx_channel.tasklet); in usbatm_cancel_send()
646 struct usbatm_data *instance = vcc->dev->dev_data; in usbatm_atm_send()
650 /* racy disconnection check - fine */ in usbatm_atm_send()
651 if (!instance || instance->disconnected) { in usbatm_atm_send()
655 err = -ENODEV; in usbatm_atm_send()
659 if (vcc->qos.aal != ATM_AAL5) { in usbatm_atm_send()
660 atm_rldbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); in usbatm_atm_send()
661 err = -EINVAL; in usbatm_atm_send()
665 if (skb->len > ATM_MAX_AAL5_PDU) { in usbatm_atm_send()
667 __func__, skb->len, ATM_MAX_AAL5_PDU); in usbatm_atm_send()
668 err = -EINVAL; in usbatm_atm_send()
672 PACKETDEBUG(instance, skb->data, skb->len); in usbatm_atm_send()
675 ctrl->atm.vcc = vcc; in usbatm_atm_send()
676 ctrl->len = skb->len; in usbatm_atm_send()
677 ctrl->crc = crc32_be(~0, skb->data, skb->len); in usbatm_atm_send()
679 skb_queue_tail(&instance->sndqueue, skb); in usbatm_atm_send()
680 tasklet_schedule(&instance->tx_channel.tasklet); in usbatm_atm_send()
698 tasklet_kill(&instance->rx_channel.tasklet); in usbatm_destroy_instance()
699 tasklet_kill(&instance->tx_channel.tasklet); in usbatm_destroy_instance()
700 usb_put_dev(instance->usb_dev); in usbatm_destroy_instance()
706 kref_get(&instance->refcount); in usbatm_get_instance()
711 kref_put(&instance->refcount, usbatm_destroy_instance); in usbatm_put_instance()
721 struct usbatm_data *instance = atm_dev->dev_data; in usbatm_atm_dev_close()
726 atm_dev->dev_data = NULL; /* catch bugs */ in usbatm_atm_dev_close()
732 struct usbatm_data *instance = atm_dev->dev_data; in usbatm_atm_proc_read()
736 return -ENODEV; in usbatm_atm_proc_read()
738 if (!left--) in usbatm_atm_proc_read()
739 return sprintf(page, "%s\n", instance->description); in usbatm_atm_proc_read()
741 if (!left--) in usbatm_atm_proc_read()
742 return sprintf(page, "MAC: %pM\n", atm_dev->esi); in usbatm_atm_proc_read()
744 if (!left--) in usbatm_atm_proc_read()
747 atomic_read(&atm_dev->stats.aal5.tx), in usbatm_atm_proc_read()
748 atomic_read(&atm_dev->stats.aal5.tx_err), in usbatm_atm_proc_read()
749 atomic_read(&atm_dev->stats.aal5.rx), in usbatm_atm_proc_read()
750 atomic_read(&atm_dev->stats.aal5.rx_err), in usbatm_atm_proc_read()
751 atomic_read(&atm_dev->stats.aal5.rx_drop)); in usbatm_atm_proc_read()
753 if (!left--) { in usbatm_atm_proc_read()
754 if (instance->disconnected) in usbatm_atm_proc_read()
757 switch (atm_dev->signal) { in usbatm_atm_proc_read()
772 struct usbatm_data *instance = vcc->dev->dev_data; in usbatm_atm_open()
775 int vci = vcc->vci; in usbatm_atm_open()
776 short vpi = vcc->vpi; in usbatm_atm_open()
779 return -ENODEV; in usbatm_atm_open()
782 if ((vcc->qos.aal != ATM_AAL5)) { in usbatm_atm_open()
783 atm_warn(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); in usbatm_atm_open()
784 return -EINVAL; in usbatm_atm_open()
788 if ((vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) { in usbatm_atm_open()
789 atm_dbg(instance, "%s: max_sdu %d out of range!\n", __func__, vcc->qos.rxtp.max_sdu); in usbatm_atm_open()
790 return -EINVAL; in usbatm_atm_open()
793 mutex_lock(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */ in usbatm_atm_open()
795 if (instance->disconnected) { in usbatm_atm_open()
797 ret = -ENODEV; in usbatm_atm_open()
803 ret = -EADDRINUSE; in usbatm_atm_open()
809 ret = -ENOMEM; in usbatm_atm_open()
813 new->vcc = vcc; in usbatm_atm_open()
814 new->vpi = vpi; in usbatm_atm_open()
815 new->vci = vci; in usbatm_atm_open()
817 new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL); in usbatm_atm_open()
818 if (!new->sarb) { in usbatm_atm_open()
820 ret = -ENOMEM; in usbatm_atm_open()
824 vcc->dev_data = new; in usbatm_atm_open()
826 tasklet_disable(&instance->rx_channel.tasklet); in usbatm_atm_open()
827 instance->cached_vcc = new; in usbatm_atm_open()
828 instance->cached_vpi = vpi; in usbatm_atm_open()
829 instance->cached_vci = vci; in usbatm_atm_open()
830 list_add(&new->list, &instance->vcc_list); in usbatm_atm_open()
831 tasklet_enable(&instance->rx_channel.tasklet); in usbatm_atm_open()
833 set_bit(ATM_VF_ADDR, &vcc->flags); in usbatm_atm_open()
834 set_bit(ATM_VF_PARTIAL, &vcc->flags); in usbatm_atm_open()
835 set_bit(ATM_VF_READY, &vcc->flags); in usbatm_atm_open()
837 mutex_unlock(&instance->serialize); in usbatm_atm_open()
845 mutex_unlock(&instance->serialize); in usbatm_atm_open()
851 struct usbatm_data *instance = vcc->dev->dev_data; in usbatm_atm_close()
852 struct usbatm_vcc_data *vcc_data = vcc->dev_data; in usbatm_atm_close()
859 mutex_lock(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */ in usbatm_atm_close()
861 tasklet_disable(&instance->rx_channel.tasklet); in usbatm_atm_close()
862 if (instance->cached_vcc == vcc_data) { in usbatm_atm_close()
863 instance->cached_vcc = NULL; in usbatm_atm_close()
864 instance->cached_vpi = ATM_VPI_UNSPEC; in usbatm_atm_close()
865 instance->cached_vci = ATM_VCI_UNSPEC; in usbatm_atm_close()
867 list_del(&vcc_data->list); in usbatm_atm_close()
868 tasklet_enable(&instance->rx_channel.tasklet); in usbatm_atm_close()
870 kfree_skb(vcc_data->sarb); in usbatm_atm_close()
871 vcc_data->sarb = NULL; in usbatm_atm_close()
874 vcc->dev_data = NULL; in usbatm_atm_close()
876 vcc->vpi = ATM_VPI_UNSPEC; in usbatm_atm_close()
877 vcc->vci = ATM_VCI_UNSPEC; in usbatm_atm_close()
878 clear_bit(ATM_VF_READY, &vcc->flags); in usbatm_atm_close()
879 clear_bit(ATM_VF_PARTIAL, &vcc->flags); in usbatm_atm_close()
880 clear_bit(ATM_VF_ADDR, &vcc->flags); in usbatm_atm_close()
882 mutex_unlock(&instance->serialize); in usbatm_atm_close()
888 struct usbatm_data *instance = atm_dev->dev_data; in usbatm_atm_ioctl()
890 if (!instance || instance->disconnected) in usbatm_atm_ioctl()
891 return -ENODEV; in usbatm_atm_ioctl()
895 return put_user(ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0; in usbatm_atm_ioctl()
897 return -ENOIOCTLCMD; in usbatm_atm_ioctl()
909 * abort if atm_dev->dev_data is NULL. */ in usbatm_atm_init()
910 atm_dev = atm_dev_register(instance->driver_name, in usbatm_atm_init()
911 &instance->usb_intf->dev, &usbatm_atm_devops, in usbatm_atm_init()
912 -1, NULL); in usbatm_atm_init()
915 return -1; in usbatm_atm_init()
918 instance->atm_dev = atm_dev; in usbatm_atm_init()
920 atm_dev->ci_range.vpi_bits = ATM_CI_MAX; in usbatm_atm_init()
921 atm_dev->ci_range.vci_bits = ATM_CI_MAX; in usbatm_atm_init()
922 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; in usbatm_atm_init()
925 atm_dev->link_rate = 128 * 1000 / 424; in usbatm_atm_init()
927 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) { in usbatm_atm_init()
936 atm_dev->dev_data = instance; in usbatm_atm_init()
940 usbatm_submit_urb(instance->urbs[i]); in usbatm_atm_init()
945 instance->atm_dev = NULL; in usbatm_atm_init()
952 ** USB **
961 complete(&instance->thread_started); in usbatm_do_heavy_init()
963 ret = instance->driver->heavy_init(instance, instance->usb_intf); in usbatm_do_heavy_init()
968 mutex_lock(&instance->serialize); in usbatm_do_heavy_init()
969 instance->thread = NULL; in usbatm_do_heavy_init()
970 mutex_unlock(&instance->serialize); in usbatm_do_heavy_init()
972 kthread_complete_and_exit(&instance->thread_exited, ret); in usbatm_do_heavy_init()
980 instance->driver->driver_name); in usbatm_heavy_init()
987 instance->thread = t; in usbatm_heavy_init()
989 wait_for_completion(&instance->thread_started); in usbatm_heavy_init()
998 tasklet_schedule(&channel->tasklet); in usbatm_tasklet_schedule()
1003 spin_lock_init(&channel->lock); in usbatm_init_channel()
1004 INIT_LIST_HEAD(&channel->list); in usbatm_init_channel()
1005 timer_setup(&channel->delay, usbatm_tasklet_schedule, 0); in usbatm_init_channel()
1011 struct device *dev = &intf->dev; in usbatm_usb_probe()
1015 int error = -ENOMEM; in usbatm_usb_probe()
1025 return -ENOMEM; in usbatm_usb_probe()
1029 instance->driver = driver; in usbatm_usb_probe()
1030 strscpy(instance->driver_name, driver->driver_name, in usbatm_usb_probe()
1031 sizeof(instance->driver_name)); in usbatm_usb_probe()
1033 instance->usb_dev = usb_dev; in usbatm_usb_probe()
1034 instance->usb_intf = intf; in usbatm_usb_probe()
1036 buf = instance->description; in usbatm_usb_probe()
1037 length = sizeof(instance->description); in usbatm_usb_probe()
1039 if ((i = usb_string(usb_dev, usb_dev->descriptor.iProduct, buf, length)) < 0) in usbatm_usb_probe()
1043 length -= i; in usbatm_usb_probe()
1047 length -= i; in usbatm_usb_probe()
1053 length -= i; in usbatm_usb_probe()
1058 if (driver->bind && (error = driver->bind(instance, intf, id)) < 0) { in usbatm_usb_probe()
1065 kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ in usbatm_usb_probe()
1066 mutex_init(&instance->serialize); in usbatm_usb_probe()
1068 instance->thread = NULL; in usbatm_usb_probe()
1069 init_completion(&instance->thread_started); in usbatm_usb_probe()
1070 init_completion(&instance->thread_exited); in usbatm_usb_probe()
1072 INIT_LIST_HEAD(&instance->vcc_list); in usbatm_usb_probe()
1073 skb_queue_head_init(&instance->sndqueue); in usbatm_usb_probe()
1075 usbatm_init_channel(&instance->rx_channel); in usbatm_usb_probe()
1076 usbatm_init_channel(&instance->tx_channel); in usbatm_usb_probe()
1077 tasklet_setup(&instance->rx_channel.tasklet, usbatm_rx_process); in usbatm_usb_probe()
1078 tasklet_setup(&instance->tx_channel.tasklet, usbatm_tx_process); in usbatm_usb_probe()
1079 instance->rx_channel.stride = ATM_CELL_SIZE + driver->rx_padding; in usbatm_usb_probe()
1080 instance->tx_channel.stride = ATM_CELL_SIZE + driver->tx_padding; in usbatm_usb_probe()
1081 instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance; in usbatm_usb_probe()
1083 if ((instance->flags & UDSL_USE_ISOC) && driver->isoc_in) in usbatm_usb_probe()
1084 instance->rx_channel.endpoint = usb_rcvisocpipe(usb_dev, driver->isoc_in); in usbatm_usb_probe()
1086 instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->bulk_in); in usbatm_usb_probe()
1088 instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->bulk_out); in usbatm_usb_probe()
1091 instance->tx_channel.buf_size = max(instance->tx_channel.stride, in usbatm_usb_probe()
1092 snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride)); in usbatm_usb_probe()
1095 maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint); in usbatm_usb_probe()
1099 usb_pipeendpoint(instance->rx_channel.endpoint)); in usbatm_usb_probe()
1100 error = -EINVAL; in usbatm_usb_probe()
1107 num_packets--; in usbatm_usb_probe()
1109 instance->rx_channel.buf_size = num_packets * maxpacket; in usbatm_usb_probe()
1110 instance->rx_channel.packet_size = maxpacket; in usbatm_usb_probe()
1114 &instance->tx_channel : &instance->rx_channel; in usbatm_usb_probe()
1117 __func__, channel->buf_size, i ? "tx" : "rx", channel); in usbatm_usb_probe()
1125 &instance->rx_channel : &instance->tx_channel; in usbatm_usb_probe()
1127 …unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_s… in usbatm_usb_probe()
1131 error = -ENOMEM; in usbatm_usb_probe()
1135 instance->urbs[i] = urb; in usbatm_usb_probe()
1138 buffer = kzalloc(channel->buf_size, GFP_KERNEL); in usbatm_usb_probe()
1140 error = -ENOMEM; in usbatm_usb_probe()
1144 usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint, in usbatm_usb_probe()
1145 buffer, channel->buf_size, usbatm_complete, channel); in usbatm_usb_probe()
1148 urb->interval = 1; in usbatm_usb_probe()
1149 urb->transfer_flags = URB_ISO_ASAP; in usbatm_usb_probe()
1150 urb->number_of_packets = iso_packets; in usbatm_usb_probe()
1152 urb->iso_frame_desc[j].offset = channel->packet_size * j; in usbatm_usb_probe()
1153 urb->iso_frame_desc[j].length = channel->packet_size; in usbatm_usb_probe()
1159 list_add_tail(&urb->urb_list, &channel->list); in usbatm_usb_probe()
1161 vdbg(&intf->dev, "%s: alloced buffer 0x%p buf size %u urb 0x%p", in usbatm_usb_probe()
1162 __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb); in usbatm_usb_probe()
1165 instance->cached_vpi = ATM_VPI_UNSPEC; in usbatm_usb_probe()
1166 instance->cached_vci = ATM_VCI_UNSPEC; in usbatm_usb_probe()
1167 instance->cell_buf = kmalloc(instance->rx_channel.stride, GFP_KERNEL); in usbatm_usb_probe()
1169 if (!instance->cell_buf) { in usbatm_usb_probe()
1170 error = -ENOMEM; in usbatm_usb_probe()
1174 if (!(instance->flags & UDSL_SKIP_HEAVY_INIT) && driver->heavy_init) { in usbatm_usb_probe()
1177 complete(&instance->thread_exited); /* pretend that heavy_init was run */ in usbatm_usb_probe()
1190 if (instance->driver->unbind) in usbatm_usb_probe()
1191 instance->driver->unbind(instance, intf); in usbatm_usb_probe()
1193 kfree(instance->cell_buf); in usbatm_usb_probe()
1196 if (instance->urbs[i]) in usbatm_usb_probe()
1197 kfree(instance->urbs[i]->transfer_buffer); in usbatm_usb_probe()
1198 usb_free_urb(instance->urbs[i]); in usbatm_usb_probe()
1209 struct device *dev = &intf->dev; in usbatm_usb_disconnect()
1221 mutex_lock(&instance->serialize); in usbatm_usb_disconnect()
1222 instance->disconnected = 1; in usbatm_usb_disconnect()
1223 if (instance->thread != NULL) in usbatm_usb_disconnect()
1224 send_sig(SIGTERM, instance->thread, 1); in usbatm_usb_disconnect()
1225 mutex_unlock(&instance->serialize); in usbatm_usb_disconnect()
1227 wait_for_completion(&instance->thread_exited); in usbatm_usb_disconnect()
1229 mutex_lock(&instance->serialize); in usbatm_usb_disconnect()
1230 list_for_each_entry(vcc_data, &instance->vcc_list, list) in usbatm_usb_disconnect()
1231 vcc_release_async(vcc_data->vcc, -EPIPE); in usbatm_usb_disconnect()
1232 mutex_unlock(&instance->serialize); in usbatm_usb_disconnect()
1234 tasklet_disable(&instance->rx_channel.tasklet); in usbatm_usb_disconnect()
1235 tasklet_disable(&instance->tx_channel.tasklet); in usbatm_usb_disconnect()
1238 usb_kill_urb(instance->urbs[i]); in usbatm_usb_disconnect()
1240 del_timer_sync(&instance->rx_channel.delay); in usbatm_usb_disconnect()
1241 del_timer_sync(&instance->tx_channel.delay); in usbatm_usb_disconnect()
1243 /* turn usbatm_[rt]x_process into something close to a no-op */ in usbatm_usb_disconnect()
1245 INIT_LIST_HEAD(&instance->rx_channel.list); in usbatm_usb_disconnect()
1246 INIT_LIST_HEAD(&instance->tx_channel.list); in usbatm_usb_disconnect()
1248 tasklet_enable(&instance->rx_channel.tasklet); in usbatm_usb_disconnect()
1249 tasklet_enable(&instance->tx_channel.tasklet); in usbatm_usb_disconnect()
1251 if (instance->atm_dev && instance->driver->atm_stop) in usbatm_usb_disconnect()
1252 instance->driver->atm_stop(instance, instance->atm_dev); in usbatm_usb_disconnect()
1254 if (instance->driver->unbind) in usbatm_usb_disconnect()
1255 instance->driver->unbind(instance, intf); in usbatm_usb_disconnect()
1257 instance->driver_data = NULL; in usbatm_usb_disconnect()
1260 kfree(instance->urbs[i]->transfer_buffer); in usbatm_usb_disconnect()
1261 usb_free_urb(instance->urbs[i]); in usbatm_usb_disconnect()
1264 kfree(instance->cell_buf); in usbatm_usb_disconnect()
1267 if (instance->atm_dev) { in usbatm_usb_disconnect()
1268 atm_dev_deregister(instance->atm_dev); in usbatm_usb_disconnect()
1269 instance->atm_dev = NULL; in usbatm_usb_disconnect()
1285 return -EIO; in usbatm_usb_init()
1294 return -EINVAL; in usbatm_usb_init()
1325 dev_dbg(&instance->usb_intf->dev, "%s", buffer); in usbatm_print_packet()