Commit 0e4b9f2f authored by Gabor Juhos's avatar Gabor Juhos Committed by John W. Linville

ath9k: use 'struct ath_hw *' as the first argument for 'ath9k_hw_nvram_read'

The 'ath9k_hw_nvram_read' function takes a
'struct ath_common *' as its first argument.
Almost each of its caller has a 'struct ath_hw *'
parameter in their argument list, and that is
dereferenced in order to get the 'struct ath_common'
pointer.

Change the first argument of 'ath9k_hw_nvram_read'
to be a 'struct ath_hw *', and remove the dereference
calls from the callers.

Also change the type of the first argument of the
ar9300_eeprom_read_{byte,word} functions.
Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7177d8f9
...@@ -3001,24 +3001,24 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah, ...@@ -3001,24 +3001,24 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
} }
} }
static bool ar9300_eeprom_read_byte(struct ath_common *common, int address, static bool ar9300_eeprom_read_byte(struct ath_hw *ah, int address,
u8 *buffer) u8 *buffer)
{ {
u16 val; u16 val;
if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
return false; return false;
*buffer = (val >> (8 * (address % 2))) & 0xff; *buffer = (val >> (8 * (address % 2))) & 0xff;
return true; return true;
} }
static bool ar9300_eeprom_read_word(struct ath_common *common, int address, static bool ar9300_eeprom_read_word(struct ath_hw *ah, int address,
u8 *buffer) u8 *buffer)
{ {
u16 val; u16 val;
if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val))) if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
return false; return false;
buffer[0] = val >> 8; buffer[0] = val >> 8;
...@@ -3044,14 +3044,14 @@ static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer, ...@@ -3044,14 +3044,14 @@ static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
* the 16-bit word at that address * the 16-bit word at that address
*/ */
if (address % 2 == 0) { if (address % 2 == 0) {
if (!ar9300_eeprom_read_byte(common, address--, buffer++)) if (!ar9300_eeprom_read_byte(ah, address--, buffer++))
goto error; goto error;
count--; count--;
} }
for (i = 0; i < count / 2; i++) { for (i = 0; i < count / 2; i++) {
if (!ar9300_eeprom_read_word(common, address, buffer)) if (!ar9300_eeprom_read_word(ah, address, buffer))
goto error; goto error;
address -= 2; address -= 2;
...@@ -3059,7 +3059,7 @@ static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer, ...@@ -3059,7 +3059,7 @@ static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
} }
if (count % 2) if (count % 2)
if (!ar9300_eeprom_read_byte(common, address, buffer)) if (!ar9300_eeprom_read_byte(ah, address, buffer))
goto error; goto error;
return true; return true;
...@@ -3236,12 +3236,11 @@ static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read, ...@@ -3236,12 +3236,11 @@ static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr, static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
int mdata_size) int mdata_size)
{ {
struct ath_common *common = ath9k_hw_common(ah);
u16 *data = (u16 *) mptr; u16 *data = (u16 *) mptr;
int i; int i;
for (i = 0; i < mdata_size / 2; i++, data++) for (i = 0; i < mdata_size / 2; i++, data++)
ath9k_hw_nvram_read(common, i, data); ath9k_hw_nvram_read(ah, i, data);
return 0; return 0;
} }
......
...@@ -113,8 +113,9 @@ void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, ...@@ -113,8 +113,9 @@ void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
} }
} }
bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data) bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
{ {
struct ath_common *common = ath9k_hw_common(ah);
bool ret; bool ret;
ret = common->bus_ops->eeprom_read(common, off, data); ret = common->bus_ops->eeprom_read(common, off, data);
......
...@@ -663,7 +663,7 @@ int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, ...@@ -663,7 +663,7 @@ int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight,
int16_t targetRight); int16_t targetRight);
bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize,
u16 *indexL, u16 *indexR); u16 *indexL, u16 *indexR);
bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data); bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data);
void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
int eep_start_loc, int size); int eep_start_loc, int size);
void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
......
...@@ -32,13 +32,11 @@ static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah) ...@@ -32,13 +32,11 @@ static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
static bool __ath9k_hw_4k_fill_eeprom(struct ath_hw *ah) static bool __ath9k_hw_4k_fill_eeprom(struct ath_hw *ah)
{ {
struct ath_common *common = ath9k_hw_common(ah);
u16 *eep_data = (u16 *)&ah->eeprom.map4k; u16 *eep_data = (u16 *)&ah->eeprom.map4k;
int addr, eep_start_loc = 64; int addr, eep_start_loc = 64;
for (addr = 0; addr < SIZE_EEPROM_4K; addr++) { for (addr = 0; addr < SIZE_EEPROM_4K; addr++) {
if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, if (!ath9k_hw_nvram_read(ah, addr + eep_start_loc, eep_data))
eep_data))
return false; return false;
eep_data++; eep_data++;
} }
...@@ -194,7 +192,7 @@ static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah) ...@@ -194,7 +192,7 @@ static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah)
if (!ath9k_hw_use_flash(ah)) { if (!ath9k_hw_use_flash(ah)) {
if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET,
&magic)) { &magic)) {
ath_err(common, "Reading Magic # failed\n"); ath_err(common, "Reading Magic # failed\n");
return false; return false;
......
...@@ -33,14 +33,12 @@ static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah) ...@@ -33,14 +33,12 @@ static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah) static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
{ {
struct ar9287_eeprom *eep = &ah->eeprom.map9287; struct ar9287_eeprom *eep = &ah->eeprom.map9287;
struct ath_common *common = ath9k_hw_common(ah);
u16 *eep_data; u16 *eep_data;
int addr, eep_start_loc = AR9287_EEP_START_LOC; int addr, eep_start_loc = AR9287_EEP_START_LOC;
eep_data = (u16 *)eep; eep_data = (u16 *)eep;
for (addr = 0; addr < SIZE_EEPROM_AR9287; addr++) { for (addr = 0; addr < SIZE_EEPROM_AR9287; addr++) {
if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, if (!ath9k_hw_nvram_read(ah, addr + eep_start_loc, eep_data))
eep_data))
return false; return false;
eep_data++; eep_data++;
} }
...@@ -187,7 +185,7 @@ static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah) ...@@ -187,7 +185,7 @@ static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
if (!ath9k_hw_use_flash(ah)) { if (!ath9k_hw_use_flash(ah)) {
if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET,
&magic)) { &magic)) {
ath_err(common, "Reading Magic # failed\n"); ath_err(common, "Reading Magic # failed\n");
return false; return false;
......
...@@ -91,12 +91,11 @@ static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah) ...@@ -91,12 +91,11 @@ static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
static bool __ath9k_hw_def_fill_eeprom(struct ath_hw *ah) static bool __ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
{ {
struct ath_common *common = ath9k_hw_common(ah);
u16 *eep_data = (u16 *)&ah->eeprom.def; u16 *eep_data = (u16 *)&ah->eeprom.def;
int addr, ar5416_eep_start_loc = 0x100; int addr, ar5416_eep_start_loc = 0x100;
for (addr = 0; addr < SIZE_EEPROM_DEF; addr++) { for (addr = 0; addr < SIZE_EEPROM_DEF; addr++) {
if (!ath9k_hw_nvram_read(common, addr + ar5416_eep_start_loc, if (!ath9k_hw_nvram_read(ah, addr + ar5416_eep_start_loc,
eep_data)) eep_data))
return false; return false;
eep_data++; eep_data++;
...@@ -268,7 +267,7 @@ static int ath9k_hw_def_check_eeprom(struct ath_hw *ah) ...@@ -268,7 +267,7 @@ static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)
bool need_swap = false; bool need_swap = false;
int i, addr, size; int i, addr, size;
if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, &magic)) { if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
ath_err(common, "Reading Magic # failed\n"); ath_err(common, "Reading Magic # failed\n");
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment