Lines Matching refs:xdev
90 struct xillyusb_dev *xdev; member
119 struct xillyusb_dev *xdev; member
488 *endpoint_alloc(struct xillyusb_dev *xdev, in endpoint_alloc() argument
517 ep->xdev = xdev; in endpoint_alloc()
549 struct xillyusb_dev *xdev = in cleanup_dev() local
552 if (xdev->in_ep) in cleanup_dev()
553 endpoint_dealloc(xdev->in_ep); in cleanup_dev()
555 if (xdev->msg_ep) in cleanup_dev()
556 endpoint_dealloc(xdev->msg_ep); in cleanup_dev()
558 if (xdev->workq) in cleanup_dev()
559 destroy_workqueue(xdev->workq); in cleanup_dev()
561 usb_put_dev(xdev->udev); in cleanup_dev()
562 kfree(xdev->channels); /* Argument may be NULL, and that's fine */ in cleanup_dev()
563 kfree(xdev); in cleanup_dev()
578 struct xillyusb_dev *xdev = container_of(work, struct xillyusb_dev, in wakeup_all() local
581 mutex_lock(&xdev->process_in_mutex); in wakeup_all()
583 for (i = 0; i < xdev->num_channels; i++) { in wakeup_all()
584 struct xillyusb_channel *chan = &xdev->channels[i]; in wakeup_all()
605 mutex_unlock(&xdev->process_in_mutex); in wakeup_all()
607 wake_up_interruptible(&xdev->msg_ep->fifo.waitq); in wakeup_all()
609 kref_put(&xdev->kref, cleanup_dev); in wakeup_all()
612 static void report_io_error(struct xillyusb_dev *xdev, in report_io_error() argument
618 spin_lock_irqsave(&xdev->error_lock, flags); in report_io_error()
619 if (!xdev->error) { in report_io_error()
620 xdev->error = errcode; in report_io_error()
623 spin_unlock_irqrestore(&xdev->error_lock, flags); in report_io_error()
626 kref_get(&xdev->kref); /* xdev is used by work item */ in report_io_error()
627 queue_work(wakeup_wq, &xdev->wakeup_workitem); in report_io_error()
643 flush_work(&chan->xdev->in_ep->workitem); in safely_assign_in_fifo()
656 report_io_error(ep->xdev, -EIO); in bulk_in_completer()
673 queue_work(ep->xdev->workq, &ep->workitem); in bulk_in_completer()
686 report_io_error(ep->xdev, -EIO); in bulk_out_completer()
694 queue_work(ep->xdev->workq, &ep->workitem); in bulk_out_completer()
699 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_in() local
709 if (ep->shutting_down || xdev->error) in try_queue_bulk_in()
728 report_io_error(xdev, -ENOMEM); in try_queue_bulk_in()
732 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_in()
733 usb_rcvbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_in()
741 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_in()
766 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_out() local
777 if (ep->shutting_down || xdev->error) in try_queue_bulk_out()
832 report_io_error(xdev, -ENOMEM); in try_queue_bulk_out()
836 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_out()
837 usb_sndbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_out()
845 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_out()
881 static int process_in_opcode(struct xillyusb_dev *xdev, in process_in_opcode() argument
886 struct device *dev = xdev->dev; in process_in_opcode()
889 if (chan_idx >= xdev->num_channels) { in process_in_opcode()
895 chan = &xdev->channels[chan_idx]; in process_in_opcode()
937 struct xillyusb_dev *xdev = ep->xdev; in process_bulk_in() local
938 struct device *dev = xdev->dev; in process_bulk_in()
956 if (xdev->in_bytes_left) { in process_bulk_in()
957 bytes = min(xdev->in_bytes_left, dws << 2); in process_bulk_in()
958 in_bytes_left = xdev->in_bytes_left - bytes; in process_bulk_in()
959 chan_num = xdev->leftover_chan_num; in process_bulk_in()
972 unsigned int in_counter = xdev->in_counter++ & 0x3ff; in process_bulk_in()
980 rc = process_in_opcode(xdev, opcode, chan_num); in process_bulk_in()
994 if (!(chan_num & 1) || chan_idx >= xdev->num_channels || in process_bulk_in()
995 !xdev->channels[chan_idx].read_data_ok) { in process_bulk_in()
1000 chan = &xdev->channels[chan_idx]; in process_bulk_in()
1019 xdev->in_bytes_left = in_bytes_left; in process_bulk_in()
1020 xdev->leftover_chan_num = chan_num; in process_bulk_in()
1028 struct xillyusb_dev *xdev = ep->xdev; in bulk_in_work() local
1034 mutex_lock(&xdev->process_in_mutex); in bulk_in_work()
1041 mutex_unlock(&xdev->process_in_mutex); in bulk_in_work()
1044 report_io_error(xdev, rc); in bulk_in_work()
1059 if (!xdev->error) in bulk_in_work()
1068 static int xillyusb_send_opcode(struct xillyusb_dev *xdev, in xillyusb_send_opcode() argument
1071 struct xillyusb_endpoint *ep = xdev->msg_ep; in xillyusb_send_opcode()
1081 mutex_lock(&xdev->msg_mutex); in xillyusb_send_opcode()
1093 xdev->error)) in xillyusb_send_opcode()
1096 if (xdev->error) { in xillyusb_send_opcode()
1097 rc = xdev->error; in xillyusb_send_opcode()
1106 mutex_unlock(&xdev->msg_mutex); in xillyusb_send_opcode()
1130 struct xillyusb_dev *xdev = chan->xdev; in flush_downstream() local
1144 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1155 report_io_error(xdev, -EIO); in flush_downstream()
1161 xdev->error, in flush_downstream()
1164 if (xdev->error) in flush_downstream()
1165 return xdev->error; in flush_downstream()
1178 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1190 xdev->error); in flush_downstream()
1191 if (xdev->error) in flush_downstream()
1192 return xdev->error; in flush_downstream()
1209 xdev->error, in flush_downstream()
1212 if (xdev->error) in flush_downstream()
1213 return xdev->error; in flush_downstream()
1228 struct xillyusb_dev *xdev = chan->xdev; in request_read_anything() local
1233 return xillyusb_send_opcode(xdev, chan_num, opcode, mercy >> sh); in request_read_anything()
1238 struct xillyusb_dev *xdev; in xillyusb_open() local
1247 rc = xillybus_find_inode(inode, (void **)&xdev, &index); in xillyusb_open()
1253 kref_get(&xdev->kref); in xillyusb_open()
1256 chan = &xdev->channels[index]; in xillyusb_open()
1263 if (xdev->error) in xillyusb_open()
1272 dev_err(xdev->dev, in xillyusb_open()
1279 dev_err(xdev->dev, in xillyusb_open()
1299 out_ep = endpoint_alloc(xdev, in xillyusb_open()
1331 report_io_error(xdev, rc); in xillyusb_open()
1373 rc = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_open()
1421 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1426 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1435 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_read() local
1514 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1543 if (xdev->error) { in xillyusb_read()
1544 rc = xdev->error; in xillyusb_read()
1554 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1630 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_flush() local
1633 if (!xdev->error) in xillyusb_flush()
1634 dev_warn(xdev->dev, in xillyusb_flush()
1646 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_write() local
1656 if (xdev->error) { in xillyusb_write()
1657 rc = xdev->error; in xillyusb_write()
1677 fifo->fill != fifo->size || xdev->error)) { in xillyusb_write()
1709 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_release() local
1715 rc_read = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_release()
1764 rc_write = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_release()
1772 kref_put(&xdev->kref, cleanup_dev); in xillyusb_release()
1785 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_llseek() local
1822 rc = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_llseek()
1887 if (chan->xdev->error) in xillyusb_poll()
1904 static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev) in xillyusb_setup_base_eps() argument
1906 struct usb_device *udev = xdev->udev; in xillyusb_setup_base_eps()
1913 xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT, in xillyusb_setup_base_eps()
1915 if (!xdev->msg_ep) in xillyusb_setup_base_eps()
1918 if (fifo_init(&xdev->msg_ep->fifo, 13)) /* 8 kiB */ in xillyusb_setup_base_eps()
1921 xdev->msg_ep->fill_mask = -8; /* 8 bytes granularity */ in xillyusb_setup_base_eps()
1923 xdev->in_ep = endpoint_alloc(xdev, IN_EP_NUM | USB_DIR_IN, in xillyusb_setup_base_eps()
1925 if (!xdev->in_ep) in xillyusb_setup_base_eps()
1928 try_queue_bulk_in(xdev->in_ep); in xillyusb_setup_base_eps()
1933 endpoint_dealloc(xdev->msg_ep); /* Also frees FIFO mem if allocated */ in xillyusb_setup_base_eps()
1934 xdev->msg_ep = NULL; in xillyusb_setup_base_eps()
1938 static int setup_channels(struct xillyusb_dev *xdev, in setup_channels() argument
1942 struct usb_device *udev = xdev->udev; in setup_channels()
1956 chan->xdev = xdev; in setup_channels()
1981 dev_err(xdev->dev, in setup_channels()
1997 xdev->channels = new_channels; in setup_channels()
2004 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_discovery() local
2012 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_discovery()
2025 rc = setup_channels(xdev, bogus_chandesc, 1); in xillyusb_discovery()
2035 chan = xdev->channels; in xillyusb_discovery()
2040 xdev->num_channels = 1; in xillyusb_discovery()
2042 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_REQ_IDT, 0); in xillyusb_discovery()
2053 if (xdev->error) { in xillyusb_discovery()
2054 rc = xdev->error; in xillyusb_discovery()
2104 rc = setup_channels(xdev, (void *)idt + 3, num_channels); in xillyusb_discovery()
2117 flush_workqueue(xdev->workq); in xillyusb_discovery()
2118 flush_work(&xdev->wakeup_workitem); in xillyusb_discovery()
2120 xdev->num_channels = num_channels; in xillyusb_discovery()
2126 THIS_MODULE, xdev, in xillyusb_discovery()
2149 struct xillyusb_dev *xdev; in xillyusb_probe() local
2152 xdev = kzalloc(sizeof(*xdev), GFP_KERNEL); in xillyusb_probe()
2153 if (!xdev) in xillyusb_probe()
2156 kref_init(&xdev->kref); in xillyusb_probe()
2157 mutex_init(&xdev->process_in_mutex); in xillyusb_probe()
2158 mutex_init(&xdev->msg_mutex); in xillyusb_probe()
2160 xdev->udev = usb_get_dev(interface_to_usbdev(interface)); in xillyusb_probe()
2161 xdev->dev = &interface->dev; in xillyusb_probe()
2162 xdev->error = 0; in xillyusb_probe()
2163 spin_lock_init(&xdev->error_lock); in xillyusb_probe()
2164 xdev->in_counter = 0; in xillyusb_probe()
2165 xdev->in_bytes_left = 0; in xillyusb_probe()
2166 xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI, 0); in xillyusb_probe()
2168 if (!xdev->workq) { in xillyusb_probe()
2174 INIT_WORK(&xdev->wakeup_workitem, wakeup_all); in xillyusb_probe()
2176 usb_set_intfdata(interface, xdev); in xillyusb_probe()
2178 rc = xillyusb_setup_base_eps(xdev); in xillyusb_probe()
2189 endpoint_quiesce(xdev->in_ep); in xillyusb_probe()
2190 endpoint_quiesce(xdev->msg_ep); in xillyusb_probe()
2194 kref_put(&xdev->kref, cleanup_dev); in xillyusb_probe()
2200 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_disconnect() local
2201 struct xillyusb_endpoint *msg_ep = xdev->msg_ep; in xillyusb_disconnect()
2206 xillybus_cleanup_chrdev(xdev, &interface->dev); in xillyusb_disconnect()
2214 xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_disconnect()
2224 msg_ep->drained || xdev->error, in xillyusb_disconnect()
2231 report_io_error(xdev, -ENODEV); /* Discourage further activity */ in xillyusb_disconnect()
2240 for (i = 0; i < xdev->num_channels; i++) { in xillyusb_disconnect()
2241 struct xillyusb_channel *chan = &xdev->channels[i]; in xillyusb_disconnect()
2254 endpoint_quiesce(xdev->in_ep); in xillyusb_disconnect()
2255 endpoint_quiesce(xdev->msg_ep); in xillyusb_disconnect()
2259 xdev->dev = NULL; in xillyusb_disconnect()
2262 kref_put(&xdev->kref, cleanup_dev); in xillyusb_disconnect()