コード例 #1
0
ファイル: tmsi.c プロジェクト: niklasrogers/openbci
static int tmsi_release_dev(struct tmsi_data* dev) {

    int i;
    if (!dev)
        return -ENODEV;
    // Unlink current receiving bulk URB
    for (i = 0; i < BULK_RECV_URBS; ++i)
        free_urb(dev->bulk_recv_urb[i]);
    // Unlink current receiving isochronous URB's
    for (i = ISOC_RECV_URBS-1; i>=0; --i)
        free_urb(dev->isoc_recv_urb[i]);

    if (dev->device_open > 0)
        dev->device_open = 0;


    // Remove buffer

    kfifo_reset(dev->packet_buffer);
    kfifo_free(dev->packet_buffer);
    up(dev->fifo_sem);
    kfree(dev->fifo_sem);
    kfree(dev->release_sem);

    /* decrement the count on our device */
    kref_put(&dev->kref, tmsi_delete);

    info("Tmsi device realese() success\n");
    dev->releasing = 0;
    return 0;
}
コード例 #2
0
ファイル: zd_usb.c プロジェクト: b3rnik/dsl-n55u-bender
void zd_usb_disable_rx(struct zd_usb *usb)
{
    int i;
    unsigned long flags;
    struct urb **urbs;
    unsigned int count;
    struct zd_usb_rx *rx = &usb->rx;

    spin_lock_irqsave(&rx->lock, flags);
    urbs = rx->urbs;
    count = rx->urbs_count;
    spin_unlock_irqrestore(&rx->lock, flags);
    if (!urbs)
        return;

    for (i = 0; i < count; i++) {
        usb_kill_urb(urbs[i]);
        free_urb(urbs[i]);
    }
    kfree(urbs);

    spin_lock_irqsave(&rx->lock, flags);
    rx->urbs = NULL;
    rx->urbs_count = 0;
    spin_unlock_irqrestore(&rx->lock, flags);
}
コード例 #3
0
ファイル: es2.c プロジェクト: alexlotw/greybus
/*
 * Returns zero if the message was successfully queued, or a negative errno
 * otherwise.
 */
static int message_send(struct gb_host_device *hd, u16 cport_id,
			struct gb_message *message, gfp_t gfp_mask)
{
	struct es2_ap_dev *es2 = hd_to_es2(hd);
	struct usb_device *udev = es2->usb_dev;
	size_t buffer_size;
	int retval;
	struct urb *urb;
	int ep_pair;
	unsigned long flags;

	/*
	 * The data actually transferred will include an indication
	 * of where the data should be sent.  Do one last check of
	 * the target CPort id before filling it in.
	 */
	if (!cport_id_valid(hd, cport_id)) {
		dev_err(&udev->dev, "invalid destination cport 0x%02x\n",
				cport_id);
		return -EINVAL;
	}

	/* Find a free urb */
	urb = next_free_urb(es2, gfp_mask);
	if (!urb)
		return -ENOMEM;

	spin_lock_irqsave(&es2->cport_out_urb_lock, flags);
	message->hcpriv = urb;
	spin_unlock_irqrestore(&es2->cport_out_urb_lock, flags);

	/* Pack the cport id into the message header */
	gb_message_cport_pack(message->header, cport_id);

	buffer_size = sizeof(*message->header) + message->payload_size;

	ep_pair = cport_to_ep_pair(es2, cport_id);
	usb_fill_bulk_urb(urb, udev,
			  usb_sndbulkpipe(udev,
					  es2->cport_out[ep_pair].endpoint),
			  message->buffer, buffer_size,
			  cport_out_callback, message);
	urb->transfer_flags |= URB_ZERO_PACKET;
	trace_gb_host_device_send(hd, cport_id, buffer_size);
	retval = usb_submit_urb(urb, gfp_mask);
	if (retval) {
		dev_err(&udev->dev, "failed to submit out-urb: %d\n", retval);

		spin_lock_irqsave(&es2->cport_out_urb_lock, flags);
		message->hcpriv = NULL;
		spin_unlock_irqrestore(&es2->cport_out_urb_lock, flags);

		free_urb(es2, urb);
		gb_message_cport_clear(message->header);

		return retval;
	}

	return 0;
}
コード例 #4
0
ファイル: zd_usb.c プロジェクト: b3rnik/dsl-n55u-bender
int zd_usb_enable_rx(struct zd_usb *usb)
{
    int i, r;
    struct zd_usb_rx *rx = &usb->rx;
    struct urb **urbs;

    dev_dbg_f(zd_usb_dev(usb), "\n");

    r = -ENOMEM;
    urbs = kcalloc(URBS_COUNT, sizeof(struct urb *), GFP_KERNEL);
    if (!urbs)
        goto error;
    for (i = 0; i < URBS_COUNT; i++) {
        urbs[i] = alloc_urb(usb);
        if (!urbs[i])
            goto error;
    }

    ZD_ASSERT(!irqs_disabled());
    spin_lock_irq(&rx->lock);
    if (rx->urbs) {
        spin_unlock_irq(&rx->lock);
        r = 0;
        goto error;
    }
    rx->urbs = urbs;
    rx->urbs_count = URBS_COUNT;
    spin_unlock_irq(&rx->lock);

    for (i = 0; i < URBS_COUNT; i++) {
        r = usb_submit_urb(urbs[i], GFP_KERNEL);
        if (r)
            goto error_submit;
    }

    return 0;
error_submit:
    for (i = 0; i < URBS_COUNT; i++) {
        usb_kill_urb(urbs[i]);
    }
    spin_lock_irq(&rx->lock);
    rx->urbs = NULL;
    rx->urbs_count = 0;
    spin_unlock_irq(&rx->lock);
error:
    if (urbs) {
        for (i = 0; i < URBS_COUNT; i++)
            free_urb(urbs[i]);
    }
    return r;
}
コード例 #5
0
ファイル: snoopdecode.c プロジェクト: AllardJ/Tomato
int main(int argc, char* argv[])
{
	struct urb urb;

	file = stdin;

	while(init_urb(&urb))
	{
		parse_urb_body(&urb);
		
		update_reports(&urb);
		
		free_urb(&urb);
	}

	return 0;
}
コード例 #6
0
ファイル: es2.c プロジェクト: melvinvarkey/greybus
static void cport_out_callback(struct urb *urb)
{
	struct gb_message *message = urb->context;
	struct gb_host_device *hd = message->operation->connection->hd;
	struct es2_ap_dev *es2 = hd_to_es2(hd);
	int status = check_urb_status(urb);
	unsigned long flags;

	gb_message_cport_clear(message->header);

	spin_lock_irqsave(&es2->cport_out_urb_lock, flags);
	message->hcpriv = NULL;
	spin_unlock_irqrestore(&es2->cport_out_urb_lock, flags);

	/*
	 * Tell the submitter that the message send (attempt) is
	 * complete, and report the status.
	 */
	greybus_message_sent(hd, message, status);

	free_urb(es2, urb);
}