Lines Matching refs:mdev

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