示例#1
0
static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
{
	int err = 0;
	int timeout = 0;
	struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);

	brcmf_dbg(USB, "Enter\n");
	if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP)
		return -EIO;

	if (test_and_set_bit(0, &devinfo->ctl_op))
		return -EIO;

	devinfo->ctl_completed = false;
	err = brcmf_usb_recv_ctl(devinfo, buf, len);
	if (err) {
		brcmf_err("fail %d bytes: %d\n", err, len);
		clear_bit(0, &devinfo->ctl_op);
		return err;
	}
	timeout = brcmf_usb_ioctl_resp_wait(devinfo);
	err = devinfo->ctl_urb_status;
	clear_bit(0, &devinfo->ctl_op);
	if (!timeout) {
		brcmf_err("rxctl wait timed out\n");
		err = -EIO;
	}
	if (!err)
		return devinfo->ctl_urb_actual_length;
	else
		return err;
}
示例#2
0
文件: usb.c 项目: serrvius/huawei-p6
static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
{
    int err = 0;
    int timeout = 0;
    bool pending;
    struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);

    if (devinfo->bus_pub.state != BCMFMAC_USB_STATE_UP) {
        /* TODO: handle suspend/resume */
        return -EIO;
    }
    if (test_and_set_bit(0, &devinfo->ctl_op))
        return -EIO;

    err = brcmf_usb_recv_ctl(devinfo, buf, len);
    if (err) {
        brcmf_dbg(ERROR, "fail %d bytes: %d\n", err, len);
        return err;
    }
    devinfo->ctl_completed = false;
    timeout = brcmf_usb_ioctl_resp_wait(devinfo, &devinfo->ctl_completed,
                                        &pending);
    err = devinfo->ctl_urb_status;
    clear_bit(0, &devinfo->ctl_op);
    if (!timeout) {
        brcmf_dbg(ERROR, "rxctl wait timed out\n");
        err = -EIO;
    }
    if (!err)
        return devinfo->ctl_urb_actual_length;
    else
        return err;
}