Lines Matching refs:xdev
89 struct xillyusb_dev *xdev; member
118 struct xillyusb_dev *xdev; member
479 *endpoint_alloc(struct xillyusb_dev *xdev, in endpoint_alloc() argument
508 ep->xdev = xdev; in endpoint_alloc()
540 struct xillyusb_dev *xdev = in cleanup_dev() local
543 if (xdev->in_ep) in cleanup_dev()
544 endpoint_dealloc(xdev->in_ep); in cleanup_dev()
546 if (xdev->msg_ep) in cleanup_dev()
547 endpoint_dealloc(xdev->msg_ep); in cleanup_dev()
549 if (xdev->workq) in cleanup_dev()
550 destroy_workqueue(xdev->workq); in cleanup_dev()
552 kfree(xdev->channels); /* Argument may be NULL, and that's fine */ in cleanup_dev()
553 kfree(xdev); in cleanup_dev()
572 struct xillyusb_dev *xdev = container_of(work, struct xillyusb_dev, in wakeup_all() local
575 mutex_lock(&xdev->process_in_mutex); in wakeup_all()
577 for (i = 0; i < xdev->num_channels; i++) { in wakeup_all()
578 struct xillyusb_channel *chan = &xdev->channels[i]; in wakeup_all()
599 mutex_unlock(&xdev->process_in_mutex); in wakeup_all()
601 wake_up_interruptible(&xdev->msg_ep->fifo.waitq); in wakeup_all()
603 kref_put(&xdev->kref, cleanup_dev); in wakeup_all()
606 static void report_io_error(struct xillyusb_dev *xdev, in report_io_error() argument
612 spin_lock_irqsave(&xdev->error_lock, flags); in report_io_error()
613 if (!xdev->error) { in report_io_error()
614 xdev->error = errcode; in report_io_error()
617 spin_unlock_irqrestore(&xdev->error_lock, flags); in report_io_error()
620 kref_get(&xdev->kref); /* xdev is used by work item */ in report_io_error()
621 queue_work(xdev->workq, &xdev->wakeup_workitem); in report_io_error()
637 flush_work(&chan->xdev->in_ep->workitem); in safely_assign_in_fifo()
650 report_io_error(ep->xdev, -EIO); in bulk_in_completer()
667 queue_work(ep->xdev->workq, &ep->workitem); in bulk_in_completer()
680 report_io_error(ep->xdev, -EIO); in bulk_out_completer()
688 queue_work(ep->xdev->workq, &ep->workitem); in bulk_out_completer()
693 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_in() local
703 if (ep->shutting_down || xdev->error) in try_queue_bulk_in()
722 report_io_error(xdev, -ENOMEM); in try_queue_bulk_in()
726 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_in()
727 usb_rcvbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_in()
735 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_in()
760 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_out() local
771 if (ep->shutting_down || xdev->error) in try_queue_bulk_out()
826 report_io_error(xdev, -ENOMEM); in try_queue_bulk_out()
830 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_out()
831 usb_sndbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_out()
839 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_out()
875 static int process_in_opcode(struct xillyusb_dev *xdev, in process_in_opcode() argument
880 struct device *dev = xdev->dev; in process_in_opcode()
883 if (chan_idx >= xdev->num_channels) { in process_in_opcode()
889 chan = &xdev->channels[chan_idx]; in process_in_opcode()
931 struct xillyusb_dev *xdev = ep->xdev; in process_bulk_in() local
932 struct device *dev = xdev->dev; in process_bulk_in()
950 if (xdev->in_bytes_left) { in process_bulk_in()
951 bytes = min(xdev->in_bytes_left, dws << 2); in process_bulk_in()
952 in_bytes_left = xdev->in_bytes_left - bytes; in process_bulk_in()
953 chan_num = xdev->leftover_chan_num; in process_bulk_in()
966 unsigned int in_counter = xdev->in_counter++ & 0x3ff; in process_bulk_in()
974 rc = process_in_opcode(xdev, opcode, chan_num); in process_bulk_in()
988 if (!(chan_num & 1) || chan_idx >= xdev->num_channels || in process_bulk_in()
989 !xdev->channels[chan_idx].read_data_ok) { in process_bulk_in()
994 chan = &xdev->channels[chan_idx]; in process_bulk_in()
1013 xdev->in_bytes_left = in_bytes_left; in process_bulk_in()
1014 xdev->leftover_chan_num = chan_num; in process_bulk_in()
1022 struct xillyusb_dev *xdev = ep->xdev; in bulk_in_work() local
1028 mutex_lock(&xdev->process_in_mutex); in bulk_in_work()
1035 mutex_unlock(&xdev->process_in_mutex); in bulk_in_work()
1038 report_io_error(xdev, rc); in bulk_in_work()
1053 if (!xdev->error) in bulk_in_work()
1062 static int xillyusb_send_opcode(struct xillyusb_dev *xdev, in xillyusb_send_opcode() argument
1065 struct xillyusb_endpoint *ep = xdev->msg_ep; in xillyusb_send_opcode()
1075 mutex_lock(&xdev->msg_mutex); in xillyusb_send_opcode()
1087 xdev->error)) in xillyusb_send_opcode()
1090 if (xdev->error) { in xillyusb_send_opcode()
1091 rc = xdev->error; in xillyusb_send_opcode()
1100 mutex_unlock(&xdev->msg_mutex); in xillyusb_send_opcode()
1124 struct xillyusb_dev *xdev = chan->xdev; in flush_downstream() local
1138 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1149 report_io_error(xdev, -EIO); in flush_downstream()
1155 xdev->error, in flush_downstream()
1158 if (xdev->error) in flush_downstream()
1159 return xdev->error; in flush_downstream()
1172 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1184 xdev->error); in flush_downstream()
1185 if (xdev->error) in flush_downstream()
1186 return xdev->error; in flush_downstream()
1203 xdev->error, in flush_downstream()
1206 if (xdev->error) in flush_downstream()
1207 return xdev->error; in flush_downstream()
1222 struct xillyusb_dev *xdev = chan->xdev; in request_read_anything() local
1227 return xillyusb_send_opcode(xdev, chan_num, opcode, mercy >> sh); in request_read_anything()
1232 struct xillyusb_dev *xdev; in xillyusb_open() local
1239 rc = xillybus_find_inode(inode, (void **)&xdev, &index); in xillyusb_open()
1243 chan = &xdev->channels[index]; in xillyusb_open()
1250 if (xdev->error) in xillyusb_open()
1259 dev_err(xdev->dev, in xillyusb_open()
1266 dev_err(xdev->dev, in xillyusb_open()
1277 kref_get(&xdev->kref); in xillyusb_open()
1288 out_ep = endpoint_alloc(xdev, in xillyusb_open()
1320 report_io_error(xdev, rc); in xillyusb_open()
1362 rc = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_open()
1410 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1423 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_read() local
1502 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1531 if (xdev->error) { in xillyusb_read()
1532 rc = xdev->error; in xillyusb_read()
1542 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1618 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_flush() local
1621 if (!xdev->error) in xillyusb_flush()
1622 dev_warn(xdev->dev, in xillyusb_flush()
1634 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_write() local
1644 if (xdev->error) { in xillyusb_write()
1645 rc = xdev->error; in xillyusb_write()
1665 fifo->fill != fifo->size || xdev->error)) { in xillyusb_write()
1697 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_release() local
1703 rc_read = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_release()
1752 rc_write = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_release()
1760 kref_put(&xdev->kref, cleanup_dev); in xillyusb_release()
1773 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_llseek() local
1810 rc = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_llseek()
1875 if (chan->xdev->error) in xillyusb_poll()
1892 static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev) in xillyusb_setup_base_eps() argument
1894 xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT, in xillyusb_setup_base_eps()
1896 if (!xdev->msg_ep) in xillyusb_setup_base_eps()
1899 if (fifo_init(&xdev->msg_ep->fifo, 13)) /* 8 kiB */ in xillyusb_setup_base_eps()
1902 xdev->msg_ep->fill_mask = -8; /* 8 bytes granularity */ in xillyusb_setup_base_eps()
1904 xdev->in_ep = endpoint_alloc(xdev, IN_EP_NUM | USB_DIR_IN, in xillyusb_setup_base_eps()
1906 if (!xdev->in_ep) in xillyusb_setup_base_eps()
1909 try_queue_bulk_in(xdev->in_ep); in xillyusb_setup_base_eps()
1914 endpoint_dealloc(xdev->msg_ep); /* Also frees FIFO mem if allocated */ in xillyusb_setup_base_eps()
1918 static int setup_channels(struct xillyusb_dev *xdev, in setup_channels() argument
1929 xdev->channels = chan; in setup_channels()
1935 chan->xdev = xdev; in setup_channels()
1973 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_discovery() local
1981 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_discovery()
1994 rc = setup_channels(xdev, bogus_chandesc, 1); in xillyusb_discovery()
2004 chan = xdev->channels; in xillyusb_discovery()
2009 xdev->num_channels = 1; in xillyusb_discovery()
2011 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_REQ_IDT, 0); in xillyusb_discovery()
2022 if (xdev->error) { in xillyusb_discovery()
2023 rc = xdev->error; in xillyusb_discovery()
2073 rc = setup_channels(xdev, (void *)idt + 3, num_channels); in xillyusb_discovery()
2085 flush_workqueue(xdev->workq); in xillyusb_discovery()
2087 xdev->num_channels = num_channels; in xillyusb_discovery()
2093 THIS_MODULE, xdev, in xillyusb_discovery()
2116 struct xillyusb_dev *xdev; in xillyusb_probe() local
2119 xdev = kzalloc(sizeof(*xdev), GFP_KERNEL); in xillyusb_probe()
2120 if (!xdev) in xillyusb_probe()
2123 kref_init(&xdev->kref); in xillyusb_probe()
2124 mutex_init(&xdev->process_in_mutex); in xillyusb_probe()
2125 mutex_init(&xdev->msg_mutex); in xillyusb_probe()
2127 xdev->udev = usb_get_dev(interface_to_usbdev(interface)); in xillyusb_probe()
2128 xdev->dev = &interface->dev; in xillyusb_probe()
2129 xdev->error = 0; in xillyusb_probe()
2130 spin_lock_init(&xdev->error_lock); in xillyusb_probe()
2131 xdev->in_counter = 0; in xillyusb_probe()
2132 xdev->in_bytes_left = 0; in xillyusb_probe()
2133 xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI, 0); in xillyusb_probe()
2135 if (!xdev->workq) { in xillyusb_probe()
2141 INIT_WORK(&xdev->wakeup_workitem, wakeup_all); in xillyusb_probe()
2143 usb_set_intfdata(interface, xdev); in xillyusb_probe()
2145 rc = xillyusb_setup_base_eps(xdev); in xillyusb_probe()
2156 endpoint_quiesce(xdev->in_ep); in xillyusb_probe()
2157 endpoint_quiesce(xdev->msg_ep); in xillyusb_probe()
2161 kref_put(&xdev->kref, cleanup_dev); in xillyusb_probe()
2167 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_disconnect() local
2168 struct xillyusb_endpoint *msg_ep = xdev->msg_ep; in xillyusb_disconnect()
2173 xillybus_cleanup_chrdev(xdev, &interface->dev); in xillyusb_disconnect()
2181 xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_disconnect()
2191 msg_ep->drained || xdev->error, in xillyusb_disconnect()
2198 report_io_error(xdev, -ENODEV); /* Discourage further activity */ in xillyusb_disconnect()
2207 for (i = 0; i < xdev->num_channels; i++) { in xillyusb_disconnect()
2208 struct xillyusb_channel *chan = &xdev->channels[i]; in xillyusb_disconnect()
2221 endpoint_quiesce(xdev->in_ep); in xillyusb_disconnect()
2222 endpoint_quiesce(xdev->msg_ep); in xillyusb_disconnect()
2226 xdev->dev = NULL; in xillyusb_disconnect()
2228 kref_put(&xdev->kref, cleanup_dev); in xillyusb_disconnect()