Search Linux Wireless

Re: [PATCH 06/10] rtw88: Add common USB chip support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2022-05-18 at 10:23 +0200, Sascha Hauer wrote:
> Add the common bits and pieces to add USB support to the RTW88 driver.
> This is based on https://github.com/ulli-kroll/rtw88-usb.git which
> itself is first written by Neo Jou.
> 

Neo Jou borrowed the usb logic from rtlwifi.
This was (maybe) also in the early stages of the vendor driver.

Newer ones doesn't use async write for register access.

In short it looks like this.
The extra "time consume" is added between v5.2.4 and v5.3.1

static int __rtw_usb_vendor_request(struct usb_device *udev, unsigned int pipe,
				    u8 request, u8 requesttype, u16 val, u16 index,
				    void *buf, size_t len)
{
	int i, ret;

	for (i = 0; i < MAX_USBCTRL_VENDORREQ_TIMES; i++) {
		ret = usb_control_msg(udev, pipe, request, requesttype, val,
				      index, buf, len, RTW_USBCTRL_MSG_TIMEOUT);

		if (ret <= 0)
			return ret;
	}

	if (val <= 0xff ||
	    (val >= 0x1000 && val <= 0x10ff)) {
		/* add a write to consume time on device */

		unsigned int t_pipe = usb_sndctrlpipe(udev, 0);/* write_out */
		u8 t_reqtype =  RTW_USB_CMD_WRITE;
		u8 t_len = 1;
		u8 t_req = RTW_USB_CMD_REQ;
		u16 t_reg = 0x4e0;	/* unknown reg on device */
		u16 t_index = 0;

		ret = usb_control_msg(udev, t_pipe, t_req, t_reqtype,
				      t_reg, t_index, buf, t_len,
				      RTW_USBCTRL_MSG_TIMEOUT);

		if (ret != 1)
			return ret;
	}


	return ret;
}

static int rtw_vendor_request(struct rtw_usb *rtwusb, unsigned int pipe,
			      u8 request, u8 requesttype, u16 val, u16 index,
			      void *buf, size_t len)
{
	struct usb_device *udev = rtwusb->udev;
	int ret;

	mutex_lock(&rtwusb->usb_ctrl_mtx);
	ret = __rtw_usb_vendor_request(udev, pipe, request, requesttype,
				       val, index, buf, len);
	mutex_unlock(&rtwusb->usb_ctrl_mtx);

	return ret;
}


Hans Ulli



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux