| 1 | From 26c22324cca2db37fa294156fd875100d95438f4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Gabor Juhos <juhosg@openwrt.org> |
| 3 | Date: Sun, 9 Dec 2012 15:19:01 +0100 |
| 4 | Subject: [PATCH 3/4] ath9k: use 'struct ath_hw *' as the first argument for |
| 5 | 'ath9k_hw_nvram_read' |
| 6 | |
| 7 | The 'ath9k_hw_nvram_read' function takes a |
| 8 | 'struct ath_common *' as its first argument. |
| 9 | Almost each of its caller has a 'struct ath_hw *' |
| 10 | parameter in their argument list, and that is |
| 11 | dereferenced in order to get the 'struct ath_common' |
| 12 | pointer. |
| 13 | |
| 14 | Change the first argument of 'ath9k_hw_nvram_read' |
| 15 | to be a 'struct ath_hw *', and remove the dereference |
| 16 | calls from the callers. |
| 17 | |
| 18 | Also change the type of the first argument of the |
| 19 | ar9300_eeprom_read_{byte,word} functions. |
| 20 | |
| 21 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
| 22 | --- |
| 23 | drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 17 ++++++++--------- |
| 24 | drivers/net/wireless/ath/ath9k/eeprom.c | 3 ++- |
| 25 | drivers/net/wireless/ath/ath9k/eeprom.h | 2 +- |
| 26 | drivers/net/wireless/ath/ath9k/eeprom_4k.c | 6 ++---- |
| 27 | drivers/net/wireless/ath/ath9k/eeprom_9287.c | 6 ++---- |
| 28 | drivers/net/wireless/ath/ath9k/eeprom_def.c | 5 ++--- |
| 29 | 6 files changed, 17 insertions(+), 22 deletions(-) |
| 30 | |
| 31 | --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |
| 32 | +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |
| 33 | @@ -3005,24 +3005,24 @@ static u32 ath9k_hw_ar9300_get_eeprom(st |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | -static bool ar9300_eeprom_read_byte(struct ath_common *common, int address, |
| 38 | +static bool ar9300_eeprom_read_byte(struct ath_hw *ah, int address, |
| 39 | u8 *buffer) |
| 40 | { |
| 41 | u16 val; |
| 42 | |
| 43 | - if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) |
| 44 | + if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val))) |
| 45 | return false; |
| 46 | |
| 47 | *buffer = (val >> (8 * (address % 2))) & 0xff; |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | -static bool ar9300_eeprom_read_word(struct ath_common *common, int address, |
| 52 | +static bool ar9300_eeprom_read_word(struct ath_hw *ah, int address, |
| 53 | u8 *buffer) |
| 54 | { |
| 55 | u16 val; |
| 56 | |
| 57 | - if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) |
| 58 | + if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val))) |
| 59 | return false; |
| 60 | |
| 61 | buffer[0] = val >> 8; |
| 62 | @@ -3048,14 +3048,14 @@ static bool ar9300_read_eeprom(struct at |
| 63 | * the 16-bit word at that address |
| 64 | */ |
| 65 | if (address % 2 == 0) { |
| 66 | - if (!ar9300_eeprom_read_byte(common, address--, buffer++)) |
| 67 | + if (!ar9300_eeprom_read_byte(ah, address--, buffer++)) |
| 68 | goto error; |
| 69 | |
| 70 | count--; |
| 71 | } |
| 72 | |
| 73 | for (i = 0; i < count / 2; i++) { |
| 74 | - if (!ar9300_eeprom_read_word(common, address, buffer)) |
| 75 | + if (!ar9300_eeprom_read_word(ah, address, buffer)) |
| 76 | goto error; |
| 77 | |
| 78 | address -= 2; |
| 79 | @@ -3063,7 +3063,7 @@ static bool ar9300_read_eeprom(struct at |
| 80 | } |
| 81 | |
| 82 | if (count % 2) |
| 83 | - if (!ar9300_eeprom_read_byte(common, address, buffer)) |
| 84 | + if (!ar9300_eeprom_read_byte(ah, address, buffer)) |
| 85 | goto error; |
| 86 | |
| 87 | return true; |
| 88 | @@ -3240,12 +3240,11 @@ static bool ar9300_check_eeprom_header(s |
| 89 | static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr, |
| 90 | int mdata_size) |
| 91 | { |
| 92 | - struct ath_common *common = ath9k_hw_common(ah); |
| 93 | u16 *data = (u16 *) mptr; |
| 94 | int i; |
| 95 | |
| 96 | for (i = 0; i < mdata_size / 2; i++, data++) |
| 97 | - ath9k_hw_nvram_read(common, i, data); |
| 98 | + ath9k_hw_nvram_read(ah, i, data); |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | --- a/drivers/net/wireless/ath/ath9k/eeprom.c |
| 103 | +++ b/drivers/net/wireless/ath/ath9k/eeprom.c |
| 104 | @@ -113,8 +113,9 @@ void ath9k_hw_usb_gen_fill_eeprom(struct |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | -bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data) |
| 109 | +bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data) |
| 110 | { |
| 111 | + struct ath_common *common = ath9k_hw_common(ah); |
| 112 | bool ret; |
| 113 | |
| 114 | ret = common->bus_ops->eeprom_read(common, off, data); |
| 115 | --- a/drivers/net/wireless/ath/ath9k/eeprom.h |
| 116 | +++ b/drivers/net/wireless/ath/ath9k/eeprom.h |
| 117 | @@ -663,7 +663,7 @@ int16_t ath9k_hw_interpolate(u16 target, |
| 118 | int16_t targetRight); |
| 119 | bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, |
| 120 | u16 *indexL, u16 *indexR); |
| 121 | -bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data); |
| 122 | +bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data); |
| 123 | void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, |
| 124 | int eep_start_loc, int size); |
| 125 | void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, |
| 126 | --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c |
| 127 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c |
| 128 | @@ -32,13 +32,11 @@ static int ath9k_hw_4k_get_eeprom_rev(st |
| 129 | |
| 130 | static bool __ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) |
| 131 | { |
| 132 | - struct ath_common *common = ath9k_hw_common(ah); |
| 133 | u16 *eep_data = (u16 *)&ah->eeprom.map4k; |
| 134 | int addr, eep_start_loc = 64; |
| 135 | |
| 136 | for (addr = 0; addr < SIZE_EEPROM_4K; addr++) { |
| 137 | - if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, |
| 138 | - eep_data)) |
| 139 | + if (!ath9k_hw_nvram_read(ah, addr + eep_start_loc, eep_data)) |
| 140 | return false; |
| 141 | eep_data++; |
| 142 | } |
| 143 | @@ -194,7 +192,7 @@ static int ath9k_hw_4k_check_eeprom(stru |
| 144 | |
| 145 | |
| 146 | if (!ath9k_hw_use_flash(ah)) { |
| 147 | - if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, |
| 148 | + if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, |
| 149 | &magic)) { |
| 150 | ath_err(common, "Reading Magic # failed\n"); |
| 151 | return false; |
| 152 | --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c |
| 153 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c |
| 154 | @@ -33,14 +33,12 @@ static int ath9k_hw_ar9287_get_eeprom_re |
| 155 | static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) |
| 156 | { |
| 157 | struct ar9287_eeprom *eep = &ah->eeprom.map9287; |
| 158 | - struct ath_common *common = ath9k_hw_common(ah); |
| 159 | u16 *eep_data; |
| 160 | int addr, eep_start_loc = AR9287_EEP_START_LOC; |
| 161 | eep_data = (u16 *)eep; |
| 162 | |
| 163 | for (addr = 0; addr < SIZE_EEPROM_AR9287; addr++) { |
| 164 | - if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, |
| 165 | - eep_data)) |
| 166 | + if (!ath9k_hw_nvram_read(ah, addr + eep_start_loc, eep_data)) |
| 167 | return false; |
| 168 | eep_data++; |
| 169 | } |
| 170 | @@ -187,7 +185,7 @@ static int ath9k_hw_ar9287_check_eeprom( |
| 171 | struct ath_common *common = ath9k_hw_common(ah); |
| 172 | |
| 173 | if (!ath9k_hw_use_flash(ah)) { |
| 174 | - if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, |
| 175 | + if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, |
| 176 | &magic)) { |
| 177 | ath_err(common, "Reading Magic # failed\n"); |
| 178 | return false; |
| 179 | --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c |
| 180 | +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c |
| 181 | @@ -91,12 +91,11 @@ static int ath9k_hw_def_get_eeprom_rev(s |
| 182 | |
| 183 | static bool __ath9k_hw_def_fill_eeprom(struct ath_hw *ah) |
| 184 | { |
| 185 | - struct ath_common *common = ath9k_hw_common(ah); |
| 186 | u16 *eep_data = (u16 *)&ah->eeprom.def; |
| 187 | int addr, ar5416_eep_start_loc = 0x100; |
| 188 | |
| 189 | for (addr = 0; addr < SIZE_EEPROM_DEF; addr++) { |
| 190 | - if (!ath9k_hw_nvram_read(common, addr + ar5416_eep_start_loc, |
| 191 | + if (!ath9k_hw_nvram_read(ah, addr + ar5416_eep_start_loc, |
| 192 | eep_data)) |
| 193 | return false; |
| 194 | eep_data++; |
| 195 | @@ -268,7 +267,7 @@ static int ath9k_hw_def_check_eeprom(str |
| 196 | bool need_swap = false; |
| 197 | int i, addr, size; |
| 198 | |
| 199 | - if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { |
| 200 | + if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { |
| 201 | ath_err(common, "Reading Magic # failed\n"); |
| 202 | return false; |
| 203 | } |
| 204 | |