rt2x00: Add eeprom_multiread function
Subsystems (3)
PATCH 4/32 rt2x00: Add eeprom_multiread function
From: Ivo van Doorn <[email protected]>
Add the eeprom_multiread function and clean up the code a bit by using it as well. ;)
Signed-off-by Ivo van Doorn <[email protected]>
drivers/net/wireless/d80211/rt2x00/rt2400pci.c +13 -3
@@ -351,6 +351,17 @@ rt2x00_eeprom_read(rt2x00_eeprom_pulse_low (rt2x00pci, &flags); } +static void +rt2x00_eeprom_multiread ( +const struct rt2x00_pci *rt2x00pci, +const u8 word,u16 *data,const u16 length) +{ +int counter; + +for (counter =0 ; counter < (length /sizeof (u16)); counter++) +rt2x00_eeprom_read (rt2x00pci, word + counter, data++); +} +/* * Configuration handlers. */
@@ -1824,9 +1835,8 @@ rt2400pci_init_eeprom(struct rt2x00_pci/* * 7 - Read BBP data from EEPROM and store in private structure. */ -for (counter =0 ; counter <EEPROM_BBP_SIZE ; counter++) -rt2x00_eeprom_read (rt2x00pci,EEPROM_BBP_START + counter, - &rt2x00pci->eeprom[counter]); +rt2x00_eeprom_multiread (rt2x00pci,EEPROM_BBP_START , + &rt2x00pci->eeprom,EEPROM_BBP_SIZE *sizeof (u16));return 0 ; }
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +13 -3
@@ -351,6 +351,17 @@ rt2x00_eeprom_read(rt2x00_eeprom_pulse_low (rt2x00pci, &flags); } +static void +rt2x00_eeprom_multiread ( +const struct rt2x00_pci *rt2x00pci, +const u8 word,u16 *data,const u16 length) +{ +int counter; + +for (counter =0 ; counter < (length /sizeof (u16)); counter++) +rt2x00_eeprom_read (rt2x00pci, word + counter, data++); +} +/* * Configuration handlers. */
@@ -1886,9 +1897,8 @@ rt2500pci_init_eeprom(struct rt2x00_pci/* * 7 - Read BBP data from EEPROM and store in private structure. */ -for (counter =0 ; counter <EEPROM_BBP_SIZE ; counter++) -rt2x00_eeprom_read (rt2x00pci,EEPROM_BBP_START + counter, - &rt2x00pci->eeprom[counter]); +rt2x00_eeprom_multiread (rt2x00pci,EEPROM_BBP_START , + &rt2x00pci->eeprom,EEPROM_BBP_SIZE *sizeof (u16));return 0 ; }
drivers/net/wireless/d80211/rt2x00/rt2500usb.c +16 -6
@@ -228,11 +228,21 @@ rf_write:static inline void rt2x00_eeprom_read (const struct rt2x00_usb *rt2x00usb, -const u16 offset,u16 *value,const u16 length) +const u16 word,u16 *data) {rt2x00_vendor_request ( rt2x00usb,USB_EEPROM_READ ,USB_VENDOR_REQUEST_IN , - offset,0x00 , value, length); + word,0x00 , data,2 ); +} + +static void +rt2x00_eeprom_multiread ( +const struct rt2x00_usb *rt2x00usb, +const u8 word,u16 *data,const u16 length) +{ +rt2x00_vendor_request ( + rt2x00usb,USB_EEPROM_READ ,USB_VENDOR_REQUEST_IN , + word,0x00 , data, length); }/*
@@ -1552,7 +1562,7 @@ rt2500usb_init_eeprom(struct rt2x00_usb/* * 1 - Read EEPROM word for configuration. */ -rt2x00_eeprom_read (rt2x00usb,EEPROM_ANTENNA , &eeprom,2 ); +rt2x00_eeprom_read (rt2x00usb,EEPROM_ANTENNA , &eeprom);/* * 2 - Identify RF chipset.
@@ -1579,7 +1589,7 @@ rt2500usb_init_eeprom(struct rt2x00_usb* 5 - Read BBP data from EEPROM and store in private structure. */ memset (&rt2x00usb->eeprom,0x00 ,sizeof (rt2x00usb->eeprom)); -rt2x00_eeprom_read (rt2x00usb,EEPROM_BBP_START , +rt2x00_eeprom_multiread (rt2x00usb,EEPROM_BBP_START , &rt2x00usb->eeprom[0 ],EEPROM_BBP_SIZE );return 0 ;
@@ -1595,7 +1605,7 @@ rt2500usb_init_mac(struct rt2x00_usb *rt/* * Read MAC address from EEPROM. */ -rt2x00_eeprom_read (rt2x00usb,EEPROM_MAC_ADDR , ®[0 ],6 ); +rt2x00_eeprom_multiread (rt2x00usb,EEPROM_MAC_ADDR , ®[0 ],6 ); net_dev->dev_addr[0 ] =rt2x00_get_field16 (reg[0 ],MAC_CSR2_BYTE0 ); net_dev->dev_addr[1 ] =rt2x00_get_field16 (reg[0 ],MAC_CSR2_BYTE1 );
@@ -1733,7 +1743,7 @@ rt2500usb_init_hw_channels(struct rt2x00*/ for (counter =0 ; counter <EEPROM_TXPOWER_SIZE ; counter++) {rt2x00_eeprom_read (rt2x00usb, -EEPROM_TXPOWER_START + counter, &eeprom,2 ); +EEPROM_TXPOWER_START + counter, &eeprom); channels[(counter *2 )].power_level =rt2x00_get_field16 (eeprom,EEPROM_TXPOWER_1 );