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

Staging: w35und: merge wbhal.c to wbusb.c

Impact: cleanup

This patch moves all the functions in wbhal.c that are used only in
wbusb.c to the latter file.

Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Pekka Enberg and committed by
Greg Kroah-Hartman
22a82bcd c6e523c0

+202 -219
-206
drivers/staging/winbond/wbhal.c
··· 2 2 #include "wbhal_f.h" 3 3 #include "wblinux_f.h" 4 4 5 - void hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address) 6 - { 7 - u32 ltmp[2]; 8 - 9 - if (pHwData->SurpriseRemove) 10 - return; 11 - 12 - memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN); 13 - 14 - ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress); 15 - ltmp[1] = 16 - cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff; 17 - 18 - Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT); 19 - } 20 - 21 - void hal_get_permanent_address(struct hw_data *pHwData, u8 * pethernet_address) 22 - { 23 - if (pHwData->SurpriseRemove) 24 - return; 25 - 26 - memcpy(pethernet_address, pHwData->PermanentMacAddress, 6); 27 - } 28 - 29 - //--------------------------------------------------------------------------------------------------- 30 - void hal_set_beacon_period(struct hw_data *pHwData, u16 beacon_period) 31 - { 32 - u32 tmp; 33 - 34 - if (pHwData->SurpriseRemove) 35 - return; 36 - 37 - pHwData->BeaconPeriod = beacon_period; 38 - tmp = pHwData->BeaconPeriod << 16; 39 - tmp |= pHwData->ProbeDelay; 40 - Wb35Reg_Write(pHwData, 0x0848, tmp); 41 - } 42 - 43 - static void hal_set_current_channel_ex(struct hw_data *pHwData, 44 - ChanInfo channel) 45 - { 46 - struct wb35_reg *reg = &pHwData->reg; 47 - 48 - if (pHwData->SurpriseRemove) 49 - return; 50 - 51 - printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo); 52 - 53 - RFSynthesizer_SwitchingChannel(pHwData, channel); // Switch channel 54 - pHwData->Channel = channel.ChanNo; 55 - pHwData->band = channel.band; 56 - #ifdef _PE_STATE_DUMP_ 57 - printk("Set channel is %d, band =%d\n", pHwData->Channel, 58 - pHwData->band); 59 - #endif 60 - reg->M28_MacControl &= ~0xff; // Clean channel information field 61 - reg->M28_MacControl |= channel.ChanNo; 62 - Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl, 63 - (s8 *) & channel, sizeof(ChanInfo)); 64 - } 65 - 66 - //--------------------------------------------------------------------------------------------------- 67 - void hal_set_current_channel(struct hw_data *pHwData, ChanInfo channel) 68 - { 69 - hal_set_current_channel_ex(pHwData, channel); 70 - } 71 - 72 - //--------------------------------------------------------------------------------------------------- 73 - void hal_set_accept_broadcast(struct hw_data *pHwData, u8 enable) 74 - { 75 - struct wb35_reg *reg = &pHwData->reg; 76 - 77 - if (pHwData->SurpriseRemove) 78 - return; 79 - 80 - reg->M00_MacControl &= ~0x02000000; //The HW value 81 - 82 - if (enable) 83 - reg->M00_MacControl |= 0x02000000; //The HW value 84 - 85 - Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 86 - } 87 - 88 - //for wep key error detection, we need to accept broadcast packets to be received temporary. 89 - void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable) 90 - { 91 - struct wb35_reg *reg = &pHwData->reg; 92 - 93 - if (pHwData->SurpriseRemove) 94 - return; 95 - if (enable) { 96 - reg->M00_MacControl |= 0x00400000; 97 - Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 98 - } else { 99 - reg->M00_MacControl &= ~0x00400000; 100 - Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 101 - } 102 - } 103 - 104 - void hal_set_accept_multicast(struct hw_data *pHwData, u8 enable) 105 - { 106 - struct wb35_reg *reg = &pHwData->reg; 107 - 108 - if (pHwData->SurpriseRemove) 109 - return; 110 - 111 - reg->M00_MacControl &= ~0x01000000; //The HW value 112 - if (enable) 113 - reg->M00_MacControl |= 0x01000000; //The HW value 114 - Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 115 - } 116 - 117 - void hal_set_accept_beacon(struct hw_data *pHwData, u8 enable) 118 - { 119 - struct wb35_reg *reg = &pHwData->reg; 120 - 121 - if (pHwData->SurpriseRemove) 122 - return; 123 - 124 - // 20040108 debug 125 - if (!enable) //Due to SME and MLME are not suitable for 35 126 - return; 127 - 128 - reg->M00_MacControl &= ~0x04000000; //The HW value 129 - if (enable) 130 - reg->M00_MacControl |= 0x04000000; //The HW value 131 - 132 - Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 133 - } 134 - 135 - //--------------------------------------------------------------------------------------------------- 136 - 137 - void hal_stop(struct hw_data *pHwData) 138 - { 139 - struct wb35_reg *reg = &pHwData->reg; 140 - 141 - pHwData->Wb35Rx.rx_halt = 1; 142 - Wb35Rx_stop(pHwData); 143 - 144 - pHwData->Wb35Tx.tx_halt = 1; 145 - Wb35Tx_stop(pHwData); 146 - 147 - reg->D00_DmaControl &= ~0xc0000000; //Tx Off, Rx Off 148 - Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl); 149 - } 150 - 151 - unsigned char hal_idle(struct hw_data *pHwData) 152 - { 153 - struct wb35_reg *reg = &pHwData->reg; 154 - struct wb_usb *pWbUsb = &pHwData->WbUsb; 155 - 156 - if (!pHwData->SurpriseRemove 157 - && (pWbUsb->DetectCount || reg->EP0vm_state != VM_STOP)) 158 - return false; 159 - 160 - return true; 161 - } 162 - 163 - void hal_set_radio_mode(struct hw_data *pHwData, unsigned char radio_off) 164 - { 165 - struct wb35_reg *reg = &pHwData->reg; 166 - 167 - if (pHwData->SurpriseRemove) 168 - return; 169 - 170 - if (radio_off) //disable Baseband receive off 171 - { 172 - pHwData->CurrentRadioSw = 1; // off 173 - reg->M24_MacControl &= 0xffffffbf; 174 - } else { 175 - pHwData->CurrentRadioSw = 0; // on 176 - reg->M24_MacControl |= 0x00000040; 177 - } 178 - Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl); 179 - } 180 - 181 - u8 hal_get_antenna_number(struct hw_data *pHwData) 182 - { 183 - struct wb35_reg *reg = &pHwData->reg; 184 - 185 - if ((reg->BB2C & BIT(11)) == 0) 186 - return 0; 187 - else 188 - return 1; 189 - } 190 - 191 - //---------------------------------------------------------------------------------------------------- 192 - //0 : radio on; 1: radio off 193 - u8 hal_get_hw_radio_off(struct hw_data * pHwData) 194 - { 195 - struct wb35_reg *reg = &pHwData->reg; 196 - 197 - if (pHwData->SurpriseRemove) 198 - return 1; 199 - 200 - //read the bit16 of register U1B0 201 - Wb35Reg_Read(pHwData, 0x3b0, &reg->U1B0); 202 - if ((reg->U1B0 & 0x00010000)) { 203 - pHwData->CurrentRadioHw = 1; 204 - return 1; 205 - } else { 206 - pHwData->CurrentRadioHw = 0; 207 - return 0; 208 - } 209 - } 210 - 211 5 unsigned char hal_get_dxx_reg(struct hw_data *pHwData, u16 number, u32 * pValue) 212 6 { 213 7 if (number < 0x1000)
-13
drivers/staging/winbond/wbhal_f.h
··· 18 18 void hal_clear_all_group_key( struct hw_data * pHwData ); 19 19 void hal_clear_all_mapping_key( struct hw_data * pHwData ); 20 20 void hal_clear_all_key( struct hw_data * pHwData ); 21 - void hal_get_ethernet_address( struct hw_data * pHwData, u8 *current_address ); 22 - void hal_set_ethernet_address( struct hw_data * pHwData, u8 *current_address ); 23 - void hal_get_permanent_address( struct hw_data * pHwData, u8 *pethernet_address ); 24 21 void hal_set_power_save_mode( struct hw_data * pHwData, unsigned char power_save, unsigned char wakeup, unsigned char dtim ); 25 22 void hal_get_power_save_mode( struct hw_data * pHwData, u8 *pin_pwr_save ); 26 23 void hal_set_slot_time( struct hw_data * pHwData, u8 type ); ··· 29 32 void hal_set_aid( struct hw_data * pHwData, u16 aid ); 30 33 void hal_set_bssid( struct hw_data * pHwData, u8 *pbssid ); 31 34 void hal_get_bssid( struct hw_data * pHwData, u8 *pbssid ); 32 - void hal_set_beacon_period( struct hw_data * pHwData, u16 beacon_period ); 33 35 void hal_set_listen_interval( struct hw_data * pHwData, u16 listen_interval ); 34 36 void hal_set_cap_info( struct hw_data * pHwData, u16 capability_info ); 35 37 void hal_set_ssid( struct hw_data * pHwData, u8 *pssid, u8 ssid_len ); 36 - void hal_set_current_channel( struct hw_data * pHwData, ChanInfo channel ); 37 - void hal_set_accept_broadcast( struct hw_data * pHwData, u8 enable ); 38 - void hal_set_accept_multicast( struct hw_data * pHwData, u8 enable ); 39 - void hal_set_accept_beacon( struct hw_data * pHwData, u8 enable ); 40 - void hal_stop( struct hw_data * pHwData ); 41 38 void hal_start_tx0( struct hw_data * pHwData ); 42 39 #define hal_get_cwmin( _A ) ( (_A)->cwmin ) 43 40 void hal_set_cwmax( struct hw_data * pHwData, u16 cwin_max ); ··· 40 49 void hal_set_connect_info( struct hw_data * pHwData, unsigned char boConnect ); 41 50 u8 hal_get_est_sq3( struct hw_data * pHwData, u8 Count ); 42 51 void hal_set_rf_power( struct hw_data * pHwData, u8 PowerIndex ); // 20060621 Modify 43 - void hal_set_radio_mode( struct hw_data * pHwData, unsigned char boValue); 44 52 void hal_descriptor_indicate( struct hw_data * pHwData, PDESCRIPTOR pDes ); 45 53 u8 hal_get_antenna_number( struct hw_data * pHwData ); 46 54 u32 hal_get_bss_pk_cnt( struct hw_data * pHwData ); 47 55 #define hal_get_region_from_EEPROM( _A ) ( (_A)->reg.EEPROMRegion ) 48 - void hal_set_accept_promiscuous ( struct hw_data * pHwData, u8 enable); 49 56 #define hal_get_tx_buffer( _A, _B ) Wb35Tx_get_tx_buffer( _A, _B ) 50 - u8 hal_get_hw_radio_off ( struct hw_data * pHwData ); 51 57 #define hal_software_set( _A ) (_A->SoftwareSet) 52 58 #define hal_driver_init_OK( _A ) (_A->IsInitOK) 53 59 #define hal_rssi_boundary_high( _A ) (_A->RSSI_high) ··· 67 79 #define hal_get_clear_interrupt(_A) 68 80 #define hal_ibss_disconnect(_A) hal_stop_sync_bss(_A) 69 81 #define hal_join_request_stop(_A) 70 - unsigned char hal_idle( struct hw_data * pHwData ); 71 82 #define hw_get_cxx_reg( _A, _B, _C ) 72 83 #define hw_set_cxx_reg( _A, _B, _C ) 73 84 #define hw_get_dxx_reg( _A, _B, _C ) hal_get_dxx_reg( _A, _B, (u32 *)_C )
+202
drivers/staging/winbond/wbusb.c
··· 120 120 return 0; 121 121 } 122 122 123 + static void hal_set_radio_mode(struct hw_data *pHwData, unsigned char radio_off) 124 + { 125 + struct wb35_reg *reg = &pHwData->reg; 126 + 127 + if (pHwData->SurpriseRemove) 128 + return; 129 + 130 + if (radio_off) //disable Baseband receive off 131 + { 132 + pHwData->CurrentRadioSw = 1; // off 133 + reg->M24_MacControl &= 0xffffffbf; 134 + } else { 135 + pHwData->CurrentRadioSw = 0; // on 136 + reg->M24_MacControl |= 0x00000040; 137 + } 138 + Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl); 139 + } 140 + 141 + static void hal_set_beacon_period(struct hw_data *pHwData, u16 beacon_period) 142 + { 143 + u32 tmp; 144 + 145 + if (pHwData->SurpriseRemove) 146 + return; 147 + 148 + pHwData->BeaconPeriod = beacon_period; 149 + tmp = pHwData->BeaconPeriod << 16; 150 + tmp |= pHwData->ProbeDelay; 151 + Wb35Reg_Write(pHwData, 0x0848, tmp); 152 + } 153 + 154 + static void 155 + hal_set_current_channel_ex(struct hw_data *pHwData, ChanInfo channel) 156 + { 157 + struct wb35_reg *reg = &pHwData->reg; 158 + 159 + if (pHwData->SurpriseRemove) 160 + return; 161 + 162 + printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo); 163 + 164 + RFSynthesizer_SwitchingChannel(pHwData, channel); // Switch channel 165 + pHwData->Channel = channel.ChanNo; 166 + pHwData->band = channel.band; 167 + #ifdef _PE_STATE_DUMP_ 168 + printk("Set channel is %d, band =%d\n", pHwData->Channel, 169 + pHwData->band); 170 + #endif 171 + reg->M28_MacControl &= ~0xff; // Clean channel information field 172 + reg->M28_MacControl |= channel.ChanNo; 173 + Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl, 174 + (s8 *) & channel, sizeof(ChanInfo)); 175 + } 176 + 177 + static void hal_set_current_channel(struct hw_data *pHwData, ChanInfo channel) 178 + { 179 + hal_set_current_channel_ex(pHwData, channel); 180 + } 181 + 182 + static void hal_set_accept_broadcast(struct hw_data *pHwData, u8 enable) 183 + { 184 + struct wb35_reg *reg = &pHwData->reg; 185 + 186 + if (pHwData->SurpriseRemove) 187 + return; 188 + 189 + reg->M00_MacControl &= ~0x02000000; //The HW value 190 + 191 + if (enable) 192 + reg->M00_MacControl |= 0x02000000; //The HW value 193 + 194 + Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 195 + } 196 + 197 + //for wep key error detection, we need to accept broadcast packets to be received temporary. 198 + static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable) 199 + { 200 + struct wb35_reg *reg = &pHwData->reg; 201 + 202 + if (pHwData->SurpriseRemove) 203 + return; 204 + if (enable) { 205 + reg->M00_MacControl |= 0x00400000; 206 + Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 207 + } else { 208 + reg->M00_MacControl &= ~0x00400000; 209 + Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 210 + } 211 + } 212 + 213 + static void hal_set_accept_multicast(struct hw_data *pHwData, u8 enable) 214 + { 215 + struct wb35_reg *reg = &pHwData->reg; 216 + 217 + if (pHwData->SurpriseRemove) 218 + return; 219 + 220 + reg->M00_MacControl &= ~0x01000000; //The HW value 221 + if (enable) 222 + reg->M00_MacControl |= 0x01000000; //The HW value 223 + Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 224 + } 225 + 226 + static void hal_set_accept_beacon(struct hw_data *pHwData, u8 enable) 227 + { 228 + struct wb35_reg *reg = &pHwData->reg; 229 + 230 + if (pHwData->SurpriseRemove) 231 + return; 232 + 233 + // 20040108 debug 234 + if (!enable) //Due to SME and MLME are not suitable for 35 235 + return; 236 + 237 + reg->M00_MacControl &= ~0x04000000; //The HW value 238 + if (enable) 239 + reg->M00_MacControl |= 0x04000000; //The HW value 240 + 241 + Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); 242 + } 243 + 123 244 static int wbsoft_config(struct ieee80211_hw *dev, u32 changed) 124 245 { 125 246 struct wbsoft_priv *priv = dev->priv; ··· 291 170 .get_tx_stats = wbsoft_get_tx_stats, 292 171 .get_tsf = wbsoft_get_tsf, 293 172 }; 173 + 174 + static void 175 + hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address) 176 + { 177 + u32 ltmp[2]; 178 + 179 + if (pHwData->SurpriseRemove) 180 + return; 181 + 182 + memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN); 183 + 184 + ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress); 185 + ltmp[1] = 186 + cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff; 187 + 188 + Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT); 189 + } 190 + 191 + static void 192 + hal_get_permanent_address(struct hw_data *pHwData, u8 * pethernet_address) 193 + { 194 + if (pHwData->SurpriseRemove) 195 + return; 196 + 197 + memcpy(pethernet_address, pHwData->PermanentMacAddress, 6); 198 + } 199 + 200 + static void hal_stop(struct hw_data *pHwData) 201 + { 202 + struct wb35_reg *reg = &pHwData->reg; 203 + 204 + pHwData->Wb35Rx.rx_halt = 1; 205 + Wb35Rx_stop(pHwData); 206 + 207 + pHwData->Wb35Tx.tx_halt = 1; 208 + Wb35Tx_stop(pHwData); 209 + 210 + reg->D00_DmaControl &= ~0xc0000000; //Tx Off, Rx Off 211 + Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl); 212 + } 213 + 214 + static unsigned char hal_idle(struct hw_data *pHwData) 215 + { 216 + struct wb35_reg *reg = &pHwData->reg; 217 + struct wb_usb *pWbUsb = &pHwData->WbUsb; 218 + 219 + if (!pHwData->SurpriseRemove 220 + && (pWbUsb->DetectCount || reg->EP0vm_state != VM_STOP)) 221 + return false; 222 + 223 + return true; 224 + } 225 + 226 + u8 hal_get_antenna_number(struct hw_data *pHwData) 227 + { 228 + struct wb35_reg *reg = &pHwData->reg; 229 + 230 + if ((reg->BB2C & BIT(11)) == 0) 231 + return 0; 232 + else 233 + return 1; 234 + } 235 + 236 + /* 0 : radio on; 1: radio off */ 237 + static u8 hal_get_hw_radio_off(struct hw_data * pHwData) 238 + { 239 + struct wb35_reg *reg = &pHwData->reg; 240 + 241 + if (pHwData->SurpriseRemove) 242 + return 1; 243 + 244 + //read the bit16 of register U1B0 245 + Wb35Reg_Read(pHwData, 0x3b0, &reg->U1B0); 246 + if ((reg->U1B0 & 0x00010000)) { 247 + pHwData->CurrentRadioHw = 1; 248 + return 1; 249 + } else { 250 + pHwData->CurrentRadioHw = 0; 251 + return 0; 252 + } 253 + } 294 254 295 255 static u8 LED_GRAY[20] = { 296 256 0, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 8, 6, 4, 2