Пример #1
0
static
struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,
				      int nrxq, int ntxq)
{
	brcmf_dbg(USB, "Enter\n");

	devinfo->bus_pub.nrxq = nrxq;
	devinfo->rx_low_watermark = nrxq / 2;
	devinfo->bus_pub.devinfo = devinfo;
	devinfo->bus_pub.ntxq = ntxq;
	devinfo->bus_pub.state = BRCMFMAC_USB_STATE_DOWN;

	/* flow control when too many tx urbs posted */
	devinfo->tx_low_watermark = ntxq / 4;
	devinfo->tx_high_watermark = devinfo->tx_low_watermark * 3;
	devinfo->bus_pub.bus_mtu = BRCMF_USB_MAX_PKT_SIZE;

	/* Initialize other structure content */
	init_waitqueue_head(&devinfo->ioctl_resp_wait);

	/* Initialize the spinlocks */
	spin_lock_init(&devinfo->qlock);
	spin_lock_init(&devinfo->tx_flowblock_lock);

	INIT_LIST_HEAD(&devinfo->rx_freeq);
	INIT_LIST_HEAD(&devinfo->rx_postq);

	INIT_LIST_HEAD(&devinfo->tx_freeq);
	INIT_LIST_HEAD(&devinfo->tx_postq);

	devinfo->tx_flowblock = false;

	devinfo->rx_reqs = brcmf_usbdev_qinit(&devinfo->rx_freeq, nrxq);
	if (!devinfo->rx_reqs)
		goto error;

	devinfo->tx_reqs = brcmf_usbdev_qinit(&devinfo->tx_freeq, ntxq);
	if (!devinfo->tx_reqs)
		goto error;
	devinfo->tx_freecount = ntxq;

	devinfo->ctl_urb = usb_alloc_urb(0, GFP_ATOMIC);
	if (!devinfo->ctl_urb) {
		brcmf_err("usb_alloc_urb (ctl) failed\n");
		goto error;
	}
	devinfo->bulk_urb = usb_alloc_urb(0, GFP_ATOMIC);
	if (!devinfo->bulk_urb) {
		brcmf_err("usb_alloc_urb (bulk) failed\n");
		goto error;
	}

	return &devinfo->bus_pub;

error:
	brcmf_err("failed!\n");
	brcmf_usb_detach(devinfo);
	return NULL;
}
Пример #2
0
static
struct brcmf_usbdev *brcmf_usb_attach(int nrxq, int ntxq, struct device *dev)
{
    struct brcmf_usbdev_info *devinfo;

    devinfo = kzalloc(sizeof(struct brcmf_usbdev_info), GFP_ATOMIC);
    if (devinfo == NULL)
        return NULL;

    devinfo->bus_pub.nrxq = nrxq;
    devinfo->rx_low_watermark = nrxq / 2;
    devinfo->bus_pub.devinfo = devinfo;
    devinfo->bus_pub.ntxq = ntxq;

    /* flow control when too many tx urbs posted */
    devinfo->tx_low_watermark = ntxq / 4;
    devinfo->tx_high_watermark = devinfo->tx_low_watermark * 3;
    devinfo->dev = dev;
    devinfo->usbdev = usbdev_probe_info.usb;
    devinfo->tx_pipe = usbdev_probe_info.tx_pipe;
    devinfo->rx_pipe = usbdev_probe_info.rx_pipe;
    devinfo->rx_pipe2 = usbdev_probe_info.rx_pipe2;
    devinfo->intr_pipe = usbdev_probe_info.intr_pipe;

    devinfo->interval = usbdev_probe_info.interval;
    devinfo->intr_size = usbdev_probe_info.intr_size;

    memcpy(&devinfo->probe_info, &usbdev_probe_info,
           sizeof(struct brcmf_usb_probe_info));
    devinfo->bus_pub.bus_mtu = BRCMF_USB_MAX_PKT_SIZE;

    /* Initialize other structure content */
    init_waitqueue_head(&devinfo->ioctl_resp_wait);

    /* Initialize the spinlocks */
    spin_lock_init(&devinfo->qlock);

    INIT_LIST_HEAD(&devinfo->rx_freeq);
    INIT_LIST_HEAD(&devinfo->rx_postq);

    INIT_LIST_HEAD(&devinfo->tx_freeq);
    INIT_LIST_HEAD(&devinfo->tx_postq);

    devinfo->rx_reqs = brcmf_usbdev_qinit(&devinfo->rx_freeq, nrxq);
    if (!devinfo->rx_reqs)
        goto error;

    devinfo->tx_reqs = brcmf_usbdev_qinit(&devinfo->tx_freeq, ntxq);
    if (!devinfo->tx_reqs)
        goto error;

    devinfo->intr_urb = usb_alloc_urb(0, GFP_ATOMIC);
    if (!devinfo->intr_urb) {
        brcmf_dbg(ERROR, "usb_alloc_urb (intr) failed\n");
        goto error;
    }
    devinfo->ctl_urb = usb_alloc_urb(0, GFP_ATOMIC);
    if (!devinfo->ctl_urb) {
        brcmf_dbg(ERROR, "usb_alloc_urb (ctl) failed\n");
        goto error;
    }
    devinfo->rxctl_deferrespok = 0;

    devinfo->bulk_urb = usb_alloc_urb(0, GFP_ATOMIC);
    if (!devinfo->bulk_urb) {
        brcmf_dbg(ERROR, "usb_alloc_urb (bulk) failed\n");
        goto error;
    }

    init_waitqueue_head(&devinfo->wait);
    if (!brcmf_usb_dlneeded(devinfo))
        return &devinfo->bus_pub;

    brcmf_dbg(TRACE, "start fw downloading\n");
    if (brcmf_usb_get_fw(devinfo))
        goto error;

    if (brcmf_usb_fw_download(devinfo))
        goto error;

    return &devinfo->bus_pub;

error:
    brcmf_dbg(ERROR, "failed!\n");
    brcmf_usb_detach(&devinfo->bus_pub);
    return NULL;
}