aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2007-12-09 16:34:59 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:05:58 -0500
commit8ed7fc48eb31e583bb31c2bcfdd3a9c557bad5d0 (patch)
tree43ece4c73d9e563c9a06b8fd7cde8cc8f72bbabb /drivers/net/wireless/b43
parentbb54244be7d12c2a5985226061d598edb49c9078 (diff)
b43: Fix ofdmtab write regression
commit f04b3787bbce4567e28069a9ec97dcd804626ac7 introduced a regression for the ofdmtable writing. It incorrectly removed the writing of the high 16bits for a 32bit table write and initialized the direction identifier too late. This patch does also some cleanups to make the code much more readable and adds a few comments, so non rocket scientists are also able to understand what this address caching is all about. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r--drivers/net/wireless/b43/b43.h14
-rw-r--r--drivers/net/wireless/b43/main.c12
-rw-r--r--drivers/net/wireless/b43/tables.c35
3 files changed, 39 insertions, 22 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index d07b56e5ea69..813b2409f0c3 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -547,12 +547,18 @@ struct b43_phy {
547 547
548 u16 initval; //FIXME rename? 548 u16 initval; //FIXME rename?
549 549
550 /* OFDM address read/write caching for hardware auto-increment. */
551 u16 ofdm_addr;
552 u8 ofdm_valid; /* 0: invalid, 1: read, 2: write */
553
554 /* PHY TX errors counter. */ 550 /* PHY TX errors counter. */
555 atomic_t txerr_cnt; 551 atomic_t txerr_cnt;
552
553 /* The device does address auto increment for the OFDM tables.
554 * We cache the previously used address here and omit the address
555 * write on the next table access, if possible. */
556 u16 ofdmtab_addr; /* The address currently set in hardware. */
557 enum { /* The last data flow direction. */
558 B43_OFDMTAB_DIRECTION_UNKNOWN = 0,
559 B43_OFDMTAB_DIRECTION_READ,
560 B43_OFDMTAB_DIRECTION_WRITE,
561 } ofdmtab_addr_direction;
556}; 562};
557 563
558/* Data structures for DMA transmission, per 80211 core. */ 564/* Data structures for DMA transmission, per 80211 core. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 064cbe118882..d7ea671394a8 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2264,12 +2264,6 @@ static int b43_chip_init(struct b43_wldev *dev)
2264 b43_write16(dev, B43_MMIO_POWERUP_DELAY, 2264 b43_write16(dev, B43_MMIO_POWERUP_DELAY,
2265 dev->dev->bus->chipco.fast_pwrup_delay); 2265 dev->dev->bus->chipco.fast_pwrup_delay);
2266 2266
2267 /* OFDM address caching. */
2268 phy->ofdm_valid = 0;
2269
2270 /* PHY TX errors counter. */
2271 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT);
2272
2273 err = 0; 2267 err = 0;
2274 b43dbg(dev->wl, "Chip initialized\n"); 2268 b43dbg(dev->wl, "Chip initialized\n");
2275out: 2269out:
@@ -3195,6 +3189,12 @@ static void setup_struct_phy_for_init(struct b43_wldev *dev,
3195 phy->channel = 0xFF; 3189 phy->channel = 0xFF;
3196 3190
3197 phy->hardware_power_control = !!modparam_hwpctl; 3191 phy->hardware_power_control = !!modparam_hwpctl;
3192
3193 /* PHY TX errors counter. */
3194 atomic_set(&phy->txerr_cnt, B43_PHY_TX_BADNESS_LIMIT);
3195
3196 /* OFDM-table address caching. */
3197 phy->ofdmtab_addr_direction = B43_OFDMTAB_DIRECTION_UNKNOWN;
3198} 3198}
3199 3199
3200static void setup_struct_wldev_for_init(struct b43_wldev *dev) 3200static void setup_struct_wldev_for_init(struct b43_wldev *dev)
diff --git a/drivers/net/wireless/b43/tables.c b/drivers/net/wireless/b43/tables.c
index be9c7eb94ac4..fd5595ba5e8b 100644
--- a/drivers/net/wireless/b43/tables.c
+++ b/drivers/net/wireless/b43/tables.c
@@ -381,13 +381,17 @@ u16 b43_ofdmtab_read16(struct b43_wldev *dev, u16 table, u16 offset)
381 u16 addr; 381 u16 addr;
382 382
383 addr = table + offset; 383 addr = table + offset;
384 if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 1) { 384 if ((phy->ofdmtab_addr_direction != B43_OFDMTAB_DIRECTION_READ) ||
385 (addr - 1 != phy->ofdmtab_addr)) {
386 /* The hardware has a different address in memory. Update it. */
385 b43_phy_write(dev, B43_PHY_OTABLECTL, addr); 387 b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
386 phy->ofdm_valid = 1; 388 phy->ofdmtab_addr_direction = B43_OFDMTAB_DIRECTION_READ;
387 } 389 }
388 phy->ofdm_addr = addr; 390 phy->ofdmtab_addr = addr;
389 391
390 return b43_phy_read(dev, B43_PHY_OTABLEI); 392 return b43_phy_read(dev, B43_PHY_OTABLEI);
393
394 /* Some compiletime assertions... */
391 assert_sizes(); 395 assert_sizes();
392} 396}
393 397
@@ -398,11 +402,13 @@ void b43_ofdmtab_write16(struct b43_wldev *dev, u16 table,
398 u16 addr; 402 u16 addr;
399 403
400 addr = table + offset; 404 addr = table + offset;
401 if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 2) { 405 if ((phy->ofdmtab_addr_direction != B43_OFDMTAB_DIRECTION_WRITE) ||
406 (addr -1 != phy->ofdmtab_addr)) {
407 /* The hardware has a different address in memory. Update it. */
402 b43_phy_write(dev, B43_PHY_OTABLECTL, addr); 408 b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
403 phy->ofdm_valid = 2; 409 phy->ofdmtab_addr_direction = B43_OFDMTAB_DIRECTION_WRITE;
404 } 410 }
405 phy->ofdm_addr = addr; 411 phy->ofdmtab_addr = addr;
406 b43_phy_write(dev, B43_PHY_OTABLEI, value); 412 b43_phy_write(dev, B43_PHY_OTABLEI, value);
407} 413}
408 414
@@ -413,11 +419,13 @@ u32 b43_ofdmtab_read32(struct b43_wldev *dev, u16 table, u16 offset)
413 u16 addr; 419 u16 addr;
414 420
415 addr = table + offset; 421 addr = table + offset;
416 if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 1) { 422 if ((phy->ofdmtab_addr_direction != B43_OFDMTAB_DIRECTION_READ) ||
423 (addr - 1 != phy->ofdmtab_addr)) {
424 /* The hardware has a different address in memory. Update it. */
417 b43_phy_write(dev, B43_PHY_OTABLECTL, addr); 425 b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
418 phy->ofdm_valid = 1; 426 phy->ofdmtab_addr_direction = B43_OFDMTAB_DIRECTION_READ;
419 } 427 }
420 phy->ofdm_addr = addr; 428 phy->ofdmtab_addr = addr;
421 ret = b43_phy_read(dev, B43_PHY_OTABLEQ); 429 ret = b43_phy_read(dev, B43_PHY_OTABLEQ);
422 ret <<= 16; 430 ret <<= 16;
423 ret |= b43_phy_read(dev, B43_PHY_OTABLEI); 431 ret |= b43_phy_read(dev, B43_PHY_OTABLEI);
@@ -432,13 +440,16 @@ void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table,
432 u16 addr; 440 u16 addr;
433 441
434 addr = table + offset; 442 addr = table + offset;
435 if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 2) { 443 if ((phy->ofdmtab_addr_direction != B43_OFDMTAB_DIRECTION_WRITE) ||
444 (addr - 1 != phy->ofdmtab_addr)) {
445 /* The hardware has a different address in memory. Update it. */
436 b43_phy_write(dev, B43_PHY_OTABLECTL, addr); 446 b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
437 phy->ofdm_valid = 2; 447 phy->ofdmtab_addr_direction = B43_OFDMTAB_DIRECTION_WRITE;
438 } 448 }
439 phy->ofdm_addr = addr; 449 phy->ofdmtab_addr = addr;
440 450
441 b43_phy_write(dev, B43_PHY_OTABLEI, value); 451 b43_phy_write(dev, B43_PHY_OTABLEI, value);
452 b43_phy_write(dev, B43_PHY_OTABLEQ, (value >> 16));
442} 453}
443 454
444u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset) 455u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset)