aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/airo.c16
-rw-r--r--drivers/net/wireless/arlan-proc.c4
-rw-r--r--drivers/net/wireless/atmel.c1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h7
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c12
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c11
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c36
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.h16
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c2
-rw-r--r--drivers/net/wireless/ipw2200.c4
-rw-r--r--drivers/net/wireless/orinoco.c6
-rw-r--r--drivers/net/wireless/orinoco_cs.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c13
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.h4
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c3
-rw-r--r--drivers/net/wireless/spectrum_cs.c2
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c126
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h158
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.h2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_types.h71
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c128
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h6
27 files changed, 272 insertions, 366 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 44a22701da97..b08055abe83a 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4430,53 +4430,53 @@ static int proc_BSSList_open( struct inode *inode, struct file *file );
4430static int proc_config_open( struct inode *inode, struct file *file ); 4430static int proc_config_open( struct inode *inode, struct file *file );
4431static int proc_wepkey_open( struct inode *inode, struct file *file ); 4431static int proc_wepkey_open( struct inode *inode, struct file *file );
4432 4432
4433static struct file_operations proc_statsdelta_ops = { 4433static const struct file_operations proc_statsdelta_ops = {
4434 .read = proc_read, 4434 .read = proc_read,
4435 .open = proc_statsdelta_open, 4435 .open = proc_statsdelta_open,
4436 .release = proc_close 4436 .release = proc_close
4437}; 4437};
4438 4438
4439static struct file_operations proc_stats_ops = { 4439static const struct file_operations proc_stats_ops = {
4440 .read = proc_read, 4440 .read = proc_read,
4441 .open = proc_stats_open, 4441 .open = proc_stats_open,
4442 .release = proc_close 4442 .release = proc_close
4443}; 4443};
4444 4444
4445static struct file_operations proc_status_ops = { 4445static const struct file_operations proc_status_ops = {
4446 .read = proc_read, 4446 .read = proc_read,
4447 .open = proc_status_open, 4447 .open = proc_status_open,
4448 .release = proc_close 4448 .release = proc_close
4449}; 4449};
4450 4450
4451static struct file_operations proc_SSID_ops = { 4451static const struct file_operations proc_SSID_ops = {
4452 .read = proc_read, 4452 .read = proc_read,
4453 .write = proc_write, 4453 .write = proc_write,
4454 .open = proc_SSID_open, 4454 .open = proc_SSID_open,
4455 .release = proc_close 4455 .release = proc_close
4456}; 4456};
4457 4457
4458static struct file_operations proc_BSSList_ops = { 4458static const struct file_operations proc_BSSList_ops = {
4459 .read = proc_read, 4459 .read = proc_read,
4460 .write = proc_write, 4460 .write = proc_write,
4461 .open = proc_BSSList_open, 4461 .open = proc_BSSList_open,
4462 .release = proc_close 4462 .release = proc_close
4463}; 4463};
4464 4464
4465static struct file_operations proc_APList_ops = { 4465static const struct file_operations proc_APList_ops = {
4466 .read = proc_read, 4466 .read = proc_read,
4467 .write = proc_write, 4467 .write = proc_write,
4468 .open = proc_APList_open, 4468 .open = proc_APList_open,
4469 .release = proc_close 4469 .release = proc_close
4470}; 4470};
4471 4471
4472static struct file_operations proc_config_ops = { 4472static const struct file_operations proc_config_ops = {
4473 .read = proc_read, 4473 .read = proc_read,
4474 .write = proc_write, 4474 .write = proc_write,
4475 .open = proc_config_open, 4475 .open = proc_config_open,
4476 .release = proc_close 4476 .release = proc_close
4477}; 4477};
4478 4478
4479static struct file_operations proc_wepkey_ops = { 4479static const struct file_operations proc_wepkey_ops = {
4480 .read = proc_read, 4480 .read = proc_read,
4481 .write = proc_write, 4481 .write = proc_write,
4482 .open = proc_wepkey_open, 4482 .open = proc_wepkey_open,
diff --git a/drivers/net/wireless/arlan-proc.c b/drivers/net/wireless/arlan-proc.c
index 5fa985435ffa..015abd928ab0 100644
--- a/drivers/net/wireless/arlan-proc.c
+++ b/drivers/net/wireless/arlan-proc.c
@@ -1216,7 +1216,7 @@ static ctl_table arlan_table[MAX_ARLANS + 1] =
1216static ctl_table arlan_root_table[] = 1216static ctl_table arlan_root_table[] =
1217{ 1217{
1218 { 1218 {
1219 .ctl_name = 254, 1219 .ctl_name = CTL_ARLAN,
1220 .procname = "arlan", 1220 .procname = "arlan",
1221 .maxlen = 0, 1221 .maxlen = 0,
1222 .mode = 0555, 1222 .mode = 0555,
@@ -1244,7 +1244,7 @@ int __init init_arlan_proc(void)
1244 return 0; 1244 return 0;
1245 for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++) 1245 for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++)
1246 arlan_table[i].ctl_name = i + 1; 1246 arlan_table[i].ctl_name = i + 1;
1247 arlan_device_sysctl_header = register_sysctl_table(arlan_root_table, 0); 1247 arlan_device_sysctl_header = register_sysctl_table(arlan_root_table);
1248 if (!arlan_device_sysctl_header) 1248 if (!arlan_device_sysctl_header)
1249 return -1; 1249 return -1;
1250 1250
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 10bcb48e80d0..23eba698aec5 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -42,7 +42,6 @@
42#include <linux/init.h> 42#include <linux/init.h>
43 43
44#include <linux/kernel.h> 44#include <linux/kernel.h>
45#include <linux/sched.h>
46#include <linux/ptrace.h> 45#include <linux/ptrace.h>
47#include <linux/slab.h> 46#include <linux/slab.h>
48#include <linux/string.h> 47#include <linux/string.h>
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 8286678513b9..3a064def162e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -352,6 +352,10 @@
352#define BCM43xx_UCODEFLAG_UNKPACTRL 0x0040 352#define BCM43xx_UCODEFLAG_UNKPACTRL 0x0040
353#define BCM43xx_UCODEFLAG_JAPAN 0x0080 353#define BCM43xx_UCODEFLAG_JAPAN 0x0080
354 354
355/* Hardware Radio Enable masks */
356#define BCM43xx_MMIO_RADIO_HWENABLED_HI_MASK (1 << 16)
357#define BCM43xx_MMIO_RADIO_HWENABLED_LO_MASK (1 << 4)
358
355/* Generic-Interrupt reasons. */ 359/* Generic-Interrupt reasons. */
356#define BCM43xx_IRQ_READY (1 << 0) 360#define BCM43xx_IRQ_READY (1 << 0)
357#define BCM43xx_IRQ_BEACON (1 << 1) 361#define BCM43xx_IRQ_BEACON (1 << 1)
@@ -758,7 +762,8 @@ struct bcm43xx_private {
758 bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */ 762 bad_frames_preempt:1, /* Use "Bad Frames Preemption" (default off) */
759 reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */ 763 reg124_set_0x4:1, /* Some variable to keep track of IRQ stuff. */
760 short_preamble:1, /* TRUE, if short preamble is enabled. */ 764 short_preamble:1, /* TRUE, if short preamble is enabled. */
761 firmware_norelease:1; /* Do not release the firmware. Used on suspend. */ 765 firmware_norelease:1, /* Do not release the firmware. Used on suspend. */
766 radio_hw_enable:1; /* TRUE if radio is hardware enabled */
762 767
763 struct bcm43xx_stats stats; 768 struct bcm43xx_stats stats;
764 769
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
index b9df06a06ea9..35dbe4554513 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
@@ -355,37 +355,37 @@ out_up:
355#undef fappend 355#undef fappend
356 356
357 357
358static struct file_operations devinfo_fops = { 358static const struct file_operations devinfo_fops = {
359 .read = devinfo_read_file, 359 .read = devinfo_read_file,
360 .write = write_file_dummy, 360 .write = write_file_dummy,
361 .open = open_file_generic, 361 .open = open_file_generic,
362}; 362};
363 363
364static struct file_operations spromdump_fops = { 364static const struct file_operations spromdump_fops = {
365 .read = spromdump_read_file, 365 .read = spromdump_read_file,
366 .write = write_file_dummy, 366 .write = write_file_dummy,
367 .open = open_file_generic, 367 .open = open_file_generic,
368}; 368};
369 369
370static struct file_operations drvinfo_fops = { 370static const struct file_operations drvinfo_fops = {
371 .read = drvinfo_read_file, 371 .read = drvinfo_read_file,
372 .write = write_file_dummy, 372 .write = write_file_dummy,
373 .open = open_file_generic, 373 .open = open_file_generic,
374}; 374};
375 375
376static struct file_operations tsf_fops = { 376static const struct file_operations tsf_fops = {
377 .read = tsf_read_file, 377 .read = tsf_read_file,
378 .write = tsf_write_file, 378 .write = tsf_write_file,
379 .open = open_file_generic, 379 .open = open_file_generic,
380}; 380};
381 381
382static struct file_operations txstat_fops = { 382static const struct file_operations txstat_fops = {
383 .read = txstat_read_file, 383 .read = txstat_read_file,
384 .write = write_file_dummy, 384 .write = write_file_dummy,
385 .open = open_file_generic, 385 .open = open_file_generic,
386}; 386};
387 387
388static struct file_operations restart_fops = { 388static const struct file_operations restart_fops = {
389 .write = restart_write_file, 389 .write = restart_write_file,
390 .open = open_file_generic, 390 .open = open_file_generic,
391}; 391};
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index 7d383a27b927..8f198befba39 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -26,6 +26,7 @@
26*/ 26*/
27 27
28#include "bcm43xx_leds.h" 28#include "bcm43xx_leds.h"
29#include "bcm43xx_radio.h"
29#include "bcm43xx.h" 30#include "bcm43xx.h"
30 31
31#include <asm/bitops.h> 32#include <asm/bitops.h>
@@ -108,6 +109,7 @@ static void bcm43xx_led_init_hardcoded(struct bcm43xx_private *bcm,
108 switch (led_index) { 109 switch (led_index) {
109 case 0: 110 case 0:
110 led->behaviour = BCM43xx_LED_ACTIVITY; 111 led->behaviour = BCM43xx_LED_ACTIVITY;
112 led->activelow = 1;
111 if (bcm->board_vendor == PCI_VENDOR_ID_COMPAQ) 113 if (bcm->board_vendor == PCI_VENDOR_ID_COMPAQ)
112 led->behaviour = BCM43xx_LED_RADIO_ALL; 114 led->behaviour = BCM43xx_LED_RADIO_ALL;
113 break; 115 break;
@@ -199,20 +201,21 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
199 turn_on = activity; 201 turn_on = activity;
200 break; 202 break;
201 case BCM43xx_LED_RADIO_ALL: 203 case BCM43xx_LED_RADIO_ALL:
202 turn_on = radio->enabled; 204 turn_on = radio->enabled && bcm43xx_is_hw_radio_enabled(bcm);
203 break; 205 break;
204 case BCM43xx_LED_RADIO_A: 206 case BCM43xx_LED_RADIO_A:
205 case BCM43xx_LED_BCM4303_2: 207 case BCM43xx_LED_BCM4303_2:
206 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A); 208 turn_on = (radio->enabled && bcm43xx_is_hw_radio_enabled(bcm) &&
209 phy->type == BCM43xx_PHYTYPE_A);
207 break; 210 break;
208 case BCM43xx_LED_RADIO_B: 211 case BCM43xx_LED_RADIO_B:
209 case BCM43xx_LED_BCM4303_1: 212 case BCM43xx_LED_BCM4303_1:
210 turn_on = (radio->enabled && 213 turn_on = (radio->enabled && bcm43xx_is_hw_radio_enabled(bcm) &&
211 (phy->type == BCM43xx_PHYTYPE_B || 214 (phy->type == BCM43xx_PHYTYPE_B ||
212 phy->type == BCM43xx_PHYTYPE_G)); 215 phy->type == BCM43xx_PHYTYPE_G));
213 break; 216 break;
214 case BCM43xx_LED_MODE_BG: 217 case BCM43xx_LED_MODE_BG:
215 if (phy->type == BCM43xx_PHYTYPE_G && 218 if (phy->type == BCM43xx_PHYTYPE_G && bcm43xx_is_hw_radio_enabled(bcm) &&
216 1/*FIXME: using G rates.*/) 219 1/*FIXME: using G rates.*/)
217 turn_on = 1; 220 turn_on = 1;
218 break; 221 break;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 91b752e3d07e..23aaf1ed8541 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -2441,6 +2441,9 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
2441 if (err) 2441 if (err)
2442 goto err_gpio_cleanup; 2442 goto err_gpio_cleanup;
2443 bcm43xx_radio_turn_on(bcm); 2443 bcm43xx_radio_turn_on(bcm);
2444 bcm->radio_hw_enable = bcm43xx_is_hw_radio_enabled(bcm);
2445 dprintk(KERN_INFO PFX "Radio %s by hardware\n",
2446 (bcm->radio_hw_enable == 0) ? "disabled" : "enabled");
2444 2447
2445 bcm43xx_write16(bcm, 0x03E6, 0x0000); 2448 bcm43xx_write16(bcm, 0x03E6, 0x0000);
2446 err = bcm43xx_phy_init(bcm); 2449 err = bcm43xx_phy_init(bcm);
@@ -3175,9 +3178,24 @@ static void bcm43xx_periodic_every30sec(struct bcm43xx_private *bcm)
3175 3178
3176static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm) 3179static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
3177{ 3180{
3181 bcm43xx_phy_xmitpower(bcm); //FIXME: unless scanning?
3182 //TODO for APHY (temperature?)
3183}
3184
3185static void bcm43xx_periodic_every1sec(struct bcm43xx_private *bcm)
3186{
3178 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); 3187 struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
3179 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); 3188 struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
3189 int radio_hw_enable;
3180 3190
3191 /* check if radio hardware enabled status changed */
3192 radio_hw_enable = bcm43xx_is_hw_radio_enabled(bcm);
3193 if (unlikely(bcm->radio_hw_enable != radio_hw_enable)) {
3194 bcm->radio_hw_enable = radio_hw_enable;
3195 dprintk(KERN_INFO PFX "Radio hardware status changed to %s\n",
3196 (radio_hw_enable == 0) ? "disabled" : "enabled");
3197 bcm43xx_leds_update(bcm, 0);
3198 }
3181 if (phy->type == BCM43xx_PHYTYPE_G) { 3199 if (phy->type == BCM43xx_PHYTYPE_G) {
3182 //TODO: update_aci_moving_average 3200 //TODO: update_aci_moving_average
3183 if (radio->aci_enable && radio->aci_wlan_automatic) { 3201 if (radio->aci_enable && radio->aci_wlan_automatic) {
@@ -3201,21 +3219,21 @@ static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
3201 //TODO: implement rev1 workaround 3219 //TODO: implement rev1 workaround
3202 } 3220 }
3203 } 3221 }
3204 bcm43xx_phy_xmitpower(bcm); //FIXME: unless scanning?
3205 //TODO for APHY (temperature?)
3206} 3222}
3207 3223
3208static void do_periodic_work(struct bcm43xx_private *bcm) 3224static void do_periodic_work(struct bcm43xx_private *bcm)
3209{ 3225{
3210 if (bcm->periodic_state % 8 == 0) 3226 if (bcm->periodic_state % 120 == 0)
3211 bcm43xx_periodic_every120sec(bcm); 3227 bcm43xx_periodic_every120sec(bcm);
3212 if (bcm->periodic_state % 4 == 0) 3228 if (bcm->periodic_state % 60 == 0)
3213 bcm43xx_periodic_every60sec(bcm); 3229 bcm43xx_periodic_every60sec(bcm);
3214 if (bcm->periodic_state % 2 == 0) 3230 if (bcm->periodic_state % 30 == 0)
3215 bcm43xx_periodic_every30sec(bcm); 3231 bcm43xx_periodic_every30sec(bcm);
3216 bcm43xx_periodic_every15sec(bcm); 3232 if (bcm->periodic_state % 15 == 0)
3233 bcm43xx_periodic_every15sec(bcm);
3234 bcm43xx_periodic_every1sec(bcm);
3217 3235
3218 schedule_delayed_work(&bcm->periodic_work, HZ * 15); 3236 schedule_delayed_work(&bcm->periodic_work, HZ);
3219} 3237}
3220 3238
3221static void bcm43xx_periodic_work_handler(struct work_struct *work) 3239static void bcm43xx_periodic_work_handler(struct work_struct *work)
@@ -3228,7 +3246,7 @@ static void bcm43xx_periodic_work_handler(struct work_struct *work)
3228 unsigned long orig_trans_start = 0; 3246 unsigned long orig_trans_start = 0;
3229 3247
3230 mutex_lock(&bcm->mutex); 3248 mutex_lock(&bcm->mutex);
3231 if (unlikely(bcm->periodic_state % 4 == 0)) { 3249 if (unlikely(bcm->periodic_state % 60 == 0)) {
3232 /* Periodic work will take a long time, so we want it to 3250 /* Periodic work will take a long time, so we want it to
3233 * be preemtible. 3251 * be preemtible.
3234 */ 3252 */
@@ -3260,7 +3278,7 @@ static void bcm43xx_periodic_work_handler(struct work_struct *work)
3260 3278
3261 do_periodic_work(bcm); 3279 do_periodic_work(bcm);
3262 3280
3263 if (unlikely(bcm->periodic_state % 4 == 0)) { 3281 if (unlikely(bcm->periodic_state % 60 == 0)) {
3264 spin_lock_irqsave(&bcm->irq_lock, flags); 3282 spin_lock_irqsave(&bcm->irq_lock, flags);
3265 tasklet_enable(&bcm->isr_tasklet); 3283 tasklet_enable(&bcm->isr_tasklet);
3266 bcm43xx_interrupt_enable(bcm, savedirqs); 3284 bcm43xx_interrupt_enable(bcm, savedirqs);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index bb9c484d7e19..af19a07032a3 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -1981,6 +1981,7 @@ void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm)
1981 } 1981 }
1982 radio->enabled = 1; 1982 radio->enabled = 1;
1983 dprintk(KERN_INFO PFX "Radio turned on\n"); 1983 dprintk(KERN_INFO PFX "Radio turned on\n");
1984 bcm43xx_leds_update(bcm, 0);
1984} 1985}
1985 1986
1986void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm) 1987void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm)
@@ -2001,6 +2002,7 @@ void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm)
2001 bcm43xx_phy_write(bcm, 0x0015, 0xAA00); 2002 bcm43xx_phy_write(bcm, 0x0015, 0xAA00);
2002 radio->enabled = 0; 2003 radio->enabled = 0;
2003 dprintk(KERN_INFO PFX "Radio turned off\n"); 2004 dprintk(KERN_INFO PFX "Radio turned off\n");
2005 bcm43xx_leds_update(bcm, 0);
2004} 2006}
2005 2007
2006void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm) 2008void bcm43xx_radio_clear_tssi(struct bcm43xx_private *bcm)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.h b/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
index 9ed18039fa3e..77a98a53a2e2 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.h
@@ -65,6 +65,22 @@ void bcm43xx_radio_init2060(struct bcm43xx_private *bcm);
65void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm); 65void bcm43xx_radio_turn_on(struct bcm43xx_private *bcm);
66void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm); 66void bcm43xx_radio_turn_off(struct bcm43xx_private *bcm);
67 67
68static inline
69int bcm43xx_is_hw_radio_enabled(struct bcm43xx_private *bcm)
70{
71 /* function to return state of hardware enable of radio
72 * returns 0 if radio disabled, 1 if radio enabled
73 */
74 if (bcm->current_core->rev >= 3)
75 return ((bcm43xx_read32(bcm, BCM43xx_MMIO_RADIO_HWENABLED_HI)
76 & BCM43xx_MMIO_RADIO_HWENABLED_HI_MASK)
77 == 0) ? 1 : 0;
78 else
79 return ((bcm43xx_read16(bcm, BCM43xx_MMIO_RADIO_HWENABLED_LO)
80 & BCM43xx_MMIO_RADIO_HWENABLED_LO_MASK)
81 == 0) ? 0 : 1;
82}
83
68int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm, u8 channel, 84int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm, u8 channel,
69 int synthetic_pu_workaround); 85 int synthetic_pu_workaround);
70 86
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index a659442b9c15..d2ca949174fe 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -33,7 +33,6 @@
33#include <net/ieee80211softmac.h> 33#include <net/ieee80211softmac.h>
34#include <net/ieee80211softmac_wx.h> 34#include <net/ieee80211softmac_wx.h>
35#include <linux/capability.h> 35#include <linux/capability.h>
36#include <linux/sched.h> /* for capable() */
37#include <linux/delay.h> 36#include <linux/delay.h>
38 37
39#include "bcm43xx.h" 38#include "bcm43xx.h"
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 04c19cefa1da..9077e6edde34 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -84,7 +84,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
84 if (strchr(dev->name, '%')) 84 if (strchr(dev->name, '%'))
85 ret = dev_alloc_name(dev, dev->name); 85 ret = dev_alloc_name(dev, dev->name);
86 86
87 SET_NETDEV_DEV(dev, mdev->class_dev.dev); 87 SET_NETDEV_DEV(dev, mdev->dev.parent);
88 if (ret >= 0) 88 if (ret >= 0)
89 ret = register_netdevice(dev); 89 ret = register_netdevice(dev);
90 90
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 22cb3fb7502e..c878a2f3239c 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -9166,7 +9166,7 @@ static int ipw_wx_set_rts(struct net_device *dev,
9166{ 9166{
9167 struct ipw_priv *priv = ieee80211_priv(dev); 9167 struct ipw_priv *priv = ieee80211_priv(dev);
9168 mutex_lock(&priv->mutex); 9168 mutex_lock(&priv->mutex);
9169 if (wrqu->rts.disabled) 9169 if (wrqu->rts.disabled || !wrqu->rts.fixed)
9170 priv->rts_threshold = DEFAULT_RTS_THRESHOLD; 9170 priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
9171 else { 9171 else {
9172 if (wrqu->rts.value < MIN_RTS_THRESHOLD || 9172 if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
@@ -9255,7 +9255,7 @@ static int ipw_wx_set_frag(struct net_device *dev,
9255{ 9255{
9256 struct ipw_priv *priv = ieee80211_priv(dev); 9256 struct ipw_priv *priv = ieee80211_priv(dev);
9257 mutex_lock(&priv->mutex); 9257 mutex_lock(&priv->mutex);
9258 if (wrqu->frag.disabled) 9258 if (wrqu->frag.disabled || !wrqu->frag.fixed)
9259 priv->ieee->fts = DEFAULT_FTS; 9259 priv->ieee->fts = DEFAULT_FTS;
9260 else { 9260 else {
9261 if (wrqu->frag.value < MIN_FRAG_THRESHOLD || 9261 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 936c888e03e1..4e7f6cf51436 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -2059,7 +2059,7 @@ static int determine_firmware(struct net_device *dev)
2059 int err; 2059 int err;
2060 struct comp_id nic_id, sta_id; 2060 struct comp_id nic_id, sta_id;
2061 unsigned int firmver; 2061 unsigned int firmver;
2062 char tmp[SYMBOL_MAX_VER_LEN+1]; 2062 char tmp[SYMBOL_MAX_VER_LEN+1] __attribute__((aligned(2)));
2063 2063
2064 /* Get the hardware version */ 2064 /* Get the hardware version */
2065 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); 2065 err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
@@ -4293,8 +4293,8 @@ static void orinoco_get_drvinfo(struct net_device *dev,
4293 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); 4293 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
4294 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); 4294 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
4295 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1); 4295 strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
4296 if (dev->class_dev.dev) 4296 if (dev->dev.parent)
4297 strncpy(info->bus_info, dev->class_dev.dev->bus_id, 4297 strncpy(info->bus_info, dev->dev.parent->bus_id,
4298 sizeof(info->bus_info) - 1); 4298 sizeof(info->bus_info) - 1);
4299 else 4299 else
4300 snprintf(info->bus_info, sizeof(info->bus_info) - 1, 4300 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index d08ae8d2726c..d1e502236b2a 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -332,7 +332,7 @@ orinoco_cs_config(struct pcmcia_device *link)
332 332
333 /* Finally, report what we've done */ 333 /* Finally, report what we've done */
334 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 334 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
335 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, 335 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
336 link->irq.AssignedIRQ, link->io.BasePort1, 336 link->irq.AssignedIRQ, link->io.BasePort1,
337 link->io.BasePort1 + link->io.NumPorts1 - 1); 337 link->io.BasePort1 + link->io.NumPorts1 - 1);
338 338
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index f057fd9fcd79..a037b11dac9d 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22 22
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/ethtool.h>
24#include <linux/pci.h> 25#include <linux/pci.h>
25#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
@@ -787,6 +788,17 @@ islpci_set_multicast_list(struct net_device *dev)
787} 788}
788#endif 789#endif
789 790
791static void islpci_ethtool_get_drvinfo(struct net_device *dev,
792 struct ethtool_drvinfo *info)
793{
794 strcpy(info->driver, DRV_NAME);
795 strcpy(info->version, DRV_VERSION);
796}
797
798static struct ethtool_ops islpci_ethtool_ops = {
799 .get_drvinfo = islpci_ethtool_get_drvinfo,
800};
801
790struct net_device * 802struct net_device *
791islpci_setup(struct pci_dev *pdev) 803islpci_setup(struct pci_dev *pdev)
792{ 804{
@@ -813,6 +825,7 @@ islpci_setup(struct pci_dev *pdev)
813 ndev->do_ioctl = &prism54_ioctl; 825 ndev->do_ioctl = &prism54_ioctl;
814 ndev->wireless_handlers = 826 ndev->wireless_handlers =
815 (struct iw_handler_def *) &prism54_handler_def; 827 (struct iw_handler_def *) &prism54_handler_def;
828 ndev->ethtool_ops = &islpci_ethtool_ops;
816 829
817 ndev->hard_start_xmit = &islpci_eth_transmit; 830 ndev->hard_start_xmit = &islpci_eth_transmit;
818 /* ndev->set_multicast_list = &islpci_set_multicast_list; */ 831 /* ndev->set_multicast_list = &islpci_set_multicast_list; */
diff --git a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h
index a9aa1662eaa4..736666da6c24 100644
--- a/drivers/net/wireless/prism54/islpci_dev.h
+++ b/drivers/net/wireless/prism54/islpci_dev.h
@@ -211,4 +211,8 @@ islpci_trigger(islpci_private *priv)
211 211
212int islpci_free_memory(islpci_private *); 212int islpci_free_memory(islpci_private *);
213struct net_device *islpci_setup(struct pci_dev *); 213struct net_device *islpci_setup(struct pci_dev *);
214
215#define DRV_NAME "prism54"
216#define DRV_VERSION "1.2"
217
214#endif /* _ISLPCI_DEV_H */ 218#endif /* _ISLPCI_DEV_H */
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index 58257b40c043..3dcb13bb7d57 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -28,9 +28,6 @@
28#include "islpci_mgt.h" /* for pc_debug */ 28#include "islpci_mgt.h" /* for pc_debug */
29#include "isl_oid.h" 29#include "isl_oid.h"
30 30
31#define DRV_NAME "prism54"
32#define DRV_VERSION "1.2"
33
34MODULE_AUTHOR("[Intersil] R.Bastings and W.Termorshuizen, The prism54.org Development Team <prism54-devel@prism54.org>"); 31MODULE_AUTHOR("[Intersil] R.Bastings and W.Termorshuizen, The prism54.org Development Team <prism54-devel@prism54.org>");
35MODULE_DESCRIPTION("The Prism54 802.11 Wireless LAN adapter"); 32MODULE_DESCRIPTION("The Prism54 802.11 Wireless LAN adapter");
36MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index cf2d1486b01d..af70460f008a 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -806,7 +806,7 @@ spectrum_cs_config(struct pcmcia_device *link)
806 806
807 /* Finally, report what we've done */ 807 /* Finally, report what we've done */
808 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 808 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
809 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, 809 "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
810 link->irq.AssignedIRQ, link->io.BasePort1, 810 link->irq.AssignedIRQ, link->io.BasePort1,
811 link->io.BasePort1 + link->io.NumPorts1 - 1); 811 link->io.BasePort1 + link->io.NumPorts1 - 1);
812 812
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index ce3a8bac66ff..f5ce1c6063d8 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -1160,7 +1160,7 @@ static int strip_seq_open(struct inode *inode, struct file *file)
1160 return seq_open(file, &strip_seq_ops); 1160 return seq_open(file, &strip_seq_ops);
1161} 1161}
1162 1162
1163static struct file_operations strip_seq_fops = { 1163static const struct file_operations strip_seq_fops = {
1164 .owner = THIS_MODULE, 1164 .owner = THIS_MODULE,
1165 .open = strip_seq_open, 1165 .open = strip_seq_open,
1166 .read = seq_read, 1166 .read = seq_read,
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 78ea72fb8f0c..12dfc0b6efe6 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -84,6 +84,18 @@ static void print_id(struct zd_chip *chip)
84 dev_info(zd_chip_dev(chip), "%s\n", buffer); 84 dev_info(zd_chip_dev(chip), "%s\n", buffer);
85} 85}
86 86
87static zd_addr_t inc_addr(zd_addr_t addr)
88{
89 u16 a = (u16)addr;
90 /* Control registers use byte addressing, but everything else uses word
91 * addressing. */
92 if ((a & 0xf000) == CR_START)
93 a += 2;
94 else
95 a += 1;
96 return (zd_addr_t)a;
97}
98
87/* Read a variable number of 32-bit values. Parameter count is not allowed to 99/* Read a variable number of 32-bit values. Parameter count is not allowed to
88 * exceed USB_MAX_IOREAD32_COUNT. 100 * exceed USB_MAX_IOREAD32_COUNT.
89 */ 101 */
@@ -114,7 +126,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
114 for (i = 0; i < count; i++) { 126 for (i = 0; i < count; i++) {
115 int j = 2*i; 127 int j = 2*i;
116 /* We read the high word always first. */ 128 /* We read the high word always first. */
117 a16[j] = zd_inc_word(addr[i]); 129 a16[j] = inc_addr(addr[i]);
118 a16[j+1] = addr[i]; 130 a16[j+1] = addr[i];
119 } 131 }
120 132
@@ -163,7 +175,7 @@ int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
163 j = 2*i; 175 j = 2*i;
164 /* We write the high word always first. */ 176 /* We write the high word always first. */
165 ioreqs16[j].value = ioreqs[i].value >> 16; 177 ioreqs16[j].value = ioreqs[i].value >> 16;
166 ioreqs16[j].addr = zd_inc_word(ioreqs[i].addr); 178 ioreqs16[j].addr = inc_addr(ioreqs[i].addr);
167 ioreqs16[j+1].value = ioreqs[i].value; 179 ioreqs16[j+1].value = ioreqs[i].value;
168 ioreqs16[j+1].addr = ioreqs[i].addr; 180 ioreqs16[j+1].addr = ioreqs[i].addr;
169 } 181 }
@@ -466,7 +478,8 @@ static int read_values(struct zd_chip *chip, u8 *values, size_t count,
466 478
467 ZD_ASSERT(mutex_is_locked(&chip->mutex)); 479 ZD_ASSERT(mutex_is_locked(&chip->mutex));
468 for (i = 0;;) { 480 for (i = 0;;) {
469 r = zd_ioread32_locked(chip, &v, e2p_addr+i/2); 481 r = zd_ioread32_locked(chip, &v,
482 (zd_addr_t)((u16)e2p_addr+i/2));
470 if (r) 483 if (r)
471 return r; 484 return r;
472 v -= guard; 485 v -= guard;
@@ -798,47 +811,18 @@ static int hw_reset_phy(struct zd_chip *chip)
798static int zd1211_hw_init_hmac(struct zd_chip *chip) 811static int zd1211_hw_init_hmac(struct zd_chip *chip)
799{ 812{
800 static const struct zd_ioreq32 ioreqs[] = { 813 static const struct zd_ioreq32 ioreqs[] = {
801 { CR_ACK_TIMEOUT_EXT, 0x20 },
802 { CR_ADDA_MBIAS_WARMTIME, 0x30000808 },
803 { CR_ZD1211_RETRY_MAX, 0x2 }, 814 { CR_ZD1211_RETRY_MAX, 0x2 },
804 { CR_SNIFFER_ON, 0 },
805 { CR_RX_FILTER, STA_RX_FILTER },
806 { CR_GROUP_HASH_P1, 0x00 },
807 { CR_GROUP_HASH_P2, 0x80000000 },
808 { CR_REG1, 0xa4 },
809 { CR_ADDA_PWR_DWN, 0x7f },
810 { CR_BCN_PLCP_CFG, 0x00f00401 },
811 { CR_PHY_DELAY, 0x00 },
812 { CR_ACK_TIMEOUT_EXT, 0x80 },
813 { CR_ADDA_PWR_DWN, 0x00 },
814 { CR_ACK_TIME_80211, 0x100 },
815 { CR_RX_PE_DELAY, 0x70 },
816 { CR_PS_CTRL, 0x10000000 },
817 { CR_RTS_CTS_RATE, 0x02030203 },
818 { CR_RX_THRESHOLD, 0x000c0640 }, 815 { CR_RX_THRESHOLD, 0x000c0640 },
819 { CR_AFTER_PNP, 0x1 },
820 { CR_WEP_PROTECT, 0x114 },
821 }; 816 };
822 817
823 int r;
824
825 dev_dbg_f(zd_chip_dev(chip), "\n"); 818 dev_dbg_f(zd_chip_dev(chip), "\n");
826 ZD_ASSERT(mutex_is_locked(&chip->mutex)); 819 ZD_ASSERT(mutex_is_locked(&chip->mutex));
827 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 820 return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
828#ifdef DEBUG
829 if (r) {
830 dev_err(zd_chip_dev(chip),
831 "error in zd_iowrite32a_locked. Error number %d\n", r);
832 }
833#endif /* DEBUG */
834 return r;
835} 821}
836 822
837static int zd1211b_hw_init_hmac(struct zd_chip *chip) 823static int zd1211b_hw_init_hmac(struct zd_chip *chip)
838{ 824{
839 static const struct zd_ioreq32 ioreqs[] = { 825 static const struct zd_ioreq32 ioreqs[] = {
840 { CR_ACK_TIMEOUT_EXT, 0x20 },
841 { CR_ADDA_MBIAS_WARMTIME, 0x30000808 },
842 { CR_ZD1211B_RETRY_MAX, 0x02020202 }, 826 { CR_ZD1211B_RETRY_MAX, 0x02020202 },
843 { CR_ZD1211B_TX_PWR_CTL4, 0x007f003f }, 827 { CR_ZD1211B_TX_PWR_CTL4, 0x007f003f },
844 { CR_ZD1211B_TX_PWR_CTL3, 0x007f003f }, 828 { CR_ZD1211B_TX_PWR_CTL3, 0x007f003f },
@@ -847,6 +831,20 @@ static int zd1211b_hw_init_hmac(struct zd_chip *chip)
847 { CR_ZD1211B_AIFS_CTL1, 0x00280028 }, 831 { CR_ZD1211B_AIFS_CTL1, 0x00280028 },
848 { CR_ZD1211B_AIFS_CTL2, 0x008C003C }, 832 { CR_ZD1211B_AIFS_CTL2, 0x008C003C },
849 { CR_ZD1211B_TXOP, 0x01800824 }, 833 { CR_ZD1211B_TXOP, 0x01800824 },
834 { CR_RX_THRESHOLD, 0x000c0eff, },
835 };
836
837 dev_dbg_f(zd_chip_dev(chip), "\n");
838 ZD_ASSERT(mutex_is_locked(&chip->mutex));
839 return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
840}
841
842static int hw_init_hmac(struct zd_chip *chip)
843{
844 int r;
845 static const struct zd_ioreq32 ioreqs[] = {
846 { CR_ACK_TIMEOUT_EXT, 0x20 },
847 { CR_ADDA_MBIAS_WARMTIME, 0x30000808 },
850 { CR_SNIFFER_ON, 0 }, 848 { CR_SNIFFER_ON, 0 },
851 { CR_RX_FILTER, STA_RX_FILTER }, 849 { CR_RX_FILTER, STA_RX_FILTER },
852 { CR_GROUP_HASH_P1, 0x00 }, 850 { CR_GROUP_HASH_P1, 0x00 },
@@ -861,25 +859,16 @@ static int zd1211b_hw_init_hmac(struct zd_chip *chip)
861 { CR_RX_PE_DELAY, 0x70 }, 859 { CR_RX_PE_DELAY, 0x70 },
862 { CR_PS_CTRL, 0x10000000 }, 860 { CR_PS_CTRL, 0x10000000 },
863 { CR_RTS_CTS_RATE, 0x02030203 }, 861 { CR_RTS_CTS_RATE, 0x02030203 },
864 { CR_RX_THRESHOLD, 0x000c0eff, },
865 { CR_AFTER_PNP, 0x1 }, 862 { CR_AFTER_PNP, 0x1 },
866 { CR_WEP_PROTECT, 0x114 }, 863 { CR_WEP_PROTECT, 0x114 },
864 { CR_IFS_VALUE, IFS_VALUE_DEFAULT },
867 }; 865 };
868 866
869 int r;
870
871 dev_dbg_f(zd_chip_dev(chip), "\n");
872 ZD_ASSERT(mutex_is_locked(&chip->mutex)); 867 ZD_ASSERT(mutex_is_locked(&chip->mutex));
873 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 868 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
874 if (r) { 869 if (r)
875 dev_dbg_f(zd_chip_dev(chip), 870 return r;
876 "error in zd_iowrite32a_locked. Error number %d\n", r);
877 }
878 return r;
879}
880 871
881static int hw_init_hmac(struct zd_chip *chip)
882{
883 return chip->is_zd1211b ? 872 return chip->is_zd1211b ?
884 zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip); 873 zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip);
885} 874}
@@ -974,16 +963,14 @@ static int hw_init(struct zd_chip *chip)
974 if (r) 963 if (r)
975 return r; 964 return r;
976 965
977 /* Although the vendor driver defaults to a different value during
978 * init, it overwrites the IFS value with the following every time
979 * the channel changes. We should aim to be more intelligent... */
980 r = zd_iowrite32_locked(chip, IFS_VALUE_DEFAULT, CR_IFS_VALUE);
981 if (r)
982 return r;
983
984 return set_beacon_interval(chip, 100); 966 return set_beacon_interval(chip, 100);
985} 967}
986 968
969static zd_addr_t fw_reg_addr(struct zd_chip *chip, u16 offset)
970{
971 return (zd_addr_t)((u16)chip->fw_regs_base + offset);
972}
973
987#ifdef DEBUG 974#ifdef DEBUG
988static int dump_cr(struct zd_chip *chip, const zd_addr_t addr, 975static int dump_cr(struct zd_chip *chip, const zd_addr_t addr,
989 const char *addr_string) 976 const char *addr_string)
@@ -1018,9 +1005,11 @@ static int test_init(struct zd_chip *chip)
1018 1005
1019static void dump_fw_registers(struct zd_chip *chip) 1006static void dump_fw_registers(struct zd_chip *chip)
1020{ 1007{
1021 static const zd_addr_t addr[4] = { 1008 const zd_addr_t addr[4] = {
1022 FW_FIRMWARE_VER, FW_USB_SPEED, FW_FIX_TX_RATE, 1009 fw_reg_addr(chip, FW_REG_FIRMWARE_VER),
1023 FW_LINK_STATUS 1010 fw_reg_addr(chip, FW_REG_USB_SPEED),
1011 fw_reg_addr(chip, FW_REG_FIX_TX_RATE),
1012 fw_reg_addr(chip, FW_REG_LED_LINK_STATUS),
1024 }; 1013 };
1025 1014
1026 int r; 1015 int r;
@@ -1046,7 +1035,8 @@ static int print_fw_version(struct zd_chip *chip)
1046 int r; 1035 int r;
1047 u16 version; 1036 u16 version;
1048 1037
1049 r = zd_ioread16_locked(chip, &version, FW_FIRMWARE_VER); 1038 r = zd_ioread16_locked(chip, &version,
1039 fw_reg_addr(chip, FW_REG_FIRMWARE_VER));
1050 if (r) 1040 if (r)
1051 return r; 1041 return r;
1052 1042
@@ -1126,6 +1116,22 @@ int zd_chip_disable_hwint(struct zd_chip *chip)
1126 return r; 1116 return r;
1127} 1117}
1128 1118
1119static int read_fw_regs_offset(struct zd_chip *chip)
1120{
1121 int r;
1122
1123 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1124 r = zd_ioread16_locked(chip, (u16*)&chip->fw_regs_base,
1125 FWRAW_REGS_ADDR);
1126 if (r)
1127 return r;
1128 dev_dbg_f(zd_chip_dev(chip), "fw_regs_base: %#06hx\n",
1129 (u16)chip->fw_regs_base);
1130
1131 return 0;
1132}
1133
1134
1129int zd_chip_init_hw(struct zd_chip *chip, u8 device_type) 1135int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
1130{ 1136{
1131 int r; 1137 int r;
@@ -1145,7 +1151,7 @@ int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
1145 if (r) 1151 if (r)
1146 goto out; 1152 goto out;
1147 1153
1148 r = zd_usb_init_hw(&chip->usb); 1154 r = read_fw_regs_offset(chip);
1149 if (r) 1155 if (r)
1150 goto out; 1156 goto out;
1151 1157
@@ -1325,15 +1331,15 @@ u8 zd_chip_get_channel(struct zd_chip *chip)
1325 1331
1326int zd_chip_control_leds(struct zd_chip *chip, enum led_status status) 1332int zd_chip_control_leds(struct zd_chip *chip, enum led_status status)
1327{ 1333{
1328 static const zd_addr_t a[] = { 1334 const zd_addr_t a[] = {
1329 FW_LINK_STATUS, 1335 fw_reg_addr(chip, FW_REG_LED_LINK_STATUS),
1330 CR_LED, 1336 CR_LED,
1331 }; 1337 };
1332 1338
1333 int r; 1339 int r;
1334 u16 v[ARRAY_SIZE(a)]; 1340 u16 v[ARRAY_SIZE(a)];
1335 struct zd_ioreq16 ioreqs[ARRAY_SIZE(a)] = { 1341 struct zd_ioreq16 ioreqs[ARRAY_SIZE(a)] = {
1336 [0] = { FW_LINK_STATUS }, 1342 [0] = { fw_reg_addr(chip, FW_REG_LED_LINK_STATUS) },
1337 [1] = { CR_LED }, 1343 [1] = { CR_LED },
1338 }; 1344 };
1339 u16 other_led; 1345 u16 other_led;
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index a4e3cee9b59d..b07569e391ee 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -18,7 +18,6 @@
18#ifndef _ZD_CHIP_H 18#ifndef _ZD_CHIP_H
19#define _ZD_CHIP_H 19#define _ZD_CHIP_H
20 20
21#include "zd_types.h"
22#include "zd_rf.h" 21#include "zd_rf.h"
23#include "zd_usb.h" 22#include "zd_usb.h"
24 23
@@ -27,6 +26,37 @@
27 * adds a processor for handling the USB protocol. 26 * adds a processor for handling the USB protocol.
28 */ 27 */
29 28
29/* Address space */
30enum {
31 /* CONTROL REGISTERS */
32 CR_START = 0x9000,
33
34
35 /* FIRMWARE */
36 FW_START = 0xee00,
37
38
39 /* EEPROM */
40 E2P_START = 0xf800,
41 E2P_LEN = 0x800,
42
43 /* EEPROM layout */
44 E2P_LOAD_CODE_LEN = 0xe, /* base 0xf800 */
45 E2P_LOAD_VECT_LEN = 0x9, /* base 0xf80e */
46 /* E2P_DATA indexes into this */
47 E2P_DATA_LEN = 0x7e, /* base 0xf817 */
48 E2P_BOOT_CODE_LEN = 0x760, /* base 0xf895 */
49 E2P_INTR_VECT_LEN = 0xb, /* base 0xfff5 */
50
51 /* Some precomputed offsets into the EEPROM */
52 E2P_DATA_OFFSET = E2P_LOAD_CODE_LEN + E2P_LOAD_VECT_LEN,
53 E2P_BOOT_CODE_OFFSET = E2P_DATA_OFFSET + E2P_DATA_LEN,
54};
55
56#define CTL_REG(offset) ((zd_addr_t)(CR_START + (offset)))
57#define E2P_DATA(offset) ((zd_addr_t)(E2P_START + E2P_DATA_OFFSET + (offset)))
58#define FWRAW_DATA(offset) ((zd_addr_t)(FW_START + (offset)))
59
30/* 8-bit hardware registers */ 60/* 8-bit hardware registers */
31#define CR0 CTL_REG(0x0000) 61#define CR0 CTL_REG(0x0000)
32#define CR1 CTL_REG(0x0004) 62#define CR1 CTL_REG(0x0004)
@@ -302,7 +332,7 @@
302 332
303#define CR_MAX_PHY_REG 255 333#define CR_MAX_PHY_REG 255
304 334
305/* Taken from the ZYDAS driver, not all of them are relevant for the ZSD1211 335/* Taken from the ZYDAS driver, not all of them are relevant for the ZD1211
306 * driver. 336 * driver.
307 */ 337 */
308 338
@@ -594,81 +624,71 @@
594/* 624/*
595 * Upper 16 bit contains the regulatory domain. 625 * Upper 16 bit contains the regulatory domain.
596 */ 626 */
597#define E2P_SUBID E2P_REG(0x00) 627#define E2P_SUBID E2P_DATA(0x00)
598#define E2P_POD E2P_REG(0x02) 628#define E2P_POD E2P_DATA(0x02)
599#define E2P_MAC_ADDR_P1 E2P_REG(0x04) 629#define E2P_MAC_ADDR_P1 E2P_DATA(0x04)
600#define E2P_MAC_ADDR_P2 E2P_REG(0x06) 630#define E2P_MAC_ADDR_P2 E2P_DATA(0x06)
601#define E2P_PWR_CAL_VALUE1 E2P_REG(0x08) 631#define E2P_PWR_CAL_VALUE1 E2P_DATA(0x08)
602#define E2P_PWR_CAL_VALUE2 E2P_REG(0x0a) 632#define E2P_PWR_CAL_VALUE2 E2P_DATA(0x0a)
603#define E2P_PWR_CAL_VALUE3 E2P_REG(0x0c) 633#define E2P_PWR_CAL_VALUE3 E2P_DATA(0x0c)
604#define E2P_PWR_CAL_VALUE4 E2P_REG(0x0e) 634#define E2P_PWR_CAL_VALUE4 E2P_DATA(0x0e)
605#define E2P_PWR_INT_VALUE1 E2P_REG(0x10) 635#define E2P_PWR_INT_VALUE1 E2P_DATA(0x10)
606#define E2P_PWR_INT_VALUE2 E2P_REG(0x12) 636#define E2P_PWR_INT_VALUE2 E2P_DATA(0x12)
607#define E2P_PWR_INT_VALUE3 E2P_REG(0x14) 637#define E2P_PWR_INT_VALUE3 E2P_DATA(0x14)
608#define E2P_PWR_INT_VALUE4 E2P_REG(0x16) 638#define E2P_PWR_INT_VALUE4 E2P_DATA(0x16)
609 639
610/* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30) 640/* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30)
611 * also only 11 channels. */ 641 * also only 11 channels. */
612#define E2P_ALLOWED_CHANNEL E2P_REG(0x18) 642#define E2P_ALLOWED_CHANNEL E2P_DATA(0x18)
613 643
614#define E2P_PHY_REG E2P_REG(0x1a) 644#define E2P_PHY_REG E2P_DATA(0x1a)
615#define E2P_DEVICE_VER E2P_REG(0x20) 645#define E2P_DEVICE_VER E2P_DATA(0x20)
616#define E2P_36M_CAL_VALUE1 E2P_REG(0x28) 646#define E2P_36M_CAL_VALUE1 E2P_DATA(0x28)
617#define E2P_36M_CAL_VALUE2 E2P_REG(0x2a) 647#define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a)
618#define E2P_36M_CAL_VALUE3 E2P_REG(0x2c) 648#define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c)
619#define E2P_36M_CAL_VALUE4 E2P_REG(0x2e) 649#define E2P_36M_CAL_VALUE4 E2P_DATA(0x2e)
620#define E2P_11A_INT_VALUE1 E2P_REG(0x30) 650#define E2P_11A_INT_VALUE1 E2P_DATA(0x30)
621#define E2P_11A_INT_VALUE2 E2P_REG(0x32) 651#define E2P_11A_INT_VALUE2 E2P_DATA(0x32)
622#define E2P_11A_INT_VALUE3 E2P_REG(0x34) 652#define E2P_11A_INT_VALUE3 E2P_DATA(0x34)
623#define E2P_11A_INT_VALUE4 E2P_REG(0x36) 653#define E2P_11A_INT_VALUE4 E2P_DATA(0x36)
624#define E2P_48M_CAL_VALUE1 E2P_REG(0x38) 654#define E2P_48M_CAL_VALUE1 E2P_DATA(0x38)
625#define E2P_48M_CAL_VALUE2 E2P_REG(0x3a) 655#define E2P_48M_CAL_VALUE2 E2P_DATA(0x3a)
626#define E2P_48M_CAL_VALUE3 E2P_REG(0x3c) 656#define E2P_48M_CAL_VALUE3 E2P_DATA(0x3c)
627#define E2P_48M_CAL_VALUE4 E2P_REG(0x3e) 657#define E2P_48M_CAL_VALUE4 E2P_DATA(0x3e)
628#define E2P_48M_INT_VALUE1 E2P_REG(0x40) 658#define E2P_48M_INT_VALUE1 E2P_DATA(0x40)
629#define E2P_48M_INT_VALUE2 E2P_REG(0x42) 659#define E2P_48M_INT_VALUE2 E2P_DATA(0x42)
630#define E2P_48M_INT_VALUE3 E2P_REG(0x44) 660#define E2P_48M_INT_VALUE3 E2P_DATA(0x44)
631#define E2P_48M_INT_VALUE4 E2P_REG(0x46) 661#define E2P_48M_INT_VALUE4 E2P_DATA(0x46)
632#define E2P_54M_CAL_VALUE1 E2P_REG(0x48) /* ??? */ 662#define E2P_54M_CAL_VALUE1 E2P_DATA(0x48) /* ??? */
633#define E2P_54M_CAL_VALUE2 E2P_REG(0x4a) 663#define E2P_54M_CAL_VALUE2 E2P_DATA(0x4a)
634#define E2P_54M_CAL_VALUE3 E2P_REG(0x4c) 664#define E2P_54M_CAL_VALUE3 E2P_DATA(0x4c)
635#define E2P_54M_CAL_VALUE4 E2P_REG(0x4e) 665#define E2P_54M_CAL_VALUE4 E2P_DATA(0x4e)
636#define E2P_54M_INT_VALUE1 E2P_REG(0x50) 666#define E2P_54M_INT_VALUE1 E2P_DATA(0x50)
637#define E2P_54M_INT_VALUE2 E2P_REG(0x52) 667#define E2P_54M_INT_VALUE2 E2P_DATA(0x52)
638#define E2P_54M_INT_VALUE3 E2P_REG(0x54) 668#define E2P_54M_INT_VALUE3 E2P_DATA(0x54)
639#define E2P_54M_INT_VALUE4 E2P_REG(0x56) 669#define E2P_54M_INT_VALUE4 E2P_DATA(0x56)
640 670
641/* All 16 bit values */ 671/* This word contains the base address of the FW_REG_ registers below */
642#define FW_FIRMWARE_VER FW_REG(0) 672#define FWRAW_REGS_ADDR FWRAW_DATA(0x1d)
643/* non-zero if USB high speed connection */ 673
644#define FW_USB_SPEED FW_REG(1) 674/* All 16 bit values, offset from the address in FWRAW_REGS_ADDR */
645#define FW_FIX_TX_RATE FW_REG(2) 675enum {
646/* Seems to be able to control LEDs over the firmware */ 676 FW_REG_FIRMWARE_VER = 0,
647#define FW_LINK_STATUS FW_REG(3) 677 /* non-zero if USB high speed connection */
648#define FW_SOFT_RESET FW_REG(4) 678 FW_REG_USB_SPEED = 1,
649#define FW_FLASH_CHK FW_REG(5) 679 FW_REG_FIX_TX_RATE = 2,
680 /* Seems to be able to control LEDs over the firmware */
681 FW_REG_LED_LINK_STATUS = 3,
682 FW_REG_SOFT_RESET = 4,
683 FW_REG_FLASH_CHK = 5,
684};
650 685
686/* Values for FW_LINK_STATUS */
651#define FW_LINK_OFF 0x0 687#define FW_LINK_OFF 0x0
652#define FW_LINK_TX 0x1 688#define FW_LINK_TX 0x1
653/* 0x2 - link led on? */ 689/* 0x2 - link led on? */
654 690
655enum { 691enum {
656 CR_BASE_OFFSET = 0x9000,
657 FW_START_OFFSET = 0xee00,
658 FW_BASE_ADDR_OFFSET = FW_START_OFFSET + 0x1d,
659 EEPROM_START_OFFSET = 0xf800,
660 EEPROM_SIZE = 0x800, /* words */
661 LOAD_CODE_SIZE = 0xe, /* words */
662 LOAD_VECT_SIZE = 0x10000 - 0xfff7, /* words */
663 EEPROM_REGS_OFFSET = LOAD_CODE_SIZE + LOAD_VECT_SIZE,
664 EEPROM_REGS_SIZE = 0x7e, /* words */
665 E2P_BASE_OFFSET = EEPROM_START_OFFSET +
666 EEPROM_REGS_OFFSET,
667};
668
669#define FW_REG_TABLE_ADDR USB_ADDR(FW_START_OFFSET + 0x1d)
670
671enum {
672 /* indices for ofdm_cal_values */ 692 /* indices for ofdm_cal_values */
673 OFDM_36M_INDEX = 0, 693 OFDM_36M_INDEX = 0,
674 OFDM_48M_INDEX = 1, 694 OFDM_48M_INDEX = 1,
@@ -679,6 +699,8 @@ struct zd_chip {
679 struct zd_usb usb; 699 struct zd_usb usb;
680 struct zd_rf rf; 700 struct zd_rf rf;
681 struct mutex mutex; 701 struct mutex mutex;
702 /* Base address of FW_REG_ registers */
703 zd_addr_t fw_regs_base;
682 u8 e2p_mac[ETH_ALEN]; 704 u8 e2p_mac[ETH_ALEN];
683 /* EepSetPoint in the vendor driver */ 705 /* EepSetPoint in the vendor driver */
684 u8 pwr_cal_values[E2P_CHANNEL_COUNT]; 706 u8 pwr_cal_values[E2P_CHANNEL_COUNT];
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
index fb22f62cf1f3..deb99d1eaa77 100644
--- a/drivers/net/wireless/zd1211rw/zd_def.h
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -23,6 +23,8 @@
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25 25
26typedef u16 __nocast zd_addr_t;
27
26#define dev_printk_f(level, dev, fmt, args...) \ 28#define dev_printk_f(level, dev, fmt, args...) \
27 dev_printk(level, dev, "%s() " fmt, __func__, ##args) 29 dev_printk(level, dev, "%s() " fmt, __func__, ##args)
28 30
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
index 26b8298dff8c..c4f36d39642b 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
@@ -2,7 +2,6 @@
2#define _ZD_IEEE80211_H 2#define _ZD_IEEE80211_H
3 3
4#include <net/ieee80211.h> 4#include <net/ieee80211.h>
5#include "zd_types.h"
6 5
7/* Additional definitions from the standards. 6/* Additional definitions from the standards.
8 */ 7 */
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.h b/drivers/net/wireless/zd1211rw/zd_rf.h
index 676b3734f1ed..a57732eb69e1 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf.h
+++ b/drivers/net/wireless/zd1211rw/zd_rf.h
@@ -18,8 +18,6 @@
18#ifndef _ZD_RF_H 18#ifndef _ZD_RF_H
19#define _ZD_RF_H 19#define _ZD_RF_H
20 20
21#include "zd_types.h"
22
23#define UW2451_RF 0x2 21#define UW2451_RF 0x2
24#define UCHIP_RF 0x3 22#define UCHIP_RF 0x3
25#define AL2230_RF 0x4 23#define AL2230_RF 0x4
diff --git a/drivers/net/wireless/zd1211rw/zd_types.h b/drivers/net/wireless/zd1211rw/zd_types.h
deleted file mode 100644
index 0155a1584ed3..000000000000
--- a/drivers/net/wireless/zd1211rw/zd_types.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/* zd_types.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_TYPES_H
19#define _ZD_TYPES_H
20
21#include <linux/types.h>
22
23/* We have three register spaces mapped into the overall USB address space of
24 * 64K words (16-bit values). There is the control register space of
25 * double-word registers, the eeprom register space and the firmware register
26 * space. The control register space is byte mapped, the others are word
27 * mapped.
28 *
29 * For that reason, we are using byte offsets for control registers and word
30 * offsets for everything else.
31 */
32
33typedef u32 __nocast zd_addr_t;
34
35enum {
36 ADDR_BASE_MASK = 0xff000000,
37 ADDR_OFFSET_MASK = 0x0000ffff,
38 ADDR_ZERO_MASK = 0x00ff0000,
39 NULL_BASE = 0x00000000,
40 USB_BASE = 0x01000000,
41 CR_BASE = 0x02000000,
42 CR_MAX_OFFSET = 0x0b30,
43 E2P_BASE = 0x03000000,
44 E2P_MAX_OFFSET = 0x007e,
45 FW_BASE = 0x04000000,
46 FW_MAX_OFFSET = 0x0005,
47};
48
49#define ZD_ADDR_BASE(addr) ((u32)(addr) & ADDR_BASE_MASK)
50#define ZD_OFFSET(addr) ((u32)(addr) & ADDR_OFFSET_MASK)
51
52#define ZD_ADDR(base, offset) \
53 ((zd_addr_t)(((base) & ADDR_BASE_MASK) | ((offset) & ADDR_OFFSET_MASK)))
54
55#define ZD_NULL_ADDR ((zd_addr_t)0)
56#define USB_REG(offset) ZD_ADDR(USB_BASE, offset) /* word addressing */
57#define CTL_REG(offset) ZD_ADDR(CR_BASE, offset) /* byte addressing */
58#define E2P_REG(offset) ZD_ADDR(E2P_BASE, offset) /* word addressing */
59#define FW_REG(offset) ZD_ADDR(FW_BASE, offset) /* word addressing */
60
61static inline zd_addr_t zd_inc_word(zd_addr_t addr)
62{
63 u32 base = ZD_ADDR_BASE(addr);
64 u32 offset = ZD_OFFSET(addr);
65
66 offset += base == CR_BASE ? 2 : 1;
67
68 return base | offset;
69}
70
71#endif /* _ZD_TYPES_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 605e96e74057..75ef55624d7f 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -58,6 +58,10 @@ static struct usb_device_id usb_ids[] = {
58 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, 58 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B },
59 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, 59 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B },
60 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B }, 60 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B },
61 { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B },
62 { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
63 { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B },
64 { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B },
61 /* "Driverless" devices that need ejecting */ 65 /* "Driverless" devices that need ejecting */
62 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, 66 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
63 {} 67 {}
@@ -73,96 +77,6 @@ MODULE_DEVICE_TABLE(usb, usb_ids);
73#define FW_ZD1211_PREFIX "zd1211/zd1211_" 77#define FW_ZD1211_PREFIX "zd1211/zd1211_"
74#define FW_ZD1211B_PREFIX "zd1211/zd1211b_" 78#define FW_ZD1211B_PREFIX "zd1211/zd1211b_"
75 79
76/* register address handling */
77
78#ifdef DEBUG
79static int check_addr(struct zd_usb *usb, zd_addr_t addr)
80{
81 u32 base = ZD_ADDR_BASE(addr);
82 u32 offset = ZD_OFFSET(addr);
83
84 if ((u32)addr & ADDR_ZERO_MASK)
85 goto invalid_address;
86 switch (base) {
87 case USB_BASE:
88 break;
89 case CR_BASE:
90 if (offset > CR_MAX_OFFSET) {
91 dev_dbg(zd_usb_dev(usb),
92 "CR offset %#010x larger than"
93 " CR_MAX_OFFSET %#10x\n",
94 offset, CR_MAX_OFFSET);
95 goto invalid_address;
96 }
97 if (offset & 1) {
98 dev_dbg(zd_usb_dev(usb),
99 "CR offset %#010x is not a multiple of 2\n",
100 offset);
101 goto invalid_address;
102 }
103 break;
104 case E2P_BASE:
105 if (offset > E2P_MAX_OFFSET) {
106 dev_dbg(zd_usb_dev(usb),
107 "E2P offset %#010x larger than"
108 " E2P_MAX_OFFSET %#010x\n",
109 offset, E2P_MAX_OFFSET);
110 goto invalid_address;
111 }
112 break;
113 case FW_BASE:
114 if (!usb->fw_base_offset) {
115 dev_dbg(zd_usb_dev(usb),
116 "ERROR: fw base offset has not been set\n");
117 return -EAGAIN;
118 }
119 if (offset > FW_MAX_OFFSET) {
120 dev_dbg(zd_usb_dev(usb),
121 "FW offset %#10x is larger than"
122 " FW_MAX_OFFSET %#010x\n",
123 offset, FW_MAX_OFFSET);
124 goto invalid_address;
125 }
126 break;
127 default:
128 dev_dbg(zd_usb_dev(usb),
129 "address has unsupported base %#010x\n", addr);
130 goto invalid_address;
131 }
132
133 return 0;
134invalid_address:
135 dev_dbg(zd_usb_dev(usb),
136 "ERROR: invalid address: %#010x\n", addr);
137 return -EINVAL;
138}
139#endif /* DEBUG */
140
141static u16 usb_addr(struct zd_usb *usb, zd_addr_t addr)
142{
143 u32 base;
144 u16 offset;
145
146 base = ZD_ADDR_BASE(addr);
147 offset = ZD_OFFSET(addr);
148
149 ZD_ASSERT(check_addr(usb, addr) == 0);
150
151 switch (base) {
152 case CR_BASE:
153 offset += CR_BASE_OFFSET;
154 break;
155 case E2P_BASE:
156 offset += E2P_BASE_OFFSET;
157 break;
158 case FW_BASE:
159 offset += usb->fw_base_offset;
160 break;
161 }
162
163 return offset;
164}
165
166/* USB device initialization */ 80/* USB device initialization */
167 81
168static int request_fw_file( 82static int request_fw_file(
@@ -295,14 +209,13 @@ static int handle_version_mismatch(struct usb_device *udev, u8 device_type,
295 if (r) 209 if (r)
296 goto error; 210 goto error;
297 211
298 r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START_OFFSET, 212 r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START, REBOOT);
299 REBOOT);
300 if (r) 213 if (r)
301 goto error; 214 goto error;
302 215
303 offset = ((EEPROM_REGS_OFFSET + EEPROM_REGS_SIZE) * sizeof(u16)); 216 offset = (E2P_BOOT_CODE_OFFSET * sizeof(u16));
304 r = upload_code(udev, ub_fw->data + offset, ub_fw->size - offset, 217 r = upload_code(udev, ub_fw->data + offset, ub_fw->size - offset,
305 E2P_BASE_OFFSET + EEPROM_REGS_SIZE, REBOOT); 218 E2P_START + E2P_BOOT_CODE_OFFSET, REBOOT);
306 219
307 /* At this point, the vendor driver downloads the whole firmware 220 /* At this point, the vendor driver downloads the whole firmware
308 * image, hacks around with version IDs, and uploads it again, 221 * image, hacks around with version IDs, and uploads it again,
@@ -331,7 +244,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type)
331 if (r) 244 if (r)
332 goto error; 245 goto error;
333 246
334 fw_bcdDevice = get_word(ub_fw->data, EEPROM_REGS_OFFSET); 247 fw_bcdDevice = get_word(ub_fw->data, E2P_DATA_OFFSET);
335 248
336 if (fw_bcdDevice != bcdDevice) { 249 if (fw_bcdDevice != bcdDevice) {
337 dev_info(&udev->dev, 250 dev_info(&udev->dev,
@@ -357,8 +270,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type)
357 if (r) 270 if (r)
358 goto error; 271 goto error;
359 272
360 r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START_OFFSET, 273 r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START, REBOOT);
361 REBOOT);
362 if (r) { 274 if (r) {
363 dev_err(&udev->dev, 275 dev_err(&udev->dev,
364 "Could not upload firmware code uph. Error number %d\n", 276 "Could not upload firmware code uph. Error number %d\n",
@@ -858,7 +770,7 @@ static inline void init_usb_interrupt(struct zd_usb *usb)
858 spin_lock_init(&intr->lock); 770 spin_lock_init(&intr->lock);
859 intr->interval = int_urb_interval(zd_usb_to_usbdev(usb)); 771 intr->interval = int_urb_interval(zd_usb_to_usbdev(usb));
860 init_completion(&intr->read_regs.completion); 772 init_completion(&intr->read_regs.completion);
861 intr->read_regs.cr_int_addr = cpu_to_le16(usb_addr(usb, CR_INTERRUPT)); 773 intr->read_regs.cr_int_addr = cpu_to_le16((u16)CR_INTERRUPT);
862} 774}
863 775
864static inline void init_usb_rx(struct zd_usb *usb) 776static inline void init_usb_rx(struct zd_usb *usb)
@@ -890,22 +802,6 @@ void zd_usb_init(struct zd_usb *usb, struct net_device *netdev,
890 init_usb_rx(usb); 802 init_usb_rx(usb);
891} 803}
892 804
893int zd_usb_init_hw(struct zd_usb *usb)
894{
895 int r;
896 struct zd_chip *chip = zd_usb_to_chip(usb);
897
898 ZD_ASSERT(mutex_is_locked(&chip->mutex));
899 r = zd_ioread16_locked(chip, &usb->fw_base_offset,
900 USB_REG((u16)FW_BASE_ADDR_OFFSET));
901 if (r)
902 return r;
903 dev_dbg_f(zd_usb_dev(usb), "fw_base_offset: %#06hx\n",
904 usb->fw_base_offset);
905
906 return 0;
907}
908
909void zd_usb_clear(struct zd_usb *usb) 805void zd_usb_clear(struct zd_usb *usb)
910{ 806{
911 usb_set_intfdata(usb->intf, NULL); 807 usb_set_intfdata(usb->intf, NULL);
@@ -1253,7 +1149,7 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values,
1253 return -ENOMEM; 1149 return -ENOMEM;
1254 req->id = cpu_to_le16(USB_REQ_READ_REGS); 1150 req->id = cpu_to_le16(USB_REQ_READ_REGS);
1255 for (i = 0; i < count; i++) 1151 for (i = 0; i < count; i++)
1256 req->addr[i] = cpu_to_le16(usb_addr(usb, addresses[i])); 1152 req->addr[i] = cpu_to_le16((u16)addresses[i]);
1257 1153
1258 udev = zd_usb_to_usbdev(usb); 1154 udev = zd_usb_to_usbdev(usb);
1259 prepare_read_regs_int(usb); 1155 prepare_read_regs_int(usb);
@@ -1318,7 +1214,7 @@ int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
1318 req->id = cpu_to_le16(USB_REQ_WRITE_REGS); 1214 req->id = cpu_to_le16(USB_REQ_WRITE_REGS);
1319 for (i = 0; i < count; i++) { 1215 for (i = 0; i < count; i++) {
1320 struct reg_data *rw = &req->reg_writes[i]; 1216 struct reg_data *rw = &req->reg_writes[i];
1321 rw->addr = cpu_to_le16(usb_addr(usb, ioreqs[i].addr)); 1217 rw->addr = cpu_to_le16((u16)ioreqs[i].addr);
1322 rw->value = cpu_to_le16(ioreqs[i].value); 1218 rw->value = cpu_to_le16(ioreqs[i].value);
1323 } 1219 }
1324 1220
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
index 317d37c36679..506ea6a74393 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.h
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -25,7 +25,6 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26 26
27#include "zd_def.h" 27#include "zd_def.h"
28#include "zd_types.h"
29 28
30enum devicetype { 29enum devicetype {
31 DEVICE_ZD1211 = 0, 30 DEVICE_ZD1211 = 0,
@@ -181,15 +180,14 @@ struct zd_usb_tx {
181 spinlock_t lock; 180 spinlock_t lock;
182}; 181};
183 182
184/* Contains the usb parts. The structure doesn't require a lock, because intf 183/* Contains the usb parts. The structure doesn't require a lock because intf
185 * and fw_base_offset, will not be changed after initialization. 184 * will not be changed after initialization.
186 */ 185 */
187struct zd_usb { 186struct zd_usb {
188 struct zd_usb_interrupt intr; 187 struct zd_usb_interrupt intr;
189 struct zd_usb_rx rx; 188 struct zd_usb_rx rx;
190 struct zd_usb_tx tx; 189 struct zd_usb_tx tx;
191 struct usb_interface *intf; 190 struct usb_interface *intf;
192 u16 fw_base_offset;
193}; 191};
194 192
195#define zd_usb_dev(usb) (&usb->intf->dev) 193#define zd_usb_dev(usb) (&usb->intf->dev)