forked from Minki/linux
rt2x00: Add helper macros
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>
This commit is contained in:
parent
e58c6aca99
commit
bd394a74a0
@ -76,10 +76,10 @@ static inline void rt2500usb_register_multiread(struct rt2x00_dev *rt2x00dev,
|
|||||||
const unsigned int offset,
|
const unsigned int offset,
|
||||||
void *value, const u16 length)
|
void *value, const u16 length)
|
||||||
{
|
{
|
||||||
int timeout = REGISTER_TIMEOUT * (length / sizeof(u16));
|
|
||||||
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
|
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
|
||||||
USB_VENDOR_REQUEST_IN, offset,
|
USB_VENDOR_REQUEST_IN, offset,
|
||||||
value, length, timeout);
|
value, length,
|
||||||
|
REGISTER_TIMEOUT16(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
|
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,
|
const unsigned int offset,
|
||||||
void *value, const u16 length)
|
void *value, const u16 length)
|
||||||
{
|
{
|
||||||
int timeout = REGISTER_TIMEOUT * (length / sizeof(u16));
|
|
||||||
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
|
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
|
||||||
USB_VENDOR_REQUEST_OUT, offset,
|
USB_VENDOR_REQUEST_OUT, offset,
|
||||||
value, length, timeout);
|
value, length,
|
||||||
|
REGISTER_TIMEOUT16(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
static u16 rt2500usb_bbp_check(struct rt2x00_dev *rt2x00dev)
|
static u16 rt2500usb_bbp_check(struct rt2x00_dev *rt2x00dev)
|
||||||
|
@ -344,7 +344,7 @@ void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
|
|||||||
struct data_queue *queue;
|
struct data_queue *queue;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0x0000, 0x0000,
|
rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0,
|
||||||
REGISTER_TIMEOUT);
|
REGISTER_TIMEOUT);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,6 +47,20 @@
|
|||||||
#define REGISTER_TIMEOUT 500
|
#define REGISTER_TIMEOUT 500
|
||||||
#define REGISTER_TIMEOUT_FIRMWARE 1000
|
#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
|
* 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,
|
static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
|
||||||
__le16 *eeprom, const u16 lenght)
|
__le16 *eeprom, const u16 lenght)
|
||||||
{
|
{
|
||||||
int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
|
|
||||||
|
|
||||||
return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
|
return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
|
||||||
USB_VENDOR_REQUEST_IN, 0, 0,
|
USB_VENDOR_REQUEST_IN, 0, 0,
|
||||||
eeprom, lenght, timeout);
|
eeprom, lenght,
|
||||||
|
REGISTER_TIMEOUT16(lenght));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -74,10 +74,10 @@ static inline void rt73usb_register_multiread(struct rt2x00_dev *rt2x00dev,
|
|||||||
const unsigned int offset,
|
const unsigned int offset,
|
||||||
void *value, const u32 length)
|
void *value, const u32 length)
|
||||||
{
|
{
|
||||||
int timeout = REGISTER_TIMEOUT * (length / sizeof(u32));
|
|
||||||
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
|
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
|
||||||
USB_VENDOR_REQUEST_IN, offset,
|
USB_VENDOR_REQUEST_IN, offset,
|
||||||
value, length, timeout);
|
value, length,
|
||||||
|
REGISTER_TIMEOUT32(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void rt73usb_register_write(struct rt2x00_dev *rt2x00dev,
|
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,
|
const unsigned int offset,
|
||||||
void *value, const u32 length)
|
void *value, const u32 length)
|
||||||
{
|
{
|
||||||
int timeout = REGISTER_TIMEOUT * (length / sizeof(u32));
|
|
||||||
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
|
rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
|
||||||
USB_VENDOR_REQUEST_OUT, offset,
|
USB_VENDOR_REQUEST_OUT, offset,
|
||||||
value, length, timeout);
|
value, length,
|
||||||
|
REGISTER_TIMEOUT32(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 rt73usb_bbp_check(struct rt2x00_dev *rt2x00dev)
|
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 *ptr = data;
|
||||||
char *cache;
|
char *cache;
|
||||||
int buflen;
|
int buflen;
|
||||||
int timeout;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for stable hardware.
|
* 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) {
|
for (i = 0; i < len; i += CSR_CACHE_SIZE_FIRMWARE) {
|
||||||
buflen = min_t(int, 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);
|
memcpy(cache, ptr, buflen);
|
||||||
|
|
||||||
rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
|
rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
|
||||||
USB_VENDOR_REQUEST_OUT,
|
USB_VENDOR_REQUEST_OUT,
|
||||||
FIRMWARE_IMAGE_BASE + i, 0,
|
FIRMWARE_IMAGE_BASE + i, 0,
|
||||||
cache, buflen, timeout);
|
cache, buflen,
|
||||||
|
REGISTER_TIMEOUT32(buflen));
|
||||||
|
|
||||||
ptr += 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 rt2x00_intf *intf = vif_to_intf(control->vif);
|
||||||
struct skb_frame_desc *skbdesc;
|
struct skb_frame_desc *skbdesc;
|
||||||
unsigned int beacon_base;
|
unsigned int beacon_base;
|
||||||
unsigned int timeout;
|
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
if (unlikely(!intf->beacon))
|
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);
|
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
|
||||||
beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
|
beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
|
||||||
timeout = REGISTER_TIMEOUT * (skb->len / sizeof(u32));
|
|
||||||
rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
|
rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE,
|
||||||
USB_VENDOR_REQUEST_OUT, beacon_base, 0,
|
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);
|
rt73usb_kick_tx_queue(rt2x00dev, QID_BEACON);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user