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 usb_put_dev(xdev->udev); in cleanup_dev()
553 kfree(xdev->channels); /* Argument may be NULL, and that's fine */ in cleanup_dev()
554 kfree(xdev); in cleanup_dev()
573 struct xillyusb_dev *xdev = container_of(work, struct xillyusb_dev, in wakeup_all() local
576 mutex_lock(&xdev->process_in_mutex); in wakeup_all()
578 for (i = 0; i < xdev->num_channels; i++) { in wakeup_all()
579 struct xillyusb_channel *chan = &xdev->channels[i]; in wakeup_all()
600 mutex_unlock(&xdev->process_in_mutex); in wakeup_all()
602 wake_up_interruptible(&xdev->msg_ep->fifo.waitq); in wakeup_all()
604 kref_put(&xdev->kref, cleanup_dev); in wakeup_all()
607 static void report_io_error(struct xillyusb_dev *xdev, in report_io_error() argument
613 spin_lock_irqsave(&xdev->error_lock, flags); in report_io_error()
614 if (!xdev->error) { in report_io_error()
615 xdev->error = errcode; in report_io_error()
618 spin_unlock_irqrestore(&xdev->error_lock, flags); in report_io_error()
621 kref_get(&xdev->kref); /* xdev is used by work item */ in report_io_error()
622 queue_work(xdev->workq, &xdev->wakeup_workitem); in report_io_error()
638 flush_work(&chan->xdev->in_ep->workitem); in safely_assign_in_fifo()
651 report_io_error(ep->xdev, -EIO); in bulk_in_completer()
668 queue_work(ep->xdev->workq, &ep->workitem); in bulk_in_completer()
681 report_io_error(ep->xdev, -EIO); in bulk_out_completer()
689 queue_work(ep->xdev->workq, &ep->workitem); in bulk_out_completer()
694 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_in() local
704 if (ep->shutting_down || xdev->error) in try_queue_bulk_in()
723 report_io_error(xdev, -ENOMEM); in try_queue_bulk_in()
727 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_in()
728 usb_rcvbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_in()
736 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_in()
761 struct xillyusb_dev *xdev = ep->xdev; in try_queue_bulk_out() local
772 if (ep->shutting_down || xdev->error) in try_queue_bulk_out()
827 report_io_error(xdev, -ENOMEM); in try_queue_bulk_out()
831 usb_fill_bulk_urb(urb, xdev->udev, in try_queue_bulk_out()
832 usb_sndbulkpipe(xdev->udev, ep->ep_num), in try_queue_bulk_out()
840 report_io_error(xdev, (rc == -ENOMEM) ? -ENOMEM : in try_queue_bulk_out()
876 static int process_in_opcode(struct xillyusb_dev *xdev, in process_in_opcode() argument
881 struct device *dev = xdev->dev; in process_in_opcode()
884 if (chan_idx >= xdev->num_channels) { in process_in_opcode()
890 chan = &xdev->channels[chan_idx]; in process_in_opcode()
932 struct xillyusb_dev *xdev = ep->xdev; in process_bulk_in() local
933 struct device *dev = xdev->dev; in process_bulk_in()
951 if (xdev->in_bytes_left) { in process_bulk_in()
952 bytes = min(xdev->in_bytes_left, dws << 2); in process_bulk_in()
953 in_bytes_left = xdev->in_bytes_left - bytes; in process_bulk_in()
954 chan_num = xdev->leftover_chan_num; in process_bulk_in()
967 unsigned int in_counter = xdev->in_counter++ & 0x3ff; in process_bulk_in()
975 rc = process_in_opcode(xdev, opcode, chan_num); in process_bulk_in()
989 if (!(chan_num & 1) || chan_idx >= xdev->num_channels || in process_bulk_in()
990 !xdev->channels[chan_idx].read_data_ok) { in process_bulk_in()
995 chan = &xdev->channels[chan_idx]; in process_bulk_in()
1014 xdev->in_bytes_left = in_bytes_left; in process_bulk_in()
1015 xdev->leftover_chan_num = chan_num; in process_bulk_in()
1023 struct xillyusb_dev *xdev = ep->xdev; in bulk_in_work() local
1029 mutex_lock(&xdev->process_in_mutex); in bulk_in_work()
1036 mutex_unlock(&xdev->process_in_mutex); in bulk_in_work()
1039 report_io_error(xdev, rc); in bulk_in_work()
1054 if (!xdev->error) in bulk_in_work()
1063 static int xillyusb_send_opcode(struct xillyusb_dev *xdev, in xillyusb_send_opcode() argument
1066 struct xillyusb_endpoint *ep = xdev->msg_ep; in xillyusb_send_opcode()
1076 mutex_lock(&xdev->msg_mutex); in xillyusb_send_opcode()
1088 xdev->error)) in xillyusb_send_opcode()
1091 if (xdev->error) { in xillyusb_send_opcode()
1092 rc = xdev->error; in xillyusb_send_opcode()
1101 mutex_unlock(&xdev->msg_mutex); in xillyusb_send_opcode()
1125 struct xillyusb_dev *xdev = chan->xdev; in flush_downstream() local
1139 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1150 report_io_error(xdev, -EIO); in flush_downstream()
1156 xdev->error, in flush_downstream()
1159 if (xdev->error) in flush_downstream()
1160 return xdev->error; in flush_downstream()
1173 rc = xillyusb_send_opcode(xdev, chan_num, in flush_downstream()
1185 xdev->error); in flush_downstream()
1186 if (xdev->error) in flush_downstream()
1187 return xdev->error; in flush_downstream()
1204 xdev->error, in flush_downstream()
1207 if (xdev->error) in flush_downstream()
1208 return xdev->error; in flush_downstream()
1223 struct xillyusb_dev *xdev = chan->xdev; in request_read_anything() local
1228 return xillyusb_send_opcode(xdev, chan_num, opcode, mercy >> sh); in request_read_anything()
1233 struct xillyusb_dev *xdev; in xillyusb_open() local
1240 rc = xillybus_find_inode(inode, (void **)&xdev, &index); in xillyusb_open()
1244 chan = &xdev->channels[index]; in xillyusb_open()
1251 if (xdev->error) in xillyusb_open()
1260 dev_err(xdev->dev, in xillyusb_open()
1267 dev_err(xdev->dev, in xillyusb_open()
1278 kref_get(&xdev->kref); in xillyusb_open()
1289 out_ep = endpoint_alloc(xdev, in xillyusb_open()
1321 report_io_error(xdev, rc); in xillyusb_open()
1363 rc = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_open()
1411 kref_put(&xdev->kref, cleanup_dev); in xillyusb_open()
1424 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_read() local
1503 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1532 if (xdev->error) { in xillyusb_read()
1533 rc = xdev->error; in xillyusb_read()
1543 rc = xillyusb_send_opcode(xdev, chan_num, in xillyusb_read()
1619 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_flush() local
1622 if (!xdev->error) in xillyusb_flush()
1623 dev_warn(xdev->dev, in xillyusb_flush()
1635 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_write() local
1645 if (xdev->error) { in xillyusb_write()
1646 rc = xdev->error; in xillyusb_write()
1666 fifo->fill != fifo->size || xdev->error)) { in xillyusb_write()
1698 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_release() local
1704 rc_read = xillyusb_send_opcode(xdev, (chan->chan_idx << 1) | 1, in xillyusb_release()
1753 rc_write = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_release()
1761 kref_put(&xdev->kref, cleanup_dev); in xillyusb_release()
1774 struct xillyusb_dev *xdev = chan->xdev; in xillyusb_llseek() local
1811 rc = xillyusb_send_opcode(xdev, chan->chan_idx << 1, in xillyusb_llseek()
1876 if (chan->xdev->error) in xillyusb_poll()
1893 static int xillyusb_setup_base_eps(struct xillyusb_dev *xdev) in xillyusb_setup_base_eps() argument
1895 xdev->msg_ep = endpoint_alloc(xdev, MSG_EP_NUM | USB_DIR_OUT, in xillyusb_setup_base_eps()
1897 if (!xdev->msg_ep) in xillyusb_setup_base_eps()
1900 if (fifo_init(&xdev->msg_ep->fifo, 13)) /* 8 kiB */ in xillyusb_setup_base_eps()
1903 xdev->msg_ep->fill_mask = -8; /* 8 bytes granularity */ in xillyusb_setup_base_eps()
1905 xdev->in_ep = endpoint_alloc(xdev, IN_EP_NUM | USB_DIR_IN, in xillyusb_setup_base_eps()
1907 if (!xdev->in_ep) in xillyusb_setup_base_eps()
1910 try_queue_bulk_in(xdev->in_ep); in xillyusb_setup_base_eps()
1915 endpoint_dealloc(xdev->msg_ep); /* Also frees FIFO mem if allocated */ in xillyusb_setup_base_eps()
1916 xdev->msg_ep = NULL; in xillyusb_setup_base_eps()
1920 static int setup_channels(struct xillyusb_dev *xdev, in setup_channels() argument
1931 xdev->channels = chan; in setup_channels()
1937 chan->xdev = xdev; in setup_channels()
1975 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_discovery() local
1983 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_discovery()
1996 rc = setup_channels(xdev, bogus_chandesc, 1); in xillyusb_discovery()
2006 chan = xdev->channels; in xillyusb_discovery()
2011 xdev->num_channels = 1; in xillyusb_discovery()
2013 rc = xillyusb_send_opcode(xdev, ~0, OPCODE_REQ_IDT, 0); in xillyusb_discovery()
2024 if (xdev->error) { in xillyusb_discovery()
2025 rc = xdev->error; in xillyusb_discovery()
2075 rc = setup_channels(xdev, (void *)idt + 3, num_channels); in xillyusb_discovery()
2087 flush_workqueue(xdev->workq); in xillyusb_discovery()
2089 xdev->num_channels = num_channels; in xillyusb_discovery()
2095 THIS_MODULE, xdev, in xillyusb_discovery()
2118 struct xillyusb_dev *xdev; in xillyusb_probe() local
2121 xdev = kzalloc(sizeof(*xdev), GFP_KERNEL); in xillyusb_probe()
2122 if (!xdev) in xillyusb_probe()
2125 kref_init(&xdev->kref); in xillyusb_probe()
2126 mutex_init(&xdev->process_in_mutex); in xillyusb_probe()
2127 mutex_init(&xdev->msg_mutex); in xillyusb_probe()
2129 xdev->udev = usb_get_dev(interface_to_usbdev(interface)); in xillyusb_probe()
2130 xdev->dev = &interface->dev; in xillyusb_probe()
2131 xdev->error = 0; in xillyusb_probe()
2132 spin_lock_init(&xdev->error_lock); in xillyusb_probe()
2133 xdev->in_counter = 0; in xillyusb_probe()
2134 xdev->in_bytes_left = 0; in xillyusb_probe()
2135 xdev->workq = alloc_workqueue(xillyname, WQ_HIGHPRI, 0); in xillyusb_probe()
2137 if (!xdev->workq) { in xillyusb_probe()
2143 INIT_WORK(&xdev->wakeup_workitem, wakeup_all); in xillyusb_probe()
2145 usb_set_intfdata(interface, xdev); in xillyusb_probe()
2147 rc = xillyusb_setup_base_eps(xdev); in xillyusb_probe()
2158 endpoint_quiesce(xdev->in_ep); in xillyusb_probe()
2159 endpoint_quiesce(xdev->msg_ep); in xillyusb_probe()
2163 kref_put(&xdev->kref, cleanup_dev); in xillyusb_probe()
2169 struct xillyusb_dev *xdev = usb_get_intfdata(interface); in xillyusb_disconnect() local
2170 struct xillyusb_endpoint *msg_ep = xdev->msg_ep; in xillyusb_disconnect()
2175 xillybus_cleanup_chrdev(xdev, &interface->dev); in xillyusb_disconnect()
2183 xillyusb_send_opcode(xdev, ~0, OPCODE_QUIESCE, 0); in xillyusb_disconnect()
2193 msg_ep->drained || xdev->error, in xillyusb_disconnect()
2200 report_io_error(xdev, -ENODEV); /* Discourage further activity */ in xillyusb_disconnect()
2209 for (i = 0; i < xdev->num_channels; i++) { in xillyusb_disconnect()
2210 struct xillyusb_channel *chan = &xdev->channels[i]; in xillyusb_disconnect()
2223 endpoint_quiesce(xdev->in_ep); in xillyusb_disconnect()
2224 endpoint_quiesce(xdev->msg_ep); in xillyusb_disconnect()
2228 xdev->dev = NULL; in xillyusb_disconnect()
2230 kref_put(&xdev->kref, cleanup_dev); in xillyusb_disconnect()