]> err.no Git - linux-2.6/commitdiff
rt2x00: Add helper macros
authorIvo van Doorn <ivdoorn@gmail.com>
Mon, 21 Apr 2008 17:01:58 +0000 (19:01 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 7 May 2008 19:02:21 +0000 (15:02 -0400)
Add some helper macro's to help determining the
the timeout for USB register access.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2x00usb.c
drivers/net/wireless/rt2x00/rt2x00usb.h
drivers/net/wireless/rt2x00/rt73usb.c

index 0dac1f5b5c4ad64c41494d5d00030d59c7289088..80b34d47114a89d291912b58276729e0882d6186 100644 (file)
@@ -76,10 +76,10 @@ static inline void rt2500usb_register_multiread(struct rt2x00_dev *rt2x00dev,
                                                const unsigned int offset,
                                                void *value, const u16 length)
 {
-       int timeout = REGISTER_TIMEOUT * (length / sizeof(u16));
        rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
                                      USB_VENDOR_REQUEST_IN, offset,
-                                     value, length, timeout);
+                                     value, length,
+                                     REGISTER_TIMEOUT16(length));
 }
 
 static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
@@ -106,10 +106,10 @@ static inline void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
                                                 const unsigned int offset,
                                                 void *value, const u16 length)
 {
-       int timeout = REGISTER_TIMEOUT * (length / sizeof(u16));
        rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
                                      USB_VENDOR_REQUEST_OUT, offset,
-                                     value, length, timeout);
+                                     value, length,
+                                     REGISTER_TIMEOUT16(length));
 }
 
 static u16 rt2500usb_bbp_check(struct rt2x00_dev *rt2x00dev)
index 47f96b34087ef56f21b0a5b756a443cd6b6924f1..98aafc2d584a051c0a52df7c129f2f048c5cdf1f 100644 (file)
@@ -344,7 +344,7 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
        struct data_queue *queue;
        unsigned int i;
 
-       rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0x0000, 0x0000,
+       rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 00,
                                    REGISTER_TIMEOUT);
 
        /*
index 11e55180cbaf61c95eaa6138bba8fae42fa695e6..1efaaae0463260bce5ef6b9920abe0e864684c73 100644 (file)
 #define REGISTER_TIMEOUT               500
 #define REGISTER_TIMEOUT_FIRMWARE      1000
 
+/**
+ * REGISTER_TIMEOUT16 - Determine the timeout for 16bit register access
+ * @__datalen: Data length
+ */
+#define REGISTER_TIMEOUT16(__datalen)  \
+       ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u16)) )
+
+/**
+ * REGISTER_TIMEOUT32 - Determine the timeout for 32bit register access
+ * @__datalen: Data length
+ */
+#define REGISTER_TIMEOUT32(__datalen)  \
+       ( REGISTER_TIMEOUT * ((__datalen) / sizeof(u32)) )
+
 /*
  * Cache size
  */
@@ -187,11 +201,10 @@ static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
 static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
                                        __le16 *eeprom, const u16 lenght)
 {
-       int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
-
        return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
                                        USB_VENDOR_REQUEST_IN, 0, 0,
-                                       eeprom, lenght, timeout);
+                                       eeprom, lenght,
+                                       REGISTER_TIMEOUT16(lenght));
 }
 
 /*
index a6419c9007723137dd1da2af407fbcc352cacf4c..351d95c4f50d7fc6de9a7420229cf2b776ef171f 100644 (file)
@@ -74,10 +74,10 @@ static inline void rt73usb_register_multiread(struct rt2x00_dev *rt2x00dev,
                                              const unsigned int offset,
                                              void *value, const u32 length)
 {
-       int timeout = REGISTER_TIMEOUT * (length / sizeof(u32));
        rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
                                      USB_VENDOR_REQUEST_IN, offset,
-                                     value, length, timeout);
+                                     value, length,
+                                     REGISTER_TIMEOUT32(length));
 }
 
 static inline void rt73usb_register_write(struct rt2x00_dev *rt2x00dev,
@@ -102,10 +102,10 @@ static inline void rt73usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
                                               const unsigned int offset,
                                               void *value, const u32 length)
 {
-       int timeout = REGISTER_TIMEOUT * (length / sizeof(u32));
        rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
                                      USB_VENDOR_REQUEST_OUT, offset,
-                                     value, length, timeout);
+                                     value, length,
+                                     REGISTER_TIMEOUT32(length));
 }
 
 static u32 rt73usb_bbp_check(struct rt2x00_dev *rt2x00dev)
@@ -876,7 +876,6 @@ static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
        char *ptr = data;
        char *cache;
        int buflen;
-       int timeout;
 
        /*
         * Wait for stable hardware.
@@ -907,14 +906,14 @@ static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
 
        for (i = 0; i < len; i += CSR_CACHE_SIZE_FIRMWARE) {
                buflen = min_t(int, len - i, CSR_CACHE_SIZE_FIRMWARE);
-               timeout = REGISTER_TIMEOUT * (buflen / sizeof(u32));
 
                memcpy(cache, ptr, buflen);
 
                rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
                                         USB_VENDOR_REQUEST_OUT,
                                         FIRMWARE_IMAGE_BASE + i, 0,
-                                        cache, buflen, timeout);
+                                        cache, buflen,
+                                        REGISTER_TIMEOUT32(buflen));
 
                ptr += buflen;
        }
@@ -1966,7 +1965,6 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
        struct rt2x00_intf *intf = vif_to_intf(control->vif);
        struct skb_frame_desc *skbdesc;
        unsigned int beacon_base;
-       unsigned int timeout;
        u32 reg;
 
        if (unlikely(!intf->beacon))
@@ -2006,10 +2004,10 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
         */
        rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
        beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
-       timeout = REGISTER_TIMEOUT * (skb->len / sizeof(u32));
        rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
                                 USB_VENDOR_REQUEST_OUT, beacon_base, 0,
-                                skb->data, skb->len, timeout);
+                                skb->data, skb->len,
+                                REGISTER_TIMEOUT32(skb->len));
        rt73usb_kick_tx_queue(rt2x00dev, QID_BEACON);
 
        return 0;