ath5k: merge ath5k_hw and ath5k_softc
PATCH v3 1/1 ath5k: merge ath5k_hw and ath5k_softc
Both ath5k_hw and ath5k_softc represent one instance of the hardware. This duplication is historical and is not needed anymore.
Keep the name "ath5k_hw" for the merged structure and "ah" for the variable pointing to it. "ath5k_hw" is shorter than "ath5k_softc", more descriptive and more widely used.
Put the combined structure to ath5k.h where the old ath5k_softc used to be. Move some code from base.h to ath5k.h as needed.
Remove memory allocation for struct ath5k_hw and the corresponding error handling. Merge iobase and ah_iobase fields.
Rename ath5k_init_softc() and ath5k_deinit_softc() to ath5k_init_ah() and ath5k_deinit_ah() respectively.
---
This version of the patch was tested on both wireless-testing and linux-next (thanks to Sedat Dilek). It also removes all occurrences of "softc", as they are not very meaningful now.
drivers/net/wireless/ath/ath5k/ahb.c | 44 - drivers/net/wireless/ath/ath5k/ani.c | 84 +- drivers/net/wireless/ath/ath5k/ath5k.h | 243 +++++ drivers/net/wireless/ath/ath5k/attach.c | 31 - drivers/net/wireless/ath/ath5k/base.c | 1132 ++++++++++++------------- drivers/net/wireless/ath/ath5k/base.h | 199 ---- drivers/net/wireless/ath/ath5k/debug.c | 218 ++--- drivers/net/wireless/ath/ath5k/debug.h | 21 drivers/net/wireless/ath/ath5k/desc.c | 10 drivers/net/wireless/ath/ath5k/dma.c | 12 drivers/net/wireless/ath/ath5k/eeprom.c | 4 drivers/net/wireless/ath/ath5k/initvals.c | 2 drivers/net/wireless/ath/ath5k/led.c | 68 +- drivers/net/wireless/ath/ath5k/mac80211-ops.c | 243 +++-- drivers/net/wireless/ath/ath5k/pci.c | 38 - drivers/net/wireless/ath/ath5k/pcu.c | 24 - drivers/net/wireless/ath/ath5k/phy.c | 32 - drivers/net/wireless/ath/ath5k/qcu.c | 9 drivers/net/wireless/ath/ath5k/reset.c | 44 - drivers/net/wireless/ath/ath5k/rfkill.c | 65 + drivers/net/wireless/ath/ath5k/sysfs.c | 32 - drivers/net/wireless/ath/ath5k/trace.h | 12 22 files changed, 1250 insertions(+), 1317 deletions(-)
drivers/net/wireless/ath/ath5k/ahb.c +21 -23
@@ -35,8 +35,8 @@ static void ath5k_ahb_read_cachesize(struct ath_common *common, int *csz)static bool ath5k_ahb_eeprom_read (struct ath_common *common,u32 off,u16 *data) { -struct ath5k_softc *sc = common->priv; -struct platform_device *pdev =to_platform_device (sc->dev); +struct ath5k_hw *ah = common->priv; +struct platform_device *pdev =to_platform_device (ah->dev);struct ar231x_board_config *bcfg = pdev->dev.platform_data;u16 *eeprom, *eeprom_end;
@@ -56,8 +56,7 @@ ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)int ath5k_hw_read_srev (struct ath5k_hw *ah) { -struct ath5k_softc *sc = ah->ah_sc; -struct platform_device *pdev =to_platform_device (sc->dev); +struct platform_device *pdev =to_platform_device (ah->dev);struct ar231x_board_config *bcfg = pdev->dev.platform_data; ah->ah_mac_srev = bcfg->devid;return 0 ;
@@ -65,12 +64,11 @@ int ath5k_hw_read_srev(struct ath5k_hw *ah)static int ath5k_ahb_eeprom_read_mac (struct ath5k_hw *ah,u8 *mac) { -struct ath5k_softc *sc = ah->ah_sc; -struct platform_device *pdev =to_platform_device (sc->dev); +struct platform_device *pdev =to_platform_device (ah->dev);struct ar231x_board_config *bcfg = pdev->dev.platform_data;u8 *cfg_mac; -if (to_platform_device (sc->dev)->id ==0 ) +if (to_platform_device (ah->dev)->id ==0 ) cfg_mac = bcfg->config->wlan0_mac;else cfg_mac = bcfg->config->wlan1_mac;
@@ -90,7 +88,7 @@ static const struct ath_bus_ops ath_ahb_bus_ops = {static int ath_ahb_probe (struct platform_device *pdev) {struct ar231x_board_config *bcfg = pdev->dev.platform_data; -struct ath5k_softc *sc; +struct ath5k_hw *ah;struct ieee80211_hw *hw;struct resource *res;void __iomem *mem;
@@ -127,19 +125,19 @@ static int ath_ahb_probe(struct platform_device *pdev) irq = res->start; - hw =ieee80211_alloc_hw (sizeof (struct ath5k_softc ), &ath5k_hw_ops); + hw =ieee80211_alloc_hw (sizeof (struct ath5k_hw ), &ath5k_hw_ops);if (hw ==NULL ) {dev_err (&pdev->dev,"no memory for ieee80211_hw\n" ); ret = -ENOMEM ; goto err_out; } - sc = hw->priv; - sc->hw = hw; - sc->dev = &pdev->dev; - sc->iobase = mem; - sc->irq = irq; - sc->devid = bcfg->devid; + ah = hw->priv; + ah->hw = hw; + ah->dev = &pdev->dev; + ah->iobase = mem; + ah->irq = irq; + ah->devid = bcfg->devid;if (bcfg->devid >=AR5K_SREV_AR2315_R6 ) {/* Enable WMAC AHB arbitration */
@@ -155,7 +153,7 @@ static int ath_ahb_probe(struct platform_device *pdev)/* Enable WMAC DMA access (assuming 5312 or 231x*/ /* TODO: check other platforms */ reg =__raw_readl ((void __iomem *)AR5K_AR5312_ENABLE ); -if (to_platform_device (sc->dev)->id ==0 ) +if (to_platform_device (ah->dev)->id ==0 ) reg |=AR5K_AR5312_ENABLE_WLAN0 ;else reg |=AR5K_AR5312_ENABLE_WLAN1 ;
@@ -166,13 +164,13 @@ static int ath_ahb_probe(struct platform_device *pdev)* used as pass-through. Disable 2 GHz support in the * driver for it */ -if (to_platform_device (sc->dev)->id ==0 && +if (to_platform_device (ah->dev)->id ==0 && (bcfg->config->flags & (BD_WLAN0 |BD_WLAN1 )) == (BD_WLAN1 |BD_WLAN0 )) -__set_bit (ATH_STAT_2G_DISABLED , sc->status); +__set_bit (ATH_STAT_2G_DISABLED , ah->status); } - ret =ath5k_init_softc (sc, &ath_ahb_bus_ops); + ret =ath5k_init_ah (ah, &ath_ahb_bus_ops);if (ret !=0 ) {dev_err (&pdev->dev,"failed to attach device, err=%d\n" , ret); ret = -ENODEV ;
@@ -194,13 +192,13 @@ static int ath_ahb_remove(struct platform_device *pdev) {struct ar231x_board_config *bcfg = pdev->dev.platform_data;struct ieee80211_hw *hw =platform_get_drvdata (pdev); -struct ath5k_softc *sc; +struct ath5k_hw *ah;u32 reg;if (!hw)return 0 ; - sc = hw->priv; + ah = hw->priv;if (bcfg->devid >=AR5K_SREV_AR2315_R6 ) {/* Disable WMAC AHB arbitration */
@@ -210,14 +208,14 @@ static int ath_ahb_remove(struct platform_device *pdev) }else {/*Stop DMA access */ reg =__raw_readl ((void __iomem *)AR5K_AR5312_ENABLE ); -if (to_platform_device (sc->dev)->id ==0 ) +if (to_platform_device (ah->dev)->id ==0 ) reg &= ~AR5K_AR5312_ENABLE_WLAN0 ;else reg &= ~AR5K_AR5312_ENABLE_WLAN1 ;__raw_writel (reg, (void __iomem *)AR5K_AR5312_ENABLE ); } -ath5k_deinit_softc (sc); +ath5k_deinit_ah (ah);platform_set_drvdata (pdev,NULL );ieee80211_free_hw (hw);
drivers/net/wireless/ath/ath5k/ani.c +42 -42
262 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/ath5k.h +215 -28
317 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/attach.c +15 -16
@@ -59,7 +59,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah) cur_val =ath5k_hw_reg_read (ah, cur_reg);if (cur_val != var_pattern) { -ATH5K_ERR (ah->ah_sc,"POST Failed !!!\n" ); +ATH5K_ERR (ah,"POST Failed !!!\n" );return -EAGAIN ; }
@@ -74,7 +74,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah) cur_val =ath5k_hw_reg_read (ah, cur_reg);if (cur_val != var_pattern) { -ATH5K_ERR (ah->ah_sc,"POST Failed !!!\n" ); +ATH5K_ERR (ah,"POST Failed !!!\n" );return -EAGAIN ; }
@@ -95,19 +95,18 @@ static int ath5k_hw_post(struct ath5k_hw *ah)/** * ath5k_hw_init - Check if hw is supported and init the needed structs * -* @sc: The &struct ath5k_softc we got from the driver's init_softc function +* @ah: The &struct ath5k_hw we got from the driver's init_ah function * * Check if the device is supported, perform a POST and initialize the needed * structs. Returns -ENOMEM if we don't have memory for the needed structs, * -ENODEV if the device is not supported or prints an error msg if something * else went wrong. */ -int ath5k_hw_init (struct ath5k_softc *sc) +int ath5k_hw_init (struct ath5k_hw *ah) {static const u8 zero_mac[ETH_ALEN ] = { }; -struct ath5k_hw *ah = sc->ah;struct ath_common *common =ath5k_hw_common (ah); -struct pci_dev *pdev = sc->pdev; +struct pci_dev *pdev = ah->pdev;struct ath5k_eeprom_info *ee;int ret;u32 srev;
@@ -123,8 +122,8 @@ int ath5k_hw_init(struct ath5k_softc *sc) ah->ah_retry_long =AR5K_INIT_RETRY_LONG ; ah->ah_ant_mode =AR5K_ANTMODE_DEFAULT ; ah->ah_noise_floor =-95 ;/* until first NF calibration is run */ - sc->ani_state.ani_mode =ATH5K_ANI_MODE_AUTO ; - ah->ah_current_channel = &sc->channels[0 ]; + ah->ani_state.ani_mode =ATH5K_ANI_MODE_AUTO ; + ah->ah_current_channel = &ah->channels[0 ];/* * Find the mac version
@@ -237,7 +236,7 @@ int ath5k_hw_init(struct ath5k_softc *sc) ah->ah_single_chip = true; ah->ah_radio_5ghz_revision =AR5K_SREV_RAD_2413 ; }else { -ATH5K_ERR (sc,"Couldn't identify radio revision.\n" ); +ATH5K_ERR (ah,"Couldn't identify radio revision.\n" ); ret = -ENODEV ; goto err; }
@@ -246,7 +245,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)/* Return on unsupported chips (unsupported eeprom etc) */ if ((srev >=AR5K_SREV_AR5416 ) && (srev <AR5K_SREV_AR2425 )) { -ATH5K_ERR (sc,"Device not yet supported.\n" ); +ATH5K_ERR (ah,"Device not yet supported.\n" ); ret = -ENODEV ; goto err; }
@@ -268,7 +267,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)*/ ret =ath5k_eeprom_init (ah);if (ret) { -ATH5K_ERR (sc,"unable to init EEPROM\n" ); +ATH5K_ERR (ah,"unable to init EEPROM\n" ); goto err; }
@@ -309,17 +308,17 @@ int ath5k_hw_init(struct ath5k_softc *sc)/* Get misc capabilities */ ret =ath5k_hw_set_capabilities (ah);if (ret) { -ATH5K_ERR (sc,"unable to get device capabilities\n" ); +ATH5K_ERR (ah,"unable to get device capabilities\n" ); goto err; } -if (test_bit (ATH_STAT_2G_DISABLED , sc->status)) { +if (test_bit (ATH_STAT_2G_DISABLED , ah->status)) {__clear_bit (AR5K_MODE_11B , ah->ah_capabilities.cap_mode);__clear_bit (AR5K_MODE_11G , ah->ah_capabilities.cap_mode); }/* Crypto settings */ - common->keymax = (sc->ah->ah_version ==AR5K_AR5210 ? + common->keymax = (ah->ah_version ==AR5K_AR5210 ?AR5K_KEYTABLE_SIZE_5210 :AR5K_KEYTABLE_SIZE_5211 ); if (srev >= AR5K_SREV_AR5212_V4 &&
@@ -339,7 +338,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)/* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */ memcpy (common->curbssid, ath_bcast_mac,ETH_ALEN );ath5k_hw_set_bssid (ah); -ath5k_hw_set_opmode (ah, sc->opmode); +ath5k_hw_set_opmode (ah, ah->opmode);ath5k_hw_rfgain_opt_init (ah);
@@ -360,7 +359,7 @@ err:*/ void ath5k_hw_deinit (struct ath5k_hw *ah) { -__set_bit (ATH_STAT_INVALID , ah->ah_sc->status); +__set_bit (ATH_STAT_INVALID , ah->status);if (ah->ah_rf_banks !=NULL )kfree (ah->ah_rf_banks);
drivers/net/wireless/ath/ath5k/base.c +548 -584
2,191 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/base.h +0 -199
199 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/debug.c +108 -110
218 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/debug.h +10 -11
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath5k/eeprom.c +2 -2
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath5k/initvals.c +1 -1
Lines of this file are not shown. View the raw message.
drivers/net/wireless/ath/ath5k/led.c +34 -34
68 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/mac80211-ops.c +119 -124
243 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/reset.c +22 -22
44 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/rfkill.c +30 -35
65 lines not on this page · raw message
drivers/net/wireless/ath/ath5k/sysfs.c +16 -16
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.