Lines Matching refs:xdev
89 struct xillyusb_dev *xdev; member
118 struct xillyusb_dev *xdev; member
487 *endpoint_alloc(struct xillyusb_dev *xdev, in endpoint_alloc() argument
516 ep->xdev = xdev; in endpoint_alloc()
548 struct xillyusb_dev *xdev = in cleanup_dev() local
551 if (xdev->in_ep) in cleanup_dev()
552 endpoint_dealloc(xdev->in_ep); in cleanup_dev()
554 if (xdev->msg_ep) in cleanup_dev()
555 endpoint_dealloc(xdev->msg_ep); in cleanup_dev()
557 if (xdev->workq) in cleanup_dev()
558 destroy_workqueue(xdev->workq); in cleanup_dev()
560 usb_put_dev(xdev->udev); in cleanup_dev()
561 kfree(xdev->channels); /* Argument may be NULL, and that's fine */ in cleanup_dev()
562 kfree(xdev); in cleanup_dev()
581 struct xillyusb_dev *xdev = container_of(work, struct xillyusb_dev, in wakeup_all() local
584 mutex_lock(&xdev->process_in_mutex); in wakeup_all()
586 for (i = 0; i < xdev->num_channels; i++) { in wakeup_all()
587 struct xillyusb_channel *chan = &xdev->channels[i]; in wakeup_all()
608 mutex_unlock(&xdev->process_in_mutex); in wakeup_all()
610 wake_up_interruptible(&xdev->msg_ep->fifo.waitq); in wakeup_all()
612 kref_put(&xdev->kref, cleanup_dev); in wakeup_all()
615 static void report_io_error(struct xillyusb_dev *xdev, in report_io_error() argument
621 spin_lock_irqsave(&xdev->error_lock, flags); in report_io_error()
622 if (!xdev->error) { in report_io_error()
623 xdev->error = errcode; in report_io_error()
626 spin_unlock_irqrestore(&xdev->error_lock, flags); in report_io_error()
629 kref_get(&xdev->kref); /* xdev is used by work item */ in report_io_error()
630 queue_work(xdev->workq, &xdev->wakeup_workitem); in report_io_error()
646 flush_work(&chan->xdev->in_ep->workitem); in safely_assign_in_fifo()
659 report_io_error(ep->xdev, -EIO); in bulk_in_completer()
676 queue_work(ep->xdev->workq, &ep->workitem); in bulk_in_completer()
689 report_io_error(ep->xdev, -EIO); in bulk_out_completer()
697 queue_work(ep->xdev->workq, &ep->workitem); in bulk_out_completer()
702 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_in() local
712 if (ep->shutting_down || xdev->error) in try_queue_bulk_in()
731 report_io_error(xdev, -ENOMEM); in try_queue_bulk_in()
735 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_in()
736 usb_rcvbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_in()
744 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_in()
769 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_out() local
780 if (ep->shutting_down || xdev->error) in try_queue_bulk_out()
835 report_io_error(xdev, -ENOMEM); in try_queue_bulk_out()
839 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_out()
840 usb_sndbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_out()
848 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_out()
884 static int process_in_opcode(struct xillyusb_dev *xdev, in process_in_opcode() argument
889 struct device *dev = xdev->dev; in process_in_opcode()
892 if (chan_idx >= xdev->num_channels) { in process_in_opcode()
898 chan = &xdev->channels[chan_idx]; in process_in_opcode()
940 struct xillyusb_dev *xdev = ep->xdev; in process_bulk_in() local
941 struct device *dev = xdev->dev; in process_bulk_in()
959 if (xdev->in_bytes_left) { in process_bulk_in()
960 bytes = min(xdev->in_bytes_left, dws << 2); in process_bulk_in()
961 in_bytes_left = xdev->in_bytes_left - bytes; in process_bulk_in()
962 chan_num = xdev->leftover_chan_num; in process_bulk_in()
975 unsigned int in_counter = xdev->in_counter++ & 0x3ff; in process_bulk_in()
983 rc = process_in_opcode(xdev, opcode, chan_num); in process_bulk_in()
997 if (!(chan_num & 1) || chan_idx >= xdev->num_channels || in process_bulk_in()
998 !xdev->channels[chan_idx].read_data_ok) { in process_bulk_in()
1003 chan = &xdev->channels[chan_idx]; in process_bulk_in()
1022 xdev->in_bytes_left = in_bytes_left; in process_bulk_in()
1023 xdev->leftover_chan_num = chan_num; in process_bulk_in()
1031 struct xillyusb_dev *xdev = ep->xdev; in bulk_in_work() local
1037 mutex_lock(&xdev->process_in_mutex); in bulk_in_work()
1044 mutex_unlock(&xdev->process_in_mutex); in bulk_in_work()
1047 report_io_error(xdev, rc); in bulk_in_work()
1062 if (!xdev->error) in bulk_in_work()
1071 static int xillyusb_send_opcode(struct xillyusb_dev *xdev, in xillyusb_send_opcode() argument
1074 struct xillyusb_endpoint *ep = xdev->msg_ep; in xillyusb_send_opcode()
1084 mutex_lock(&xdev->msg_mutex); in xillyusb_send_opcode()
1096 xdev->error)) in xillyusb_send_opcode()
1099 if (xdev->error) { in xillyusb_send_opcode()
1100 rc = xdev->error; in xillyusb_send_opcode()
1109 mutex_unlock(&xdev->msg_mutex); in xillyusb_send_opcode()
1133 struct xillyusb_dev *xdev = chan->xdev; in flush_downstream() local
1147 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1158 report_io_error(xdev, -EIO); in flush_downstream()
1164 xdev->error, in flush_downstream()
1167 if (xdev->error) in flush_downstream()
1168 return xdev->error; in flush_downstream()
1181 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1193 xdev->error); in flush_downstream()
1194 if (xdev->error) in flush_downstream()
1195 return xdev->error; in flush_downstream()
1212 xdev->error, in flush_downstream()
1215 if (xdev->error) in flush_downstream()
1216 return xdev->error; in flush_downstream()
1231 struct xillyusb_dev *xdev = chan->xdev; in request_read_anything() local
1236 return xillyusb_send_opcode(xdev, chan_num, opcode, mercy >> sh); in request_read_anything()
1241 struct xillyusb_dev *xdev; in xillyusb_open() local
1250 rc = xillybus_find_inode(inode, (void **)&xdev, &index); in xillyusb_open()
1256 kref_get(&xdev->kref); in xillyusb_open()
1259 chan = &xdev->channels[index]; in xillyusb_open()
1266 if (xdev->error) in xillyusb_open()
1275 dev_err(xdev->dev, in xillyusb_open()
1282 dev_err(xdev->dev, in xillyusb_open()
1302 out_ep = endpoint_alloc(xdev, in xillyusb_open()
1334 report_io_error(xdev, rc); in xillyusb_open()
1376 rc = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_open()
1424 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1429 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1438 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_read() local
1517 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1546 if (xdev->error) { in xillyusb_read()
1547 rc = xdev->error; in xillyusb_read()
1557 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1633 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_flush() local
1636 if (!xdev->error) in xillyusb_flush()
1637 dev_warn(xdev->dev, in xillyusb_flush()
1649 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_write() local
1659 if (xdev->error) { in xillyusb_write()
1660 rc = xdev->error; in xillyusb_write()
1680 fifo->fill != fifo->size || xdev->error)) { in xillyusb_write()
1712 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_release() local
1718 rc_read = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_release()
1767 rc_write = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_release()
1775 kref_put(&xdev->kref, cleanup_dev); in xillyusb_release()
1788 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_llseek() local
1825 rc = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_llseek()
1890 if (chan->xdev->error) in xillyusb_poll()
1907 static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev) in xillyusb_setup_base_eps() argument
1909 xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT, in xillyusb_setup_base_eps()
1911 if (!xdev->msg_ep) in xillyusb_setup_base_eps()
1914 if (fifo_init(&xdev->msg_ep->fifo, 13)) /* 8 kiB */ in xillyusb_setup_base_eps()
1917 xdev->msg_ep->fill_mask = -8; /* 8 bytes granularity */ in xillyusb_setup_base_eps()
1919 xdev->in_ep = endpoint_alloc(xdev, IN_EP_NUM | USB_DIR_IN, in xillyusb_setup_base_eps()
1921 if (!xdev->in_ep) in xillyusb_setup_base_eps()
1924 try_queue_bulk_in(xdev->in_ep); in xillyusb_setup_base_eps()
1929 endpoint_dealloc(xdev->msg_ep); /* Also frees FIFO mem if allocated */ in xillyusb_setup_base_eps()
1930 xdev->msg_ep = NULL; in xillyusb_setup_base_eps()
1934 static int setup_channels(struct xillyusb_dev *xdev, in setup_channels() argument
1945 xdev->channels = chan; in setup_channels()
1951 chan->xdev = xdev; in setup_channels()
1989 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_discovery() local
1997 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_discovery()
2010 rc = setup_channels(xdev, bogus_chandesc, 1); in xillyusb_discovery()
2020 chan = xdev->channels; in xillyusb_discovery()
2025 xdev->num_channels = 1; in xillyusb_discovery()
2027 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_REQ_IDT, 0); in xillyusb_discovery()
2038 if (xdev->error) { in xillyusb_discovery()
2039 rc = xdev->error; in xillyusb_discovery()
2089 rc = setup_channels(xdev, (void *)idt + 3, num_channels); in xillyusb_discovery()
2101 flush_workqueue(xdev->workq); in xillyusb_discovery()
2103 xdev->num_channels = num_channels; in xillyusb_discovery()
2109 THIS_MODULE, xdev, in xillyusb_discovery()
2132 struct xillyusb_dev *xdev; in xillyusb_probe() local
2135 xdev = kzalloc(sizeof(*xdev), GFP_KERNEL); in xillyusb_probe()
2136 if (!xdev) in xillyusb_probe()
2139 kref_init(&xdev->kref); in xillyusb_probe()
2140 mutex_init(&xdev->process_in_mutex); in xillyusb_probe()
2141 mutex_init(&xdev->msg_mutex); in xillyusb_probe()
2143 xdev->udev = usb_get_dev(interface_to_usbdev(interface)); in xillyusb_probe()
2144 xdev->dev = &interface->dev; in xillyusb_probe()
2145 xdev->error = 0; in xillyusb_probe()
2146 spin_lock_init(&xdev->error_lock); in xillyusb_probe()
2147 xdev->in_counter = 0; in xillyusb_probe()
2148 xdev->in_bytes_left = 0; in xillyusb_probe()
2149 xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI, 0); in xillyusb_probe()
2151 if (!xdev->workq) { in xillyusb_probe()
2157 INIT_WORK(&xdev->wakeup_workitem, wakeup_all); in xillyusb_probe()
2159 usb_set_intfdata(interface, xdev); in xillyusb_probe()
2161 rc = xillyusb_setup_base_eps(xdev); in xillyusb_probe()
2172 endpoint_quiesce(xdev->in_ep); in xillyusb_probe()
2173 endpoint_quiesce(xdev->msg_ep); in xillyusb_probe()
2177 kref_put(&xdev->kref, cleanup_dev); in xillyusb_probe()
2183 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_disconnect() local
2184 struct xillyusb_endpoint *msg_ep = xdev->msg_ep; in xillyusb_disconnect()
2189 xillybus_cleanup_chrdev(xdev, &interface->dev); in xillyusb_disconnect()
2197 xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_disconnect()
2207 msg_ep->drained || xdev->error, in xillyusb_disconnect()
2214 report_io_error(xdev, -ENODEV); /* Discourage further activity */ in xillyusb_disconnect()
2223 for (i = 0; i < xdev->num_channels; i++) { in xillyusb_disconnect()
2224 struct xillyusb_channel *chan = &xdev->channels[i]; in xillyusb_disconnect()
2237 endpoint_quiesce(xdev->in_ep); in xillyusb_disconnect()
2238 endpoint_quiesce(xdev->msg_ep); in xillyusb_disconnect()
2242 xdev->dev = NULL; in xillyusb_disconnect()
2245 kref_put(&xdev->kref, cleanup_dev); in xillyusb_disconnect()