rsi: use macros in USB specific code
authorPrameela Rani Garnepudi <prameela.j04cs@gmail.com>
Tue, 16 May 2017 10:01:11 +0000 (15:31 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 24 May 2017 13:37:50 +0000 (16:37 +0300)
For USB vendor read and write operations new macros added to avoid
redundant usage of long or'ed macros. Also for timeouts standard USB
macros are used.

Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rsi/rsi_91x_usb.c

index 5f6c7000bc51279a1a506585f9856bef082b3b7e..9e1359a204fcda12407d88f0b59deeaa9dd376af 100644 (file)
@@ -141,6 +141,9 @@ static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface *interface,
        return 0;
 }
 
+#define RSI_USB_REQ_OUT        (USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE)
+#define RSI_USB_REQ_IN (USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE)
+
 /* rsi_usb_reg_read() - This function reads data from given register address.
  * @usbdev: Pointer to the usb_device structure.
  * @reg: Address of the register to be read.
@@ -164,11 +167,11 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
        status = usb_control_msg(usbdev,
                                 usb_rcvctrlpipe(usbdev, 0),
                                 USB_VENDOR_REGISTER_READ,
-                                USB_TYPE_VENDOR,
+                                RSI_USB_REQ_IN,
                                 ((reg & 0xffff0000) >> 16), (reg & 0xffff),
                                 (void *)buf,
                                 len,
-                                HZ * 5);
+                                USB_CTRL_GET_TIMEOUT);
 
        *value = (buf[0] | (buf[1] << 8));
        if (status < 0) {
@@ -211,12 +214,12 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
        status = usb_control_msg(usbdev,
                                 usb_sndctrlpipe(usbdev, 0),
                                 USB_VENDOR_REGISTER_WRITE,
-                                USB_TYPE_VENDOR,
+                                RSI_USB_REQ_OUT,
                                 ((reg & 0xffff0000) >> 16),
                                 (reg & 0xffff),
                                 (void *)usb_reg_buf,
                                 len,
-                                HZ * 5);
+                                USB_CTRL_SET_TIMEOUT);
        if (status < 0) {
                rsi_dbg(ERR_ZONE,
                        "%s: Reg write failed with error code :%d\n",
@@ -303,12 +306,12 @@ int rsi_usb_write_register_multiple(struct rsi_hw *adapter,
                status = usb_control_msg(dev->usbdev,
                                         usb_sndctrlpipe(dev->usbdev, 0),
                                         USB_VENDOR_REGISTER_WRITE,
-                                        USB_TYPE_VENDOR,
+                                        RSI_USB_REQ_OUT,
                                         ((addr & 0xffff0000) >> 16),
                                         (addr & 0xffff),
                                         (void *)buf,
                                         transfer,
-                                        HZ * 5);
+                                        USB_CTRL_SET_TIMEOUT);
                if (status < 0) {
                        rsi_dbg(ERR_ZONE,
                                "Reg write failed with error code :%d\n",