コード例 #1
0
ファイル: rt2x00usb.c プロジェクト: Niisp/MT6795.kernel
static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev)
{
    struct usb_interface *intf = to_usb_interface(rt2x00dev->dev);
    struct usb_host_interface *intf_desc = intf->cur_altsetting;
    struct usb_endpoint_descriptor *ep_desc;
    struct data_queue *queue = rt2x00dev->tx;
    struct usb_endpoint_descriptor *tx_ep_desc = NULL;
    unsigned int i;

    /*
     * Walk through all available endpoints to search for "bulk in"
     * and "bulk out" endpoints. When we find such endpoints collect
     * the information we need from the descriptor and assign it
     * to the queue.
     */
    for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) {
        ep_desc = &intf_desc->endpoint[i].desc;

        if (usb_endpoint_is_bulk_in(ep_desc)) {
            rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc);
        } else if (usb_endpoint_is_bulk_out(ep_desc) &&
                   (queue != queue_end(rt2x00dev))) {
            rt2x00usb_assign_endpoint(queue, ep_desc);
            queue = queue_next(queue);

            tx_ep_desc = ep_desc;
        }
    }

    /*
     * At least 1 endpoint for RX and 1 endpoint for TX must be available.
     */
    if (!rt2x00dev->rx->usb_endpoint || !rt2x00dev->tx->usb_endpoint) {
        rt2x00_err(rt2x00dev, "Bulk-in/Bulk-out endpoints not found\n");
        return -EPIPE;
    }

    /*
     * It might be possible not all queues have a dedicated endpoint.
     * Loop through all TX queues and copy the endpoint information
     * which we have gathered from already assigned endpoints.
     */
    txall_queue_for_each(rt2x00dev, queue) {
        if (!queue->usb_endpoint)
            rt2x00usb_assign_endpoint(queue, tx_ep_desc);
    }

    return 0;
}
コード例 #2
0
static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev)
{
	struct usb_interface *intf = to_usb_interface(rt2x00dev->dev);
	struct usb_host_interface *intf_desc = intf->cur_altsetting;
	struct usb_endpoint_descriptor *ep_desc;
	struct data_queue *queue = rt2x00dev->tx;
	struct usb_endpoint_descriptor *tx_ep_desc = NULL;
	unsigned int i;

	
	for (i = 0; i < intf_desc->desc.bNumEndpoints; i++) {
		ep_desc = &intf_desc->endpoint[i].desc;

		if (usb_endpoint_is_bulk_in(ep_desc)) {
			rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc);
		} else if (usb_endpoint_is_bulk_out(ep_desc) &&
			   (queue != queue_end(rt2x00dev))) {
			rt2x00usb_assign_endpoint(queue, ep_desc);
			queue = queue_next(queue);

			tx_ep_desc = ep_desc;
		}
	}

	
	if (!rt2x00dev->rx->usb_endpoint || !rt2x00dev->tx->usb_endpoint) {
		ERROR(rt2x00dev, "Bulk-in/Bulk-out endpoints not found\n");
		return -EPIPE;
	}

	
	txall_queue_for_each(rt2x00dev, queue) {
		if (!queue->usb_endpoint)
			rt2x00usb_assign_endpoint(queue, tx_ep_desc);
	}

	return 0;
}