return status;
}
+static int usb_read(struct intf_hdl *intf, u16 value, void *data, u8 size)
+{
+ struct adapter *adapt = intf->padapter;
+ struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
+ struct usb_device *udev = dvobjpriv->pusbdev;
+ int status;
+ u8 *io_buf; /* Pointer to I/O buffer */
+
+ mutex_lock(&dvobjpriv->usb_vendor_req_mutex);
+
+ if (adapt->bSurpriseRemoved || adapt->pwrctrlpriv.pnp_bstop_trx)
+ return -EPERM;
+
+ io_buf = dvobjpriv->usb_vendor_req_buf;
+
+ status = usb_control_msg_recv(udev, 0, REALTEK_USB_VENQT_CMD_REQ,
+ REALTEK_USB_VENQT_READ, value,
+ REALTEK_USB_VENQT_CMD_IDX, io_buf,
+ size, RTW_USB_CONTROL_MSG_TIMEOUT,
+ GFP_KERNEL);
+
+ if (status == -ESHUTDOWN ||
+ status == -ENODEV ||
+ status == -ENOENT) {
+ /*
+ * device or controller has been disabled due to
+ * some problem that could not be worked around,
+ * device or bus doesn’t exist, endpoint does not
+ * exist or is not enabled.
+ */
+ adapt->bSurpriseRemoved = true;
+ goto mutex_unlock;
+ }
+
+ if (status < 0) {
+ GET_HAL_DATA(adapt)->srestpriv.wifi_error_status =
+ USB_VEN_REQ_CMD_FAIL;
+
+ if (rtw_inc_and_chk_continual_urb_error(dvobjpriv))
+ adapt->bSurpriseRemoved = true;
+
+ goto mutex_unlock;
+ }
+
+ rtw_reset_continual_urb_error(dvobjpriv);
+ memcpy(data, io_buf, size);
+
+mutex_unlock:
+ mutex_unlock(&dvobjpriv->usb_vendor_req_mutex);
+
+ return status;
+}
+
u8 rtw_read8(struct adapter *adapter, u32 addr)
{
struct io_priv *io_priv = &adapter->iopriv;
u16 value = addr & 0xffff;
u8 data;
- usbctrl_vendorreq(intf, value, &data, 1, REALTEK_USB_VENQT_READ);
+ usb_read(intf, value, &data, 1);
return data;
}
u16 value = addr & 0xffff;
__le16 data;
- usbctrl_vendorreq(intf, value, &data, 2, REALTEK_USB_VENQT_READ);
+ usb_read(intf, value, &data, 2);
return le16_to_cpu(data);
}
u16 value = addr & 0xffff;
__le32 data;
- usbctrl_vendorreq(intf, value, &data, 4, REALTEK_USB_VENQT_READ);
+ usb_read(intf, value, &data, 4);
return le32_to_cpu(data);
}