Lines Matching refs:mdev
77 struct most_dev *mdev; member
237 struct most_dev *mdev = to_mdev(iface); in hdm_poison_channel() local
242 dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n"); in hdm_poison_channel()
246 lock = mdev->channel_lock + channel; in hdm_poison_channel()
248 mdev->is_channel_healthy[channel] = false; in hdm_poison_channel()
251 cancel_work_sync(&mdev->clear_work[channel].ws); in hdm_poison_channel()
253 mutex_lock(&mdev->io_mutex); in hdm_poison_channel()
254 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); in hdm_poison_channel()
255 if (mdev->padding_active[channel]) in hdm_poison_channel()
256 mdev->padding_active[channel] = false; in hdm_poison_channel()
258 if (mdev->conf[channel].data_type == MOST_CH_ASYNC) { in hdm_poison_channel()
259 del_timer_sync(&mdev->link_stat_timer); in hdm_poison_channel()
260 cancel_work_sync(&mdev->poll_work_obj); in hdm_poison_channel()
262 mutex_unlock(&mdev->io_mutex); in hdm_poison_channel()
275 static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo) in hdm_add_padding() argument
277 struct most_channel_config *conf = &mdev->conf[channel]; in hdm_add_padding()
278 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); in hdm_add_padding()
286 dev_err(&mdev->usb_device->dev, in hdm_add_padding()
308 static int hdm_remove_padding(struct most_dev *mdev, int channel, in hdm_remove_padding() argument
311 struct most_channel_config *const conf = &mdev->conf[channel]; in hdm_remove_padding()
312 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); in hdm_remove_padding()
342 struct most_dev *mdev = to_mdev(mbo->ifp); in hdm_write_completion() local
344 spinlock_t *lock = mdev->channel_lock + channel; in hdm_write_completion()
351 if (likely(mdev->is_channel_healthy[channel])) { in hdm_write_completion()
359 dev_warn(&mdev->usb_device->dev, in hdm_write_completion()
361 mdev->ep_address[channel]); in hdm_write_completion()
362 mdev->is_channel_healthy[channel] = false; in hdm_write_completion()
363 mdev->clear_work[channel].pipe = urb->pipe; in hdm_write_completion()
364 schedule_work(&mdev->clear_work[channel].ws); in hdm_write_completion()
394 struct most_dev *mdev = to_mdev(mbo->ifp); in hdm_read_completion() local
396 struct device *dev = &mdev->usb_device->dev; in hdm_read_completion()
397 spinlock_t *lock = mdev->channel_lock + channel; in hdm_read_completion()
404 if (likely(mdev->is_channel_healthy[channel])) { in hdm_read_completion()
410 if (mdev->padding_active[channel] && in hdm_read_completion()
411 hdm_remove_padding(mdev, channel, mbo)) { in hdm_read_completion()
418 mdev->ep_address[channel]); in hdm_read_completion()
419 mdev->is_channel_healthy[channel] = false; in hdm_read_completion()
420 mdev->clear_work[channel].pipe = urb->pipe; in hdm_read_completion()
421 schedule_work(&mdev->clear_work[channel].ws); in hdm_read_completion()
429 mdev->ep_address[channel]); in hdm_read_completion()
459 struct most_dev *mdev = to_mdev(iface); in hdm_enqueue() local
475 conf = &mdev->conf[channel]; in hdm_enqueue()
477 mutex_lock(&mdev->io_mutex); in hdm_enqueue()
478 if (!mdev->usb_device) { in hdm_enqueue()
483 if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] && in hdm_enqueue()
484 hdm_add_padding(mdev, channel, mbo)) { in hdm_enqueue()
494 usb_fill_bulk_urb(urb, mdev->usb_device, in hdm_enqueue()
495 usb_sndbulkpipe(mdev->usb_device, in hdm_enqueue()
496 mdev->ep_address[channel]), in hdm_enqueue()
505 usb_fill_bulk_urb(urb, mdev->usb_device, in hdm_enqueue()
506 usb_rcvbulkpipe(mdev->usb_device, in hdm_enqueue()
507 mdev->ep_address[channel]), in hdm_enqueue()
515 usb_anchor_urb(urb, &mdev->busy_urbs[channel]); in hdm_enqueue()
519 dev_err(&mdev->usb_device->dev, in hdm_enqueue()
523 mutex_unlock(&mdev->io_mutex); in hdm_enqueue()
530 mutex_unlock(&mdev->io_mutex); in hdm_enqueue()
536 struct most_dev *mdev = to_mdev(mbo->ifp); in hdm_dma_alloc() local
538 return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL, in hdm_dma_alloc()
544 struct most_dev *mdev = to_mdev(mbo->ifp); in hdm_dma_free() local
546 usb_free_coherent(mdev->usb_device, size, mbo->virt_address, in hdm_dma_free()
570 struct most_dev *mdev = to_mdev(iface); in hdm_configure_channel() local
571 struct device *dev = &mdev->usb_device->dev; in hdm_configure_channel()
582 mdev->is_channel_healthy[channel] = true; in hdm_configure_channel()
583 mdev->clear_work[channel].channel = channel; in hdm_configure_channel()
584 mdev->clear_work[channel].mdev = mdev; in hdm_configure_channel()
585 INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt); in hdm_configure_channel()
595 mdev->padding_active[channel] = false; in hdm_configure_channel()
604 mdev->padding_active[channel] = true; in hdm_configure_channel()
606 frame_size = get_stream_frame_size(&mdev->dev, conf); in hdm_configure_channel()
619 mdev->suffix[channel], old_size, conf->buffer_size); in hdm_configure_channel()
626 mdev->conf[channel] = *conf; in hdm_configure_channel()
628 u16 ep = mdev->ep_address[channel]; in hdm_configure_channel()
630 if (start_sync_ep(mdev->usb_device, ep) < 0) in hdm_configure_channel()
650 struct most_dev *mdev = to_mdev(iface); in hdm_request_netinfo() local
652 mdev->on_netinfo = on_netinfo; in hdm_request_netinfo()
656 mdev->link_stat_timer.expires = jiffies + HZ; in hdm_request_netinfo()
657 mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires); in hdm_request_netinfo()
669 struct most_dev *mdev = from_timer(mdev, t, link_stat_timer); in link_stat_timer_handler() local
671 schedule_work(&mdev->poll_work_obj); in link_stat_timer_handler()
672 mdev->link_stat_timer.expires = jiffies + (2 * HZ); in link_stat_timer_handler()
673 add_timer(&mdev->link_stat_timer); in link_stat_timer_handler()
684 struct most_dev *mdev = to_mdev_from_work(wq_obj); in wq_netinfo() local
685 struct usb_device *usb_device = mdev->usb_device; in wq_netinfo()
717 if (mdev->on_netinfo) in wq_netinfo()
718 mdev->on_netinfo(&mdev->iface, link, hw_addr); in wq_netinfo()
730 struct most_dev *mdev = clear_work->mdev; in wq_clear_halt() local
736 mutex_lock(&mdev->io_mutex); in wq_clear_halt()
737 most_stop_enqueue(&mdev->iface, channel); in wq_clear_halt()
738 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); in wq_clear_halt()
739 if (usb_clear_halt(mdev->usb_device, pipe)) in wq_clear_halt()
740 dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n"); in wq_clear_halt()
750 if (mdev->conf[channel].data_type == MOST_CH_ASYNC && in wq_clear_halt()
751 mdev->conf[channel].direction == MOST_CH_RX) { in wq_clear_halt()
756 snd_pipe = usb_sndbulkpipe(mdev->usb_device, in wq_clear_halt()
757 mdev->ep_address[peer]); in wq_clear_halt()
758 usb_clear_halt(mdev->usb_device, snd_pipe); in wq_clear_halt()
760 mdev->is_channel_healthy[channel] = true; in wq_clear_halt()
761 most_resume_enqueue(&mdev->iface, channel); in wq_clear_halt()
762 mutex_unlock(&mdev->io_mutex); in wq_clear_halt()
929 struct most_dev *mdev = to_mdev_from_dev(dev); in release_mdev() local
931 kfree(mdev); in release_mdev()
951 struct most_dev *mdev; in hdm_probe() local
958 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); in hdm_probe()
959 if (!mdev) in hdm_probe()
962 usb_set_intfdata(interface, mdev); in hdm_probe()
965 kfree(mdev); in hdm_probe()
968 mutex_init(&mdev->io_mutex); in hdm_probe()
969 INIT_WORK(&mdev->poll_work_obj, wq_netinfo); in hdm_probe()
970 timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0); in hdm_probe()
972 mdev->usb_device = usb_dev; in hdm_probe()
973 mdev->link_stat_timer.expires = jiffies + (2 * HZ); in hdm_probe()
975 mdev->iface.mod = hdm_usb_fops.owner; in hdm_probe()
976 mdev->iface.dev = &mdev->dev; in hdm_probe()
977 mdev->iface.driver_dev = &interface->dev; in hdm_probe()
978 mdev->iface.interface = ITYPE_USB; in hdm_probe()
979 mdev->iface.configure = hdm_configure_channel; in hdm_probe()
980 mdev->iface.request_netinfo = hdm_request_netinfo; in hdm_probe()
981 mdev->iface.enqueue = hdm_enqueue; in hdm_probe()
982 mdev->iface.poison_channel = hdm_poison_channel; in hdm_probe()
983 mdev->iface.dma_alloc = hdm_dma_alloc; in hdm_probe()
984 mdev->iface.dma_free = hdm_dma_free; in hdm_probe()
985 mdev->iface.description = mdev->description; in hdm_probe()
986 mdev->iface.num_channels = num_endpoints; in hdm_probe()
988 snprintf(mdev->description, sizeof(mdev->description), in hdm_probe()
995 mdev->dev.init_name = mdev->description; in hdm_probe()
996 mdev->dev.parent = &interface->dev; in hdm_probe()
997 mdev->dev.release = release_mdev; in hdm_probe()
998 mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL); in hdm_probe()
999 if (!mdev->conf) in hdm_probe()
1002 mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL); in hdm_probe()
1003 if (!mdev->cap) in hdm_probe()
1006 mdev->iface.channel_vector = mdev->cap; in hdm_probe()
1007 mdev->ep_address = in hdm_probe()
1008 kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL); in hdm_probe()
1009 if (!mdev->ep_address) in hdm_probe()
1012 mdev->busy_urbs = in hdm_probe()
1013 kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL); in hdm_probe()
1014 if (!mdev->busy_urbs) in hdm_probe()
1017 tmp_cap = mdev->cap; in hdm_probe()
1020 mdev->ep_address[i] = ep_desc->bEndpointAddress; in hdm_probe()
1021 mdev->padding_active[i] = false; in hdm_probe()
1022 mdev->is_channel_healthy[i] = true; in hdm_probe()
1024 snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x", in hdm_probe()
1025 mdev->ep_address[i]); in hdm_probe()
1027 tmp_cap->name_suffix = &mdev->suffix[i][0]; in hdm_probe()
1039 init_usb_anchor(&mdev->busy_urbs[i]); in hdm_probe()
1040 spin_lock_init(&mdev->channel_lock[i]); in hdm_probe()
1054 ret = most_register_interface(&mdev->iface); in hdm_probe()
1058 mutex_lock(&mdev->io_mutex); in hdm_probe()
1062 mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL); in hdm_probe()
1063 if (!mdev->dci) { in hdm_probe()
1064 mutex_unlock(&mdev->io_mutex); in hdm_probe()
1065 most_deregister_interface(&mdev->iface); in hdm_probe()
1070 mdev->dci->dev.init_name = "dci"; in hdm_probe()
1071 mdev->dci->dev.parent = get_device(mdev->iface.dev); in hdm_probe()
1072 mdev->dci->dev.groups = dci_groups; in hdm_probe()
1073 mdev->dci->dev.release = release_dci; in hdm_probe()
1074 if (device_register(&mdev->dci->dev)) { in hdm_probe()
1075 mutex_unlock(&mdev->io_mutex); in hdm_probe()
1076 most_deregister_interface(&mdev->iface); in hdm_probe()
1080 mdev->dci->usb_device = mdev->usb_device; in hdm_probe()
1082 mutex_unlock(&mdev->io_mutex); in hdm_probe()
1085 put_device(&mdev->dci->dev); in hdm_probe()
1087 kfree(mdev->busy_urbs); in hdm_probe()
1089 kfree(mdev->ep_address); in hdm_probe()
1091 kfree(mdev->cap); in hdm_probe()
1093 kfree(mdev->conf); in hdm_probe()
1095 put_device(&mdev->dev); in hdm_probe()
1110 struct most_dev *mdev = usb_get_intfdata(interface); in hdm_disconnect() local
1112 mutex_lock(&mdev->io_mutex); in hdm_disconnect()
1114 mdev->usb_device = NULL; in hdm_disconnect()
1115 mutex_unlock(&mdev->io_mutex); in hdm_disconnect()
1117 del_timer_sync(&mdev->link_stat_timer); in hdm_disconnect()
1118 cancel_work_sync(&mdev->poll_work_obj); in hdm_disconnect()
1120 if (mdev->dci) in hdm_disconnect()
1121 device_unregister(&mdev->dci->dev); in hdm_disconnect()
1122 most_deregister_interface(&mdev->iface); in hdm_disconnect()
1124 kfree(mdev->busy_urbs); in hdm_disconnect()
1125 kfree(mdev->cap); in hdm_disconnect()
1126 kfree(mdev->conf); in hdm_disconnect()
1127 kfree(mdev->ep_address); in hdm_disconnect()
1128 put_device(&mdev->dci->dev); in hdm_disconnect()
1129 put_device(&mdev->dev); in hdm_disconnect()
1134 struct most_dev *mdev = usb_get_intfdata(interface); in hdm_suspend() local
1137 mutex_lock(&mdev->io_mutex); in hdm_suspend()
1138 for (i = 0; i < mdev->iface.num_channels; i++) { in hdm_suspend()
1139 most_stop_enqueue(&mdev->iface, i); in hdm_suspend()
1140 usb_kill_anchored_urbs(&mdev->busy_urbs[i]); in hdm_suspend()
1142 mutex_unlock(&mdev->io_mutex); in hdm_suspend()
1148 struct most_dev *mdev = usb_get_intfdata(interface); in hdm_resume() local
1151 mutex_lock(&mdev->io_mutex); in hdm_resume()
1152 for (i = 0; i < mdev->iface.num_channels; i++) in hdm_resume()
1153 most_resume_enqueue(&mdev->iface, i); in hdm_resume()
1154 mutex_unlock(&mdev->io_mutex); in hdm_resume()