Lines Matching refs:mdev
77 struct most_dev *mdev;
238 struct most_dev *mdev = to_mdev(iface);
243 dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
247 lock = mdev->channel_lock + channel;
249 mdev->is_channel_healthy[channel] = false;
252 cancel_work_sync(&mdev->clear_work[channel].ws);
254 mutex_lock(&mdev->io_mutex);
255 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
256 if (mdev->padding_active[channel])
257 mdev->padding_active[channel] = false;
259 if (mdev->conf[channel].data_type == MOST_CH_ASYNC) {
260 del_timer_sync(&mdev->link_stat_timer);
261 cancel_work_sync(&mdev->poll_work_obj);
263 mutex_unlock(&mdev->io_mutex);
269 * @mdev: most device
276 static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
278 struct most_channel_config *conf = &mdev->conf[channel];
279 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf);
287 dev_err(&mdev->usb_device->dev,
302 * @mdev: most device
309 static int hdm_remove_padding(struct most_dev *mdev, int channel,
312 struct most_channel_config *const conf = &mdev->conf[channel];
313 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf);
343 struct most_dev *mdev = to_mdev(mbo->ifp);
345 spinlock_t *lock = mdev->channel_lock + channel;
352 if (likely(mdev->is_channel_healthy[channel])) {
360 dev_warn(&mdev->usb_device->dev,
362 mdev->ep_address[channel]);
363 mdev->is_channel_healthy[channel] = false;
364 mdev->clear_work[channel].pipe = urb->pipe;
365 schedule_work(&mdev->clear_work[channel].ws);
395 struct most_dev *mdev = to_mdev(mbo->ifp);
397 struct device *dev = &mdev->usb_device->dev;
398 spinlock_t *lock = mdev->channel_lock + channel;
405 if (likely(mdev->is_channel_healthy[channel])) {
411 if (mdev->padding_active[channel] &&
412 hdm_remove_padding(mdev, channel, mbo)) {
419 mdev->ep_address[channel]);
420 mdev->is_channel_healthy[channel] = false;
421 mdev->clear_work[channel].pipe = urb->pipe;
422 schedule_work(&mdev->clear_work[channel].ws);
430 mdev->ep_address[channel]);
460 struct most_dev *mdev = to_mdev(iface);
476 conf = &mdev->conf[channel];
478 mutex_lock(&mdev->io_mutex);
479 if (!mdev->usb_device) {
484 if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
485 hdm_add_padding(mdev, channel, mbo)) {
495 usb_fill_bulk_urb(urb, mdev->usb_device,
496 usb_sndbulkpipe(mdev->usb_device,
497 mdev->ep_address[channel]),
506 usb_fill_bulk_urb(urb, mdev->usb_device,
507 usb_rcvbulkpipe(mdev->usb_device,
508 mdev->ep_address[channel]),
516 usb_anchor_urb(urb, &mdev->busy_urbs[channel]);
520 dev_err(&mdev->usb_device->dev,
524 mutex_unlock(&mdev->io_mutex);
531 mutex_unlock(&mdev->io_mutex);
537 struct most_dev *mdev = to_mdev(mbo->ifp);
539 return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL,
545 struct most_dev *mdev = to_mdev(mbo->ifp);
547 usb_free_coherent(mdev->usb_device, size, mbo->virt_address,
571 struct most_dev *mdev = to_mdev(iface);
572 struct device *dev = &mdev->usb_device->dev;
583 mdev->is_channel_healthy[channel] = true;
584 mdev->clear_work[channel].channel = channel;
585 mdev->clear_work[channel].mdev = mdev;
586 INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
596 mdev->padding_active[channel] = false;
605 mdev->padding_active[channel] = true;
607 frame_size = get_stream_frame_size(&mdev->dev, conf);
620 mdev->suffix[channel], old_size, conf->buffer_size);
627 mdev->conf[channel] = *conf;
629 u16 ep = mdev->ep_address[channel];
631 if (start_sync_ep(mdev->usb_device, ep) < 0)
651 struct most_dev *mdev = to_mdev(iface);
653 mdev->on_netinfo = on_netinfo;
657 mdev->link_stat_timer.expires = jiffies + HZ;
658 mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires);
670 struct most_dev *mdev = from_timer(mdev, t, link_stat_timer);
672 schedule_work(&mdev->poll_work_obj);
673 mdev->link_stat_timer.expires = jiffies + (2 * HZ);
674 add_timer(&mdev->link_stat_timer);
685 struct most_dev *mdev = to_mdev_from_work(wq_obj);
686 struct usb_device *usb_device = mdev->usb_device;
718 if (mdev->on_netinfo)
719 mdev->on_netinfo(&mdev->iface, link, hw_addr);
731 struct most_dev *mdev = clear_work->mdev;
737 mutex_lock(&mdev->io_mutex);
738 most_stop_enqueue(&mdev->iface, channel);
739 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
740 if (usb_clear_halt(mdev->usb_device, pipe))
741 dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n");
751 if (mdev->conf[channel].data_type == MOST_CH_ASYNC &&
752 mdev->conf[channel].direction == MOST_CH_RX) {
757 snd_pipe = usb_sndbulkpipe(mdev->usb_device,
758 mdev->ep_address[peer]);
759 usb_clear_halt(mdev->usb_device, snd_pipe);
761 mdev->is_channel_healthy[channel] = true;
762 most_resume_enqueue(&mdev->iface, channel);
763 mutex_unlock(&mdev->io_mutex);
930 struct most_dev *mdev = to_mdev_from_dev(dev);
932 kfree(mdev);
952 struct most_dev *mdev;
959 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
960 if (!mdev)
963 usb_set_intfdata(interface, mdev);
966 kfree(mdev);
969 mutex_init(&mdev->io_mutex);
970 INIT_WORK(&mdev->poll_work_obj, wq_netinfo);
971 timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0);
973 mdev->usb_device = usb_dev;
974 mdev->link_stat_timer.expires = jiffies + (2 * HZ);
976 mdev->iface.mod = hdm_usb_fops.owner;
977 mdev->iface.dev = &mdev->dev;
978 mdev->iface.driver_dev = &interface->dev;
979 mdev->iface.interface = ITYPE_USB;
980 mdev->iface.configure = hdm_configure_channel;
981 mdev->iface.request_netinfo = hdm_request_netinfo;
982 mdev->iface.enqueue = hdm_enqueue;
983 mdev->iface.poison_channel = hdm_poison_channel;
984 mdev->iface.dma_alloc = hdm_dma_alloc;
985 mdev->iface.dma_free = hdm_dma_free;
986 mdev->iface.description = mdev->description;
987 mdev->iface.num_channels = num_endpoints;
989 snprintf(mdev->description, sizeof(mdev->description),
996 mdev->dev.init_name = mdev->description;
997 mdev->dev.parent = &interface->dev;
998 mdev->dev.release = release_mdev;
999 mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL);
1000 if (!mdev->conf)
1003 mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL);
1004 if (!mdev->cap)
1007 mdev->iface.channel_vector = mdev->cap;
1008 mdev->ep_address =
1009 kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL);
1010 if (!mdev->ep_address)
1013 mdev->busy_urbs =
1014 kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL);
1015 if (!mdev->busy_urbs)
1018 tmp_cap = mdev->cap;
1021 mdev->ep_address[i] = ep_desc->bEndpointAddress;
1022 mdev->padding_active[i] = false;
1023 mdev->is_channel_healthy[i] = true;
1025 snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x",
1026 mdev->ep_address[i]);
1028 tmp_cap->name_suffix = &mdev->suffix[i][0];
1040 init_usb_anchor(&mdev->busy_urbs[i]);
1041 spin_lock_init(&mdev->channel_lock[i]);
1055 ret = most_register_interface(&mdev->iface);
1059 mutex_lock(&mdev->io_mutex);
1063 mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL);
1064 if (!mdev->dci) {
1065 mutex_unlock(&mdev->io_mutex);
1066 most_deregister_interface(&mdev->iface);
1071 mdev->dci->dev.init_name = "dci";
1072 mdev->dci->dev.parent = get_device(mdev->iface.dev);
1073 mdev->dci->dev.groups = dci_groups;
1074 mdev->dci->dev.release = release_dci;
1075 if (device_register(&mdev->dci->dev)) {
1076 mutex_unlock(&mdev->io_mutex);
1077 most_deregister_interface(&mdev->iface);
1081 mdev->dci->usb_device = mdev->usb_device;
1083 mutex_unlock(&mdev->io_mutex);
1086 put_device(&mdev->dci->dev);
1088 kfree(mdev->busy_urbs);
1090 kfree(mdev->ep_address);
1092 kfree(mdev->cap);
1094 kfree(mdev->conf);
1096 put_device(&mdev->dev);
1111 struct most_dev *mdev = usb_get_intfdata(interface);
1113 mutex_lock(&mdev->io_mutex);
1115 mdev->usb_device = NULL;
1116 mutex_unlock(&mdev->io_mutex);
1118 del_timer_sync(&mdev->link_stat_timer);
1119 cancel_work_sync(&mdev->poll_work_obj);
1121 if (mdev->dci)
1122 device_unregister(&mdev->dci->dev);
1123 most_deregister_interface(&mdev->iface);
1125 kfree(mdev->busy_urbs);
1126 kfree(mdev->cap);
1127 kfree(mdev->conf);
1128 kfree(mdev->ep_address);
1129 put_device(&mdev->dci->dev);
1130 put_device(&mdev->dev);
1135 struct most_dev *mdev = usb_get_intfdata(interface);
1138 mutex_lock(&mdev->io_mutex);
1139 for (i = 0; i < mdev->iface.num_channels; i++) {
1140 most_stop_enqueue(&mdev->iface, i);
1141 usb_kill_anchored_urbs(&mdev->busy_urbs[i]);
1143 mutex_unlock(&mdev->io_mutex);
1149 struct most_dev *mdev = usb_get_intfdata(interface);
1152 mutex_lock(&mdev->io_mutex);
1153 for (i = 0; i < mdev->iface.num_channels; i++)
1154 most_resume_enqueue(&mdev->iface, i);
1155 mutex_unlock(&mdev->io_mutex);