]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rt2x00: change REGISTER_BUSY_COUNT for USB
authorStanislaw Gruszka <sgruszka@redhat.com>
Wed, 26 Nov 2014 14:29:14 +0000 (15:29 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 1 Dec 2014 20:57:21 +0000 (15:57 -0500)
Because of delays on USB we do not have to iterate so many times on
USB hardware when waiting for H/W register become valid.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00usb.c
drivers/net/wireless/rt2x00/rt73usb.c

index c878e3f3993c3ecb7692b980aec723e9723f656e..05c64597838d6610c876ad548b2b6b6f8c536c18 100644 (file)
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
  * BBP and RF register require indirect register access,
  * and use the CSR registers BBPCSR and RFCSR to achieve this.
  * These indirect registers work with busy bits,
- * and we will try maximal REGISTER_BUSY_COUNT times to access
+ * and we will try maximal REGISTER_USB_BUSY_COUNT times to access
  * the register while taking a REGISTER_BUSY_DELAY us delay
  * between each attampt. When the busy bit is still set at that time,
  * the access attempt is considered to have failed,
@@ -122,7 +122,7 @@ static int rt2500usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
 {
        unsigned int i;
 
-       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+       for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
                rt2500usb_register_read_lock(rt2x00dev, offset, reg);
                if (!rt2x00_get_field16(*reg, field))
                        return 1;
@@ -904,7 +904,7 @@ static int rt2500usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
        unsigned int i;
        u8 value;
 
-       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+       for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
                rt2500usb_bbp_read(rt2x00dev, 0, &value);
                if ((value != 0xff) && (value != 0x00))
                        return 0;
@@ -1023,7 +1023,7 @@ static int rt2500usb_set_state(struct rt2x00_dev *rt2x00dev,
         * We must wait until the register indicates that the
         * device has entered the correct state.
         */
-       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+       for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
                rt2500usb_register_read(rt2x00dev, MAC_CSR17, &reg2);
                bbp_state = rt2x00_get_field16(reg2, MAC_CSR17_BBP_CURR_STATE);
                rf_state = rt2x00_get_field16(reg2, MAC_CSR17_RF_CURR_STATE);
index 1ff81afb672c5408bcbe975552b846fa8b510626..9bb398bed9bb68ba133d702c2e5be8b0b089a8ae 100644 (file)
@@ -1019,9 +1019,12 @@ struct rt2x00_bar_list_entry {
  * Register defines.
  * Some registers require multiple attempts before success,
  * in those cases REGISTER_BUSY_COUNT attempts should be
- * taken with a REGISTER_BUSY_DELAY interval.
+ * taken with a REGISTER_BUSY_DELAY interval. Due to USB
+ * bus delays, we do not have to loop so many times to wait
+ * for valid register value on that bus.
  */
 #define REGISTER_BUSY_COUNT    100
+#define REGISTER_USB_BUSY_COUNT 20
 #define REGISTER_BUSY_DELAY    100
 
 /*
index 258e2a87c5eaf98a71523e2a8e481147dbcb3e2d..c2346f8d1db068f52f48e8830caacb63c6138df1 100644 (file)
@@ -150,7 +150,7 @@ int rt2x00usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
        if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
                return -ENODEV;
 
-       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+       for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
                rt2x00usb_register_read_lock(rt2x00dev, offset, reg);
                if (!rt2x00_get_field32(*reg, field))
                        return 1;
index 95724ff9c7268700628866f433b66e82a8a9f7c4..a5458cf01fb26be50976c3dd4699e476e540c3c5 100644 (file)
@@ -1295,7 +1295,7 @@ static int rt73usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
        unsigned int i;
        u8 value;
 
-       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+       for (i = 0; i < REGISTER_USB_BUSY_COUNT; i++) {
                rt73usb_bbp_read(rt2x00dev, 0, &value);
                if ((value != 0xff) && (value != 0x00))
                        return 0;