Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

atheros: define a common priv struct

hw code should never use private driver data, but
sometimes we need a backpointer so just stuff it on
the common ath struct.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Luis R. Rodriguez and committed by
John W. Linville
bc974f4a 7c89606e

+31 -24
+1
drivers/net/wireless/ath/ath.h
··· 56 56 57 57 struct ath_common { 58 58 void *ah; 59 + void *priv; 59 60 struct ieee80211_hw *hw; 60 61 int debug_mask; 61 62
+4 -3
drivers/net/wireless/ath/ath9k/debug.c
··· 562 562 563 563 int ath9k_init_debug(struct ath_hw *ah) 564 564 { 565 - struct ath_softc *sc = ah->ah_sc; 566 - struct ath_common *common = ath9k_hw_common(sc->sc_ah); 565 + struct ath_common *common = ath9k_hw_common(ah); 566 + struct ath_softc *sc = (struct ath_softc *) common->priv; 567 567 568 568 common->debug_mask = ath9k_debug; 569 569 ··· 620 620 621 621 void ath9k_exit_debug(struct ath_hw *ah) 622 622 { 623 - struct ath_softc *sc = ah->ah_sc; 623 + struct ath_common *common = ath9k_hw_common(ah); 624 + struct ath_softc *sc = (struct ath_softc *) common->priv; 624 625 625 626 debugfs_remove(sc->debug.debugfs_xmit); 626 627 debugfs_remove(sc->debug.debugfs_wiphy);
-1
drivers/net/wireless/ath/ath9k/hw.h
··· 450 450 451 451 struct ath_hw { 452 452 struct ieee80211_hw *hw; 453 - struct ath_softc *ah_sc; 454 453 struct ath_common common; 455 454 struct ath9k_hw_version hw_version; 456 455 struct ath9k_ops_config config;
+23 -14
drivers/net/wireless/ath/ath9k/main.c
··· 1438 1438 u32 timer_next, 1439 1439 u32 timer_period) 1440 1440 { 1441 + struct ath_common *common = ath9k_hw_common(ah); 1442 + struct ath_softc *sc = (struct ath_softc *) common->priv; 1443 + 1441 1444 ath9k_hw_gen_timer_start(ah, timer, timer_next, timer_period); 1442 1445 1443 - if ((ah->ah_sc->imask & ATH9K_INT_GENTIMER) == 0) { 1446 + if ((sc->imask & ATH9K_INT_GENTIMER) == 0) { 1444 1447 ath9k_hw_set_interrupts(ah, 0); 1445 - ah->ah_sc->imask |= ATH9K_INT_GENTIMER; 1446 - ath9k_hw_set_interrupts(ah, ah->ah_sc->imask); 1448 + sc->imask |= ATH9K_INT_GENTIMER; 1449 + ath9k_hw_set_interrupts(ah, sc->imask); 1447 1450 } 1448 1451 } 1449 1452 1450 1453 static void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer) 1451 1454 { 1455 + struct ath_common *common = ath9k_hw_common(ah); 1456 + struct ath_softc *sc = (struct ath_softc *) common->priv; 1452 1457 struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; 1453 1458 1454 1459 ath9k_hw_gen_timer_stop(ah, timer); ··· 1461 1456 /* if no timer is enabled, turn off interrupt mask */ 1462 1457 if (timer_table->timer_mask.val == 0) { 1463 1458 ath9k_hw_set_interrupts(ah, 0); 1464 - ah->ah_sc->imask &= ~ATH9K_INT_GENTIMER; 1465 - ath9k_hw_set_interrupts(ah, ah->ah_sc->imask); 1459 + sc->imask &= ~ATH9K_INT_GENTIMER; 1460 + ath9k_hw_set_interrupts(ah, sc->imask); 1466 1461 } 1467 1462 } 1468 1463 ··· 1559 1554 static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) 1560 1555 { 1561 1556 struct ath_hw *ah = (struct ath_hw *) hw_priv; 1557 + struct ath_common *common = ath9k_hw_common(ah); 1558 + struct ath_softc *sc = (struct ath_softc *) common->priv; 1562 1559 1563 1560 if (ah->config.serialize_regmode == SER_REG_MODE_ON) { 1564 1561 unsigned long flags; 1565 - spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); 1566 - iowrite32(val, ah->ah_sc->mem + reg_offset); 1567 - spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); 1562 + spin_lock_irqsave(&sc->sc_serial_rw, flags); 1563 + iowrite32(val, sc->mem + reg_offset); 1564 + spin_unlock_irqrestore(&sc->sc_serial_rw, flags); 1568 1565 } else 1569 - iowrite32(val, ah->ah_sc->mem + reg_offset); 1566 + iowrite32(val, sc->mem + reg_offset); 1570 1567 } 1571 1568 1572 1569 static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) 1573 1570 { 1574 1571 struct ath_hw *ah = (struct ath_hw *) hw_priv; 1572 + struct ath_common *common = ath9k_hw_common(ah); 1573 + struct ath_softc *sc = (struct ath_softc *) common->priv; 1575 1574 u32 val; 1576 1575 1577 1576 if (ah->config.serialize_regmode == SER_REG_MODE_ON) { 1578 1577 unsigned long flags; 1579 - spin_lock_irqsave(&ah->ah_sc->sc_serial_rw, flags); 1580 - val = ioread32(ah->ah_sc->mem + reg_offset); 1581 - spin_unlock_irqrestore(&ah->ah_sc->sc_serial_rw, flags); 1578 + spin_lock_irqsave(&sc->sc_serial_rw, flags); 1579 + val = ioread32(sc->mem + reg_offset); 1580 + spin_unlock_irqrestore(&sc->sc_serial_rw, flags); 1582 1581 } else 1583 - val = ioread32(ah->ah_sc->mem + reg_offset); 1582 + val = ioread32(sc->mem + reg_offset); 1584 1583 return val; 1585 1584 } 1586 1585 ··· 1627 1618 goto bad_no_ah; 1628 1619 } 1629 1620 1630 - ah->ah_sc = sc; 1631 1621 ah->hw_version.devid = devid; 1632 1622 ah->hw_version.subsysid = subsysid; 1633 1623 sc->sc_ah = ah; ··· 1636 1628 common->bus_ops = bus_ops; 1637 1629 common->ah = ah; 1638 1630 common->hw = sc->hw; 1631 + common->priv = sc; 1639 1632 1640 1633 /* 1641 1634 * Cache line size is used to size and align various
+3 -6
drivers/net/wireless/ath/ath9k/pci.c
··· 33 33 /* return bus cachesize in 4B word units */ 34 34 static void ath_pci_read_cachesize(struct ath_common *common, int *csz) 35 35 { 36 - struct ath_hw *ah = (struct ath_hw *) common->ah; 37 - struct ath_softc *sc = ah->ah_sc; 36 + struct ath_softc *sc = (struct ath_softc *) common->priv; 38 37 u8 u8tmp; 39 38 40 39 pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE, &u8tmp); ··· 51 52 52 53 static void ath_pci_cleanup(struct ath_common *common) 53 54 { 54 - struct ath_hw *ah = (struct ath_hw *) common->ah; 55 - struct ath_softc *sc = ah->ah_sc; 55 + struct ath_softc *sc = (struct ath_softc *) common->priv; 56 56 struct pci_dev *pdev = to_pci_dev(sc->dev); 57 57 58 58 pci_iounmap(pdev, sc->mem); ··· 84 86 */ 85 87 static void ath_pci_bt_coex_prep(struct ath_common *common) 86 88 { 87 - struct ath_hw *ah = (struct ath_hw *) common->ah; 88 - struct ath_softc *sc = ah->ah_sc; 89 + struct ath_softc *sc = (struct ath_softc *) common->priv; 89 90 struct pci_dev *pdev = to_pci_dev(sc->dev); 90 91 u8 aspm; 91 92