aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/orinoco
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-05-05 16:14:16 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-05-05 16:14:16 -0400
commit83163244f845c296a118ce85c653872dbff6abfe (patch)
treece2eac695a1c198f23d537e20ed86c16ece21f7e /drivers/net/wireless/orinoco
parent0a12761bcd5646691c5d16dd93df84d1b8849285 (diff)
parentadfba3c7c026a6a5560d2a43fefc9b198cb74462 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Conflicts: drivers/net/wireless/libertas_tf/cmd.c drivers/net/wireless/libertas_tf/main.c
Diffstat (limited to 'drivers/net/wireless/orinoco')
-rw-r--r--drivers/net/wireless/orinoco/Kconfig7
-rw-r--r--drivers/net/wireless/orinoco/Makefile1
-rw-r--r--drivers/net/wireless/orinoco/airport.c8
-rw-r--r--drivers/net/wireless/orinoco/cfg.c2
-rw-r--r--drivers/net/wireless/orinoco/fw.c10
-rw-r--r--drivers/net/wireless/orinoco/hermes.c286
-rw-r--r--drivers/net/wireless/orinoco/hermes.h62
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c243
-rw-r--r--drivers/net/wireless/orinoco/hw.c63
-rw-r--r--drivers/net/wireless/orinoco/main.c137
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h30
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_usb.c1800
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c7
-rw-r--r--drivers/net/wireless/orinoco/wext.c6
19 files changed, 2278 insertions, 398 deletions
diff --git a/drivers/net/wireless/orinoco/Kconfig b/drivers/net/wireless/orinoco/Kconfig
index 6116b546861..60819bcf437 100644
--- a/drivers/net/wireless/orinoco/Kconfig
+++ b/drivers/net/wireless/orinoco/Kconfig
@@ -132,3 +132,10 @@ config PCMCIA_SPECTRUM
132 This driver requires firmware download on startup. Utilities 132 This driver requires firmware download on startup. Utilities
133 for downloading Symbol firmware are available at 133 for downloading Symbol firmware are available at
134 <http://sourceforge.net/projects/orinoco/> 134 <http://sourceforge.net/projects/orinoco/>
135
136config ORINOCO_USB
137 tristate "Agere Orinoco USB support"
138 depends on USB && HERMES
139 select FW_LOADER
140 ---help---
141 This driver is for USB versions of the Agere Orinoco card.
diff --git a/drivers/net/wireless/orinoco/Makefile b/drivers/net/wireless/orinoco/Makefile
index e6452698eba..bfdefb85abc 100644
--- a/drivers/net/wireless/orinoco/Makefile
+++ b/drivers/net/wireless/orinoco/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_PCI_HERMES) += orinoco_pci.o
11obj-$(CONFIG_TMD_HERMES) += orinoco_tmd.o 11obj-$(CONFIG_TMD_HERMES) += orinoco_tmd.o
12obj-$(CONFIG_NORTEL_HERMES) += orinoco_nortel.o 12obj-$(CONFIG_NORTEL_HERMES) += orinoco_nortel.o
13obj-$(CONFIG_PCMCIA_SPECTRUM) += spectrum_cs.o 13obj-$(CONFIG_PCMCIA_SPECTRUM) += spectrum_cs.o
14obj-$(CONFIG_ORINOCO_USB) += orinoco_usb.o
14 15
15# Orinoco should be endian clean. 16# Orinoco should be endian clean.
16ccflags-y += -D__CHECK_ENDIAN__ 17ccflags-y += -D__CHECK_ENDIAN__
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index c60df2c1aca..9bcee10c930 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -77,9 +77,9 @@ airport_resume(struct macio_dev *mdev)
77 77
78 enable_irq(card->irq); 78 enable_irq(card->irq);
79 79
80 spin_lock_irqsave(&priv->lock, flags); 80 priv->hw.ops->lock_irqsave(&priv->lock, &flags);
81 err = orinoco_up(priv); 81 err = orinoco_up(priv);
82 spin_unlock_irqrestore(&priv->lock, flags); 82 priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
83 83
84 return err; 84 return err;
85} 85}
@@ -195,7 +195,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
195 ssleep(1); 195 ssleep(1);
196 196
197 /* Reset it before we get the interrupt */ 197 /* Reset it before we get the interrupt */
198 hermes_init(hw); 198 hw->ops->init(hw);
199 199
200 if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) { 200 if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) {
201 printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq); 201 printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq);
@@ -210,7 +210,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
210 } 210 }
211 211
212 /* Register an interface with the stack */ 212 /* Register an interface with the stack */
213 if (orinoco_if_add(priv, phys_addr, card->irq) != 0) { 213 if (orinoco_if_add(priv, phys_addr, card->irq, NULL) != 0) {
214 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 214 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
215 goto failed; 215 goto failed;
216 } 216 }
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c
index 90dd4d0595c..81d228de9e5 100644
--- a/drivers/net/wireless/orinoco/cfg.c
+++ b/drivers/net/wireless/orinoco/cfg.c
@@ -189,7 +189,7 @@ static int orinoco_set_channel(struct wiphy *wiphy,
189 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 189 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
190 /* Fast channel change - no commit if successful */ 190 /* Fast channel change - no commit if successful */
191 hermes_t *hw = &priv->hw; 191 hermes_t *hw = &priv->hw;
192 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 192 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
193 HERMES_TEST_SET_CHANNEL, 193 HERMES_TEST_SET_CHANNEL,
194 channel, NULL); 194 channel, NULL);
195 } 195 }
diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c
index 5ea0f7cf85b..3e1947d097c 100644
--- a/drivers/net/wireless/orinoco/fw.c
+++ b/drivers/net/wireless/orinoco/fw.c
@@ -122,7 +122,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
122 dev_dbg(dev, "Attempting to download firmware %s\n", firmware); 122 dev_dbg(dev, "Attempting to download firmware %s\n", firmware);
123 123
124 /* Read current plug data */ 124 /* Read current plug data */
125 err = hermes_read_pda(hw, pda, fw->pda_addr, fw->pda_size, 0); 125 err = hw->ops->read_pda(hw, pda, fw->pda_addr, fw->pda_size);
126 dev_dbg(dev, "Read PDA returned %d\n", err); 126 dev_dbg(dev, "Read PDA returned %d\n", err);
127 if (err) 127 if (err)
128 goto free; 128 goto free;
@@ -149,7 +149,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
149 } 149 }
150 150
151 /* Enable aux port to allow programming */ 151 /* Enable aux port to allow programming */
152 err = hermesi_program_init(hw, le32_to_cpu(hdr->entry_point)); 152 err = hw->ops->program_init(hw, le32_to_cpu(hdr->entry_point));
153 dev_dbg(dev, "Program init returned %d\n", err); 153 dev_dbg(dev, "Program init returned %d\n", err);
154 if (err != 0) 154 if (err != 0)
155 goto abort; 155 goto abort;
@@ -177,7 +177,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
177 goto abort; 177 goto abort;
178 178
179 /* Tell card we've finished */ 179 /* Tell card we've finished */
180 err = hermesi_program_end(hw); 180 err = hw->ops->program_end(hw);
181 dev_dbg(dev, "Program end returned %d\n", err); 181 dev_dbg(dev, "Program end returned %d\n", err);
182 if (err != 0) 182 if (err != 0)
183 goto abort; 183 goto abort;
@@ -224,7 +224,7 @@ symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
224 if (!pda) 224 if (!pda)
225 return -ENOMEM; 225 return -ENOMEM;
226 226
227 ret = hermes_read_pda(hw, pda, fw->pda_addr, fw->pda_size, 1); 227 ret = hw->ops->read_pda(hw, pda, fw->pda_addr, fw->pda_size);
228 if (ret) 228 if (ret)
229 goto free; 229 goto free;
230 } 230 }
@@ -260,7 +260,7 @@ symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
260 } 260 }
261 261
262 /* Reset hermes chip and make sure it responds */ 262 /* Reset hermes chip and make sure it responds */
263 ret = hermes_init(hw); 263 ret = hw->ops->init(hw);
264 264
265 /* hermes_reset() should return 0 with the secondary firmware */ 265 /* hermes_reset() should return 0 with the secondary firmware */
266 if (secondary && ret != 0) 266 if (secondary && ret != 0)
diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c
index 1a2fca76fd3..6c6a23e08df 100644
--- a/drivers/net/wireless/orinoco/hermes.c
+++ b/drivers/net/wireless/orinoco/hermes.c
@@ -52,6 +52,26 @@
52#define ALLOC_COMPL_TIMEOUT (1000) /* in iterations of ~10us */ 52#define ALLOC_COMPL_TIMEOUT (1000) /* in iterations of ~10us */
53 53
54/* 54/*
55 * AUX port access. To unlock the AUX port write the access keys to the
56 * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
57 * register. Then read it and make sure it's HERMES_AUX_ENABLED.
58 */
59#define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
60#define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
61#define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
62#define HERMES_AUX_DISABLED 0x0000 /* Auxiliary port is closed */
63
64#define HERMES_AUX_PW0 0xFE01
65#define HERMES_AUX_PW1 0xDC23
66#define HERMES_AUX_PW2 0xBA45
67
68/* HERMES_CMD_DOWNLD */
69#define HERMES_PROGRAM_DISABLE (0x0000 | HERMES_CMD_DOWNLD)
70#define HERMES_PROGRAM_ENABLE_VOLATILE (0x0100 | HERMES_CMD_DOWNLD)
71#define HERMES_PROGRAM_ENABLE_NON_VOLATILE (0x0200 | HERMES_CMD_DOWNLD)
72#define HERMES_PROGRAM_NON_VOLATILE (0x0300 | HERMES_CMD_DOWNLD)
73
74/*
55 * Debugging helpers 75 * Debugging helpers
56 */ 76 */
57 77
@@ -70,6 +90,7 @@
70 90
71#endif /* ! HERMES_DEBUG */ 91#endif /* ! HERMES_DEBUG */
72 92
93static const struct hermes_ops hermes_ops_local;
73 94
74/* 95/*
75 * Internal functions 96 * Internal functions
@@ -111,9 +132,9 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0,
111 */ 132 */
112 133
113/* For doing cmds that wipe the magic constant in SWSUPPORT0 */ 134/* For doing cmds that wipe the magic constant in SWSUPPORT0 */
114int hermes_doicmd_wait(hermes_t *hw, u16 cmd, 135static int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
115 u16 parm0, u16 parm1, u16 parm2, 136 u16 parm0, u16 parm1, u16 parm2,
116 struct hermes_response *resp) 137 struct hermes_response *resp)
117{ 138{
118 int err = 0; 139 int err = 0;
119 int k; 140 int k;
@@ -163,17 +184,18 @@ int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
163out: 184out:
164 return err; 185 return err;
165} 186}
166EXPORT_SYMBOL(hermes_doicmd_wait);
167 187
168void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing) 188void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
169{ 189{
170 hw->iobase = address; 190 hw->iobase = address;
171 hw->reg_spacing = reg_spacing; 191 hw->reg_spacing = reg_spacing;
172 hw->inten = 0x0; 192 hw->inten = 0x0;
193 hw->eeprom_pda = false;
194 hw->ops = &hermes_ops_local;
173} 195}
174EXPORT_SYMBOL(hermes_struct_init); 196EXPORT_SYMBOL(hermes_struct_init);
175 197
176int hermes_init(hermes_t *hw) 198static int hermes_init(hermes_t *hw)
177{ 199{
178 u16 reg; 200 u16 reg;
179 int err = 0; 201 int err = 0;
@@ -217,7 +239,6 @@ int hermes_init(hermes_t *hw)
217 239
218 return err; 240 return err;
219} 241}
220EXPORT_SYMBOL(hermes_init);
221 242
222/* Issue a command to the chip, and (busy!) wait for it to 243/* Issue a command to the chip, and (busy!) wait for it to
223 * complete. 244 * complete.
@@ -228,8 +249,8 @@ EXPORT_SYMBOL(hermes_init);
228 * > 0 on error returned by the firmware 249 * > 0 on error returned by the firmware
229 * 250 *
230 * Callable from any context, but locking is your problem. */ 251 * Callable from any context, but locking is your problem. */
231int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, 252static int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
232 struct hermes_response *resp) 253 struct hermes_response *resp)
233{ 254{
234 int err; 255 int err;
235 int k; 256 int k;
@@ -291,9 +312,8 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
291 out: 312 out:
292 return err; 313 return err;
293} 314}
294EXPORT_SYMBOL(hermes_docmd_wait);
295 315
296int hermes_allocate(hermes_t *hw, u16 size, u16 *fid) 316static int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
297{ 317{
298 int err = 0; 318 int err = 0;
299 int k; 319 int k;
@@ -333,7 +353,6 @@ int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
333 353
334 return 0; 354 return 0;
335} 355}
336EXPORT_SYMBOL(hermes_allocate);
337 356
338/* Set up a BAP to read a particular chunk of data from card's internal buffer. 357/* Set up a BAP to read a particular chunk of data from card's internal buffer.
339 * 358 *
@@ -403,8 +422,8 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
403 * 0 on success 422 * 0 on success
404 * > 0 on error from firmware 423 * > 0 on error from firmware
405 */ 424 */
406int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, 425static int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
407 u16 id, u16 offset) 426 u16 id, u16 offset)
408{ 427{
409 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 428 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
410 int err = 0; 429 int err = 0;
@@ -422,7 +441,6 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
422 out: 441 out:
423 return err; 442 return err;
424} 443}
425EXPORT_SYMBOL(hermes_bap_pread);
426 444
427/* Write a block of data to the chip's buffer, via the 445/* Write a block of data to the chip's buffer, via the
428 * BAP. Synchronization/serialization is the caller's problem. 446 * BAP. Synchronization/serialization is the caller's problem.
@@ -432,8 +450,8 @@ EXPORT_SYMBOL(hermes_bap_pread);
432 * 0 on success 450 * 0 on success
433 * > 0 on error from firmware 451 * > 0 on error from firmware
434 */ 452 */
435int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, 453static int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
436 u16 id, u16 offset) 454 u16 id, u16 offset)
437{ 455{
438 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
439 int err = 0; 457 int err = 0;
@@ -451,7 +469,6 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
451 out: 469 out:
452 return err; 470 return err;
453} 471}
454EXPORT_SYMBOL(hermes_bap_pwrite);
455 472
456/* Read a Length-Type-Value record from the card. 473/* Read a Length-Type-Value record from the card.
457 * 474 *
@@ -461,8 +478,8 @@ EXPORT_SYMBOL(hermes_bap_pwrite);
461 * practice. 478 * practice.
462 * 479 *
463 * Callable from user or bh context. */ 480 * Callable from user or bh context. */
464int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize, 481static int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
465 u16 *length, void *buf) 482 u16 *length, void *buf)
466{ 483{
467 int err = 0; 484 int err = 0;
468 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 485 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -505,10 +522,9 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
505 522
506 return 0; 523 return 0;
507} 524}
508EXPORT_SYMBOL(hermes_read_ltv);
509 525
510int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 526static int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
511 u16 length, const void *value) 527 u16 length, const void *value)
512{ 528{
513 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 529 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
514 int err = 0; 530 int err = 0;
@@ -533,4 +549,228 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
533 549
534 return err; 550 return err;
535} 551}
536EXPORT_SYMBOL(hermes_write_ltv); 552
553/*** Hermes AUX control ***/
554
555static inline void
556hermes_aux_setaddr(hermes_t *hw, u32 addr)
557{
558 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
559 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
560}
561
562static inline int
563hermes_aux_control(hermes_t *hw, int enabled)
564{
565 int desired_state = enabled ? HERMES_AUX_ENABLED : HERMES_AUX_DISABLED;
566 int action = enabled ? HERMES_AUX_ENABLE : HERMES_AUX_DISABLE;
567 int i;
568
569 /* Already open? */
570 if (hermes_read_reg(hw, HERMES_CONTROL) == desired_state)
571 return 0;
572
573 hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0);
574 hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1);
575 hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2);
576 hermes_write_reg(hw, HERMES_CONTROL, action);
577
578 for (i = 0; i < 20; i++) {
579 udelay(10);
580 if (hermes_read_reg(hw, HERMES_CONTROL) ==
581 desired_state)
582 return 0;
583 }
584
585 return -EBUSY;
586}
587
588/*** Hermes programming ***/
589
590/* About to start programming data (Hermes I)
591 * offset is the entry point
592 *
593 * Spectrum_cs' Symbol fw does not require this
594 * wl_lkm Agere fw does
595 * Don't know about intersil
596 */
597static int hermesi_program_init(hermes_t *hw, u32 offset)
598{
599 int err;
600
601 /* Disable interrupts?*/
602 /*hw->inten = 0x0;*/
603 /*hermes_write_regn(hw, INTEN, 0);*/
604 /*hermes_set_irqmask(hw, 0);*/
605
606 /* Acknowledge any outstanding command */
607 hermes_write_regn(hw, EVACK, 0xFFFF);
608
609 /* Using init_cmd_wait rather than cmd_wait */
610 err = hw->ops->init_cmd_wait(hw,
611 0x0100 | HERMES_CMD_INIT,
612 0, 0, 0, NULL);
613 if (err)
614 return err;
615
616 err = hw->ops->init_cmd_wait(hw,
617 0x0000 | HERMES_CMD_INIT,
618 0, 0, 0, NULL);
619 if (err)
620 return err;
621
622 err = hermes_aux_control(hw, 1);
623 pr_debug("AUX enable returned %d\n", err);
624
625 if (err)
626 return err;
627
628 pr_debug("Enabling volatile, EP 0x%08x\n", offset);
629 err = hw->ops->init_cmd_wait(hw,
630 HERMES_PROGRAM_ENABLE_VOLATILE,
631 offset & 0xFFFFu,
632 offset >> 16,
633 0,
634 NULL);
635 pr_debug("PROGRAM_ENABLE returned %d\n", err);
636
637 return err;
638}
639
640/* Done programming data (Hermes I)
641 *
642 * Spectrum_cs' Symbol fw does not require this
643 * wl_lkm Agere fw does
644 * Don't know about intersil
645 */
646static int hermesi_program_end(hermes_t *hw)
647{
648 struct hermes_response resp;
649 int rc = 0;
650 int err;
651
652 rc = hw->ops->cmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp);
653
654 pr_debug("PROGRAM_DISABLE returned %d, "
655 "r0 0x%04x, r1 0x%04x, r2 0x%04x\n",
656 rc, resp.resp0, resp.resp1, resp.resp2);
657
658 if ((rc == 0) &&
659 ((resp.status & HERMES_STATUS_CMDCODE) != HERMES_CMD_DOWNLD))
660 rc = -EIO;
661
662 err = hermes_aux_control(hw, 0);
663 pr_debug("AUX disable returned %d\n", err);
664
665 /* Acknowledge any outstanding command */
666 hermes_write_regn(hw, EVACK, 0xFFFF);
667
668 /* Reinitialise, ignoring return */
669 (void) hw->ops->init_cmd_wait(hw, 0x0000 | HERMES_CMD_INIT,
670 0, 0, 0, NULL);
671
672 return rc ? rc : err;
673}
674
675static int hermes_program_bytes(struct hermes *hw, const char *data,
676 u32 addr, u32 len)
677{
678 /* wl lkm splits the programming into chunks of 2000 bytes.
679 * This restriction appears to come from USB. The PCMCIA
680 * adapters can program the whole lot in one go */
681 hermes_aux_setaddr(hw, addr);
682 hermes_write_bytes(hw, HERMES_AUXDATA, data, len);
683 return 0;
684}
685
686/* Read PDA from the adapter */
687static int hermes_read_pda(hermes_t *hw, __le16 *pda, u32 pda_addr, u16 pda_len)
688{
689 int ret;
690 u16 pda_size;
691 u16 data_len = pda_len;
692 __le16 *data = pda;
693
694 if (hw->eeprom_pda) {
695 /* PDA of spectrum symbol is in eeprom */
696
697 /* Issue command to read EEPROM */
698 ret = hw->ops->cmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
699 if (ret)
700 return ret;
701 } else {
702 /* wl_lkm does not include PDA size in the PDA area.
703 * We will pad the information into pda, so other routines
704 * don't have to be modified */
705 pda[0] = cpu_to_le16(pda_len - 2);
706 /* Includes CFG_PROD_DATA but not itself */
707 pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
708 data_len = pda_len - 4;
709 data = pda + 2;
710 }
711
712 /* Open auxiliary port */
713 ret = hermes_aux_control(hw, 1);
714 pr_debug("AUX enable returned %d\n", ret);
715 if (ret)
716 return ret;
717
718 /* Read PDA */
719 hermes_aux_setaddr(hw, pda_addr);
720 hermes_read_words(hw, HERMES_AUXDATA, data, data_len / 2);
721
722 /* Close aux port */
723 ret = hermes_aux_control(hw, 0);
724 pr_debug("AUX disable returned %d\n", ret);
725
726 /* Check PDA length */
727 pda_size = le16_to_cpu(pda[0]);
728 pr_debug("Actual PDA length %d, Max allowed %d\n",
729 pda_size, pda_len);
730 if (pda_size > pda_len)
731 return -EINVAL;
732
733 return 0;
734}
735
736static void hermes_lock_irqsave(spinlock_t *lock,
737 unsigned long *flags) __acquires(lock)
738{
739 spin_lock_irqsave(lock, *flags);
740}
741
742static void hermes_unlock_irqrestore(spinlock_t *lock,
743 unsigned long *flags) __releases(lock)
744{
745 spin_unlock_irqrestore(lock, *flags);
746}
747
748static void hermes_lock_irq(spinlock_t *lock) __acquires(lock)
749{
750 spin_lock_irq(lock);
751}
752
753static void hermes_unlock_irq(spinlock_t *lock) __releases(lock)
754{
755 spin_unlock_irq(lock);
756}
757
758/* Hermes operations for local buses */
759static const struct hermes_ops hermes_ops_local = {
760 .init = hermes_init,
761 .cmd_wait = hermes_docmd_wait,
762 .init_cmd_wait = hermes_doicmd_wait,
763 .allocate = hermes_allocate,
764 .read_ltv = hermes_read_ltv,
765 .write_ltv = hermes_write_ltv,
766 .bap_pread = hermes_bap_pread,
767 .bap_pwrite = hermes_bap_pwrite,
768 .read_pda = hermes_read_pda,
769 .program_init = hermesi_program_init,
770 .program_end = hermesi_program_end,
771 .program = hermes_program_bytes,
772 .lock_irqsave = hermes_lock_irqsave,
773 .unlock_irqrestore = hermes_unlock_irqrestore,
774 .lock_irq = hermes_lock_irq,
775 .unlock_irq = hermes_unlock_irq,
776};
diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h
index 2dddbb597c4..9ca34e722b4 100644
--- a/drivers/net/wireless/orinoco/hermes.h
+++ b/drivers/net/wireless/orinoco/hermes.h
@@ -374,6 +374,37 @@ struct hermes_multicast {
374/* Timeouts */ 374/* Timeouts */
375#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */ 375#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */
376 376
377struct hermes;
378
379/* Functions to access hardware */
380struct hermes_ops {
381 int (*init)(struct hermes *hw);
382 int (*cmd_wait)(struct hermes *hw, u16 cmd, u16 parm0,
383 struct hermes_response *resp);
384 int (*init_cmd_wait)(struct hermes *hw, u16 cmd,
385 u16 parm0, u16 parm1, u16 parm2,
386 struct hermes_response *resp);
387 int (*allocate)(struct hermes *hw, u16 size, u16 *fid);
388 int (*read_ltv)(struct hermes *hw, int bap, u16 rid, unsigned buflen,
389 u16 *length, void *buf);
390 int (*write_ltv)(struct hermes *hw, int bap, u16 rid,
391 u16 length, const void *value);
392 int (*bap_pread)(struct hermes *hw, int bap, void *buf, int len,
393 u16 id, u16 offset);
394 int (*bap_pwrite)(struct hermes *hw, int bap, const void *buf,
395 int len, u16 id, u16 offset);
396 int (*read_pda)(struct hermes *hw, __le16 *pda,
397 u32 pda_addr, u16 pda_len);
398 int (*program_init)(struct hermes *hw, u32 entry_point);
399 int (*program_end)(struct hermes *hw);
400 int (*program)(struct hermes *hw, const char *buf,
401 u32 addr, u32 len);
402 void (*lock_irqsave)(spinlock_t *lock, unsigned long *flags);
403 void (*unlock_irqrestore)(spinlock_t *lock, unsigned long *flags);
404 void (*lock_irq)(spinlock_t *lock);
405 void (*unlock_irq)(spinlock_t *lock);
406};
407
377/* Basic control structure */ 408/* Basic control structure */
378typedef struct hermes { 409typedef struct hermes {
379 void __iomem *iobase; 410 void __iomem *iobase;
@@ -381,6 +412,9 @@ typedef struct hermes {
381#define HERMES_16BIT_REGSPACING 0 412#define HERMES_16BIT_REGSPACING 0
382#define HERMES_32BIT_REGSPACING 1 413#define HERMES_32BIT_REGSPACING 1
383 u16 inten; /* Which interrupts should be enabled? */ 414 u16 inten; /* Which interrupts should be enabled? */
415 bool eeprom_pda;
416 const struct hermes_ops *ops;
417 void *priv;
384} hermes_t; 418} hermes_t;
385 419
386/* Register access convenience macros */ 420/* Register access convenience macros */
@@ -394,22 +428,6 @@ typedef struct hermes {
394 428
395/* Function prototypes */ 429/* Function prototypes */
396void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing); 430void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing);
397int hermes_init(hermes_t *hw);
398int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
399 struct hermes_response *resp);
400int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
401 u16 parm0, u16 parm1, u16 parm2,
402 struct hermes_response *resp);
403int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);
404
405int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
406 u16 id, u16 offset);
407int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
408 u16 id, u16 offset);
409int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,
410 u16 *length, void *buf);
411int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
412 u16 length, const void *value);
413 431
414/* Inline functions */ 432/* Inline functions */
415 433
@@ -426,13 +444,13 @@ static inline void hermes_set_irqmask(hermes_t *hw, u16 events)
426 444
427static inline int hermes_enable_port(hermes_t *hw, int port) 445static inline int hermes_enable_port(hermes_t *hw, int port)
428{ 446{
429 return hermes_docmd_wait(hw, HERMES_CMD_ENABLE | (port << 8), 447 return hw->ops->cmd_wait(hw, HERMES_CMD_ENABLE | (port << 8),
430 0, NULL); 448 0, NULL);
431} 449}
432 450
433static inline int hermes_disable_port(hermes_t *hw, int port) 451static inline int hermes_disable_port(hermes_t *hw, int port)
434{ 452{
435 return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), 453 return hw->ops->cmd_wait(hw, HERMES_CMD_DISABLE | (port << 8),
436 0, NULL); 454 0, NULL);
437} 455}
438 456
@@ -440,7 +458,7 @@ static inline int hermes_disable_port(hermes_t *hw, int port)
440 * information frame in __orinoco_ev_info() */ 458 * information frame in __orinoco_ev_info() */
441static inline int hermes_inquire(hermes_t *hw, u16 rid) 459static inline int hermes_inquire(hermes_t *hw, u16 rid)
442{ 460{
443 return hermes_docmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL); 461 return hw->ops->cmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL);
444} 462}
445 463
446#define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1) 464#define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1)
@@ -475,10 +493,10 @@ static inline void hermes_clear_words(struct hermes *hw, int off,
475} 493}
476 494
477#define HERMES_READ_RECORD(hw, bap, rid, buf) \ 495#define HERMES_READ_RECORD(hw, bap, rid, buf) \
478 (hermes_read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf))) 496 (hw->ops->read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf)))
479#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \ 497#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \
480 (hermes_write_ltv((hw), (bap), (rid), \ 498 (hw->ops->write_ltv((hw), (bap), (rid), \
481 HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf))) 499 HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf)))
482 500
483static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) 501static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
484{ 502{
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index fb157eb889c..6da85e75fce 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
@@ -46,37 +46,11 @@
46 46
47#define PFX "hermes_dld: " 47#define PFX "hermes_dld: "
48 48
49/*
50 * AUX port access. To unlock the AUX port write the access keys to the
51 * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
52 * register. Then read it and make sure it's HERMES_AUX_ENABLED.
53 */
54#define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
55#define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
56#define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
57#define HERMES_AUX_DISABLED 0x0000 /* Auxiliary port is closed */
58
59#define HERMES_AUX_PW0 0xFE01
60#define HERMES_AUX_PW1 0xDC23
61#define HERMES_AUX_PW2 0xBA45
62
63/* HERMES_CMD_DOWNLD */
64#define HERMES_PROGRAM_DISABLE (0x0000 | HERMES_CMD_DOWNLD)
65#define HERMES_PROGRAM_ENABLE_VOLATILE (0x0100 | HERMES_CMD_DOWNLD)
66#define HERMES_PROGRAM_ENABLE_NON_VOLATILE (0x0200 | HERMES_CMD_DOWNLD)
67#define HERMES_PROGRAM_NON_VOLATILE (0x0300 | HERMES_CMD_DOWNLD)
68
69/* End markers used in dblocks */ 49/* End markers used in dblocks */
70#define PDI_END 0x00000000 /* End of PDA */ 50#define PDI_END 0x00000000 /* End of PDA */
71#define BLOCK_END 0xFFFFFFFF /* Last image block */ 51#define BLOCK_END 0xFFFFFFFF /* Last image block */
72#define TEXT_END 0x1A /* End of text header */ 52#define TEXT_END 0x1A /* End of text header */
73 53
74/* Limit the amout we try to download in a single shot.
75 * Size is in bytes.
76 */
77#define MAX_DL_SIZE 1024
78#define LIMIT_PROGRAM_SIZE 0
79
80/* 54/*
81 * The following structures have little-endian fields denoted by 55 * The following structures have little-endian fields denoted by
82 * the leading underscore. Don't access them directly - use inline 56 * the leading underscore. Don't access them directly - use inline
@@ -165,41 +139,6 @@ pdi_len(const struct pdi *pdi)
165 return 2 * (le16_to_cpu(pdi->len) - 1); 139 return 2 * (le16_to_cpu(pdi->len) - 1);
166} 140}
167 141
168/*** Hermes AUX control ***/
169
170static inline void
171hermes_aux_setaddr(hermes_t *hw, u32 addr)
172{
173 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
174 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
175}
176
177static inline int
178hermes_aux_control(hermes_t *hw, int enabled)
179{
180 int desired_state = enabled ? HERMES_AUX_ENABLED : HERMES_AUX_DISABLED;
181 int action = enabled ? HERMES_AUX_ENABLE : HERMES_AUX_DISABLE;
182 int i;
183
184 /* Already open? */
185 if (hermes_read_reg(hw, HERMES_CONTROL) == desired_state)
186 return 0;
187
188 hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0);
189 hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1);
190 hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2);
191 hermes_write_reg(hw, HERMES_CONTROL, action);
192
193 for (i = 0; i < 20; i++) {
194 udelay(10);
195 if (hermes_read_reg(hw, HERMES_CONTROL) ==
196 desired_state)
197 return 0;
198 }
199
200 return -EBUSY;
201}
202
203/*** Plug Data Functions ***/ 142/*** Plug Data Functions ***/
204 143
205/* 144/*
@@ -271,62 +210,7 @@ hermes_plug_pdi(hermes_t *hw, const struct pdr *first_pdr,
271 return -EINVAL; 210 return -EINVAL;
272 211
273 /* do the actual plugging */ 212 /* do the actual plugging */
274 hermes_aux_setaddr(hw, pdr_addr(pdr)); 213 hw->ops->program(hw, pdi->data, pdr_addr(pdr), pdi_len(pdi));
275 hermes_write_bytes(hw, HERMES_AUXDATA, pdi->data, pdi_len(pdi));
276
277 return 0;
278}
279
280/* Read PDA from the adapter */
281int hermes_read_pda(hermes_t *hw,
282 __le16 *pda,
283 u32 pda_addr,
284 u16 pda_len,
285 int use_eeprom) /* can we get this into hw? */
286{
287 int ret;
288 u16 pda_size;
289 u16 data_len = pda_len;
290 __le16 *data = pda;
291
292 if (use_eeprom) {
293 /* PDA of spectrum symbol is in eeprom */
294
295 /* Issue command to read EEPROM */
296 ret = hermes_docmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
297 if (ret)
298 return ret;
299 } else {
300 /* wl_lkm does not include PDA size in the PDA area.
301 * We will pad the information into pda, so other routines
302 * don't have to be modified */
303 pda[0] = cpu_to_le16(pda_len - 2);
304 /* Includes CFG_PROD_DATA but not itself */
305 pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
306 data_len = pda_len - 4;
307 data = pda + 2;
308 }
309
310 /* Open auxiliary port */
311 ret = hermes_aux_control(hw, 1);
312 pr_debug(PFX "AUX enable returned %d\n", ret);
313 if (ret)
314 return ret;
315
316 /* read PDA from EEPROM */
317 hermes_aux_setaddr(hw, pda_addr);
318 hermes_read_words(hw, HERMES_AUXDATA, data, data_len / 2);
319
320 /* Close aux port */
321 ret = hermes_aux_control(hw, 0);
322 pr_debug(PFX "AUX disable returned %d\n", ret);
323
324 /* Check PDA length */
325 pda_size = le16_to_cpu(pda[0]);
326 pr_debug(PFX "Actual PDA length %d, Max allowed %d\n",
327 pda_size, pda_len);
328 if (pda_size > pda_len)
329 return -EINVAL;
330 214
331 return 0; 215 return 0;
332} 216}
@@ -389,101 +273,13 @@ hermes_blocks_length(const char *first_block, const void *end)
389 273
390/*** Hermes programming ***/ 274/*** Hermes programming ***/
391 275
392/* About to start programming data (Hermes I)
393 * offset is the entry point
394 *
395 * Spectrum_cs' Symbol fw does not require this
396 * wl_lkm Agere fw does
397 * Don't know about intersil
398 */
399int hermesi_program_init(hermes_t *hw, u32 offset)
400{
401 int err;
402
403 /* Disable interrupts?*/
404 /*hw->inten = 0x0;*/
405 /*hermes_write_regn(hw, INTEN, 0);*/
406 /*hermes_set_irqmask(hw, 0);*/
407
408 /* Acknowledge any outstanding command */
409 hermes_write_regn(hw, EVACK, 0xFFFF);
410
411 /* Using doicmd_wait rather than docmd_wait */
412 err = hermes_doicmd_wait(hw,
413 0x0100 | HERMES_CMD_INIT,
414 0, 0, 0, NULL);
415 if (err)
416 return err;
417
418 err = hermes_doicmd_wait(hw,
419 0x0000 | HERMES_CMD_INIT,
420 0, 0, 0, NULL);
421 if (err)
422 return err;
423
424 err = hermes_aux_control(hw, 1);
425 pr_debug(PFX "AUX enable returned %d\n", err);
426
427 if (err)
428 return err;
429
430 pr_debug(PFX "Enabling volatile, EP 0x%08x\n", offset);
431 err = hermes_doicmd_wait(hw,
432 HERMES_PROGRAM_ENABLE_VOLATILE,
433 offset & 0xFFFFu,
434 offset >> 16,
435 0,
436 NULL);
437 pr_debug(PFX "PROGRAM_ENABLE returned %d\n", err);
438
439 return err;
440}
441
442/* Done programming data (Hermes I)
443 *
444 * Spectrum_cs' Symbol fw does not require this
445 * wl_lkm Agere fw does
446 * Don't know about intersil
447 */
448int hermesi_program_end(hermes_t *hw)
449{
450 struct hermes_response resp;
451 int rc = 0;
452 int err;
453
454 rc = hermes_docmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp);
455
456 pr_debug(PFX "PROGRAM_DISABLE returned %d, "
457 "r0 0x%04x, r1 0x%04x, r2 0x%04x\n",
458 rc, resp.resp0, resp.resp1, resp.resp2);
459
460 if ((rc == 0) &&
461 ((resp.status & HERMES_STATUS_CMDCODE) != HERMES_CMD_DOWNLD))
462 rc = -EIO;
463
464 err = hermes_aux_control(hw, 0);
465 pr_debug(PFX "AUX disable returned %d\n", err);
466
467 /* Acknowledge any outstanding command */
468 hermes_write_regn(hw, EVACK, 0xFFFF);
469
470 /* Reinitialise, ignoring return */
471 (void) hermes_doicmd_wait(hw, 0x0000 | HERMES_CMD_INIT,
472 0, 0, 0, NULL);
473
474 return rc ? rc : err;
475}
476
477/* Program the data blocks */ 276/* Program the data blocks */
478int hermes_program(hermes_t *hw, const char *first_block, const void *end) 277int hermes_program(hermes_t *hw, const char *first_block, const void *end)
479{ 278{
480 const struct dblock *blk; 279 const struct dblock *blk;
481 u32 blkaddr; 280 u32 blkaddr;
482 u32 blklen; 281 u32 blklen;
483#if LIMIT_PROGRAM_SIZE 282 int err = 0;
484 u32 addr;
485 u32 len;
486#endif
487 283
488 blk = (const struct dblock *) first_block; 284 blk = (const struct dblock *) first_block;
489 285
@@ -498,30 +294,10 @@ int hermes_program(hermes_t *hw, const char *first_block, const void *end)
498 pr_debug(PFX "Programming block of length %d " 294 pr_debug(PFX "Programming block of length %d "
499 "to address 0x%08x\n", blklen, blkaddr); 295 "to address 0x%08x\n", blklen, blkaddr);
500 296
501#if !LIMIT_PROGRAM_SIZE 297 err = hw->ops->program(hw, blk->data, blkaddr, blklen);
502 /* wl_lkm driver splits this into writes of 2000 bytes */ 298 if (err)
503 hermes_aux_setaddr(hw, blkaddr); 299 break;
504 hermes_write_bytes(hw, HERMES_AUXDATA, blk->data, 300
505 blklen);
506#else
507 len = (blklen < MAX_DL_SIZE) ? blklen : MAX_DL_SIZE;
508 addr = blkaddr;
509
510 while (addr < (blkaddr + blklen)) {
511 pr_debug(PFX "Programming subblock of length %d "
512 "to address 0x%08x. Data @ %p\n",
513 len, addr, &blk->data[addr - blkaddr]);
514
515 hermes_aux_setaddr(hw, addr);
516 hermes_write_bytes(hw, HERMES_AUXDATA,
517 &blk->data[addr - blkaddr],
518 len);
519
520 addr += len;
521 len = ((blkaddr + blklen - addr) < MAX_DL_SIZE) ?
522 (blkaddr + blklen - addr) : MAX_DL_SIZE;
523 }
524#endif
525 blk = (const struct dblock *) &blk->data[blklen]; 301 blk = (const struct dblock *) &blk->data[blklen];
526 302
527 if ((void *) blk > (end - sizeof(*blk))) 303 if ((void *) blk > (end - sizeof(*blk)))
@@ -530,7 +306,7 @@ int hermes_program(hermes_t *hw, const char *first_block, const void *end)
530 blkaddr = dblock_addr(blk); 306 blkaddr = dblock_addr(blk);
531 blklen = dblock_len(blk); 307 blklen = dblock_len(blk);
532 } 308 }
533 return 0; 309 return err;
534} 310}
535 311
536/*** Default plugging data for Hermes I ***/ 312/*** Default plugging data for Hermes I ***/
@@ -690,9 +466,8 @@ int hermes_apply_pda_with_defaults(hermes_t *hw,
690 if ((pdi_len(pdi) == pdr_len(pdr)) && 466 if ((pdi_len(pdi) == pdr_len(pdr)) &&
691 ((void *) pdi->data + pdi_len(pdi) < pda_end)) { 467 ((void *) pdi->data + pdi_len(pdi) < pda_end)) {
692 /* do the actual plugging */ 468 /* do the actual plugging */
693 hermes_aux_setaddr(hw, pdr_addr(pdr)); 469 hw->ops->program(hw, pdi->data, pdr_addr(pdr),
694 hermes_write_bytes(hw, HERMES_AUXDATA, 470 pdi_len(pdi));
695 pdi->data, pdi_len(pdi));
696 } 471 }
697 } 472 }
698 473
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index 741f8cea95b..6fbd7885012 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -177,9 +177,9 @@ int determine_fw_capabilities(struct orinoco_private *priv,
177 /* 3Com MAC : 00:50:DA:* */ 177 /* 3Com MAC : 00:50:DA:* */
178 memset(tmp, 0, sizeof(tmp)); 178 memset(tmp, 0, sizeof(tmp));
179 /* Get the Symbol firmware version */ 179 /* Get the Symbol firmware version */
180 err = hermes_read_ltv(hw, USER_BAP, 180 err = hw->ops->read_ltv(hw, USER_BAP,
181 HERMES_RID_SECONDARYVERSION_SYMBOL, 181 HERMES_RID_SECONDARYVERSION_SYMBOL,
182 SYMBOL_MAX_VER_LEN, NULL, &tmp); 182 SYMBOL_MAX_VER_LEN, NULL, &tmp);
183 if (err) { 183 if (err) {
184 dev_warn(dev, "Error %d reading Symbol firmware info. " 184 dev_warn(dev, "Error %d reading Symbol firmware info. "
185 "Wildly guessing capabilities...\n", err); 185 "Wildly guessing capabilities...\n", err);
@@ -286,8 +286,8 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
286 u16 reclen; 286 u16 reclen;
287 287
288 /* Get the MAC address */ 288 /* Get the MAC address */
289 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, 289 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
290 ETH_ALEN, NULL, dev_addr); 290 ETH_ALEN, NULL, dev_addr);
291 if (err) { 291 if (err) {
292 dev_warn(dev, "Failed to read MAC address!\n"); 292 dev_warn(dev, "Failed to read MAC address!\n");
293 goto out; 293 goto out;
@@ -296,8 +296,8 @@ int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
296 dev_dbg(dev, "MAC address %pM\n", dev_addr); 296 dev_dbg(dev, "MAC address %pM\n", dev_addr);
297 297
298 /* Get the station name */ 298 /* Get the station name */
299 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, 299 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
300 sizeof(nickbuf), &reclen, &nickbuf); 300 sizeof(nickbuf), &reclen, &nickbuf);
301 if (err) { 301 if (err) {
302 dev_err(dev, "failed to read station name\n"); 302 dev_err(dev, "failed to read station name\n");
303 goto out; 303 goto out;
@@ -413,11 +413,11 @@ int orinoco_hw_allocate_fid(struct orinoco_private *priv)
413 struct hermes *hw = &priv->hw; 413 struct hermes *hw = &priv->hw;
414 int err; 414 int err;
415 415
416 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); 416 err = hw->ops->allocate(hw, priv->nicbuf_size, &priv->txfid);
417 if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) { 417 if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) {
418 /* Try workaround for old Symbol firmware bug */ 418 /* Try workaround for old Symbol firmware bug */
419 priv->nicbuf_size = TX_NICBUF_SIZE_BUG; 419 priv->nicbuf_size = TX_NICBUF_SIZE_BUG;
420 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); 420 err = hw->ops->allocate(hw, priv->nicbuf_size, &priv->txfid);
421 421
422 dev_warn(dev, "Firmware ALLOC bug detected " 422 dev_warn(dev, "Firmware ALLOC bug detected "
423 "(old Symbol firmware?). Work around %s\n", 423 "(old Symbol firmware?). Work around %s\n",
@@ -463,8 +463,9 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
463 struct hermes_idstring idbuf; 463 struct hermes_idstring idbuf;
464 464
465 /* Set the MAC address */ 465 /* Set the MAC address */
466 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, 466 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
467 HERMES_BYTES_TO_RECLEN(ETH_ALEN), dev->dev_addr); 467 HERMES_BYTES_TO_RECLEN(ETH_ALEN),
468 dev->dev_addr);
468 if (err) { 469 if (err) {
469 printk(KERN_ERR "%s: Error %d setting MAC address\n", 470 printk(KERN_ERR "%s: Error %d setting MAC address\n",
470 dev->name, err); 471 dev->name, err);
@@ -527,7 +528,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
527 idbuf.len = cpu_to_le16(strlen(priv->desired_essid)); 528 idbuf.len = cpu_to_le16(strlen(priv->desired_essid));
528 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val)); 529 memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
529 /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */ 530 /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */
530 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID, 531 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID,
531 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), 532 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
532 &idbuf); 533 &idbuf);
533 if (err) { 534 if (err) {
@@ -535,7 +536,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
535 dev->name, err); 536 dev->name, err);
536 return err; 537 return err;
537 } 538 }
538 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID, 539 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID,
539 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), 540 HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
540 &idbuf); 541 &idbuf);
541 if (err) { 542 if (err) {
@@ -547,9 +548,9 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
547 /* Set the station name */ 548 /* Set the station name */
548 idbuf.len = cpu_to_le16(strlen(priv->nick)); 549 idbuf.len = cpu_to_le16(strlen(priv->nick));
549 memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val)); 550 memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val));
550 err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, 551 err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
551 HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2), 552 HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2),
552 &idbuf); 553 &idbuf);
553 if (err) { 554 if (err) {
554 printk(KERN_ERR "%s: Error %d setting nickname\n", 555 printk(KERN_ERR "%s: Error %d setting nickname\n",
555 dev->name, err); 556 dev->name, err);
@@ -664,12 +665,12 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
664 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 665 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
665 /* Enable monitor mode */ 666 /* Enable monitor mode */
666 dev->type = ARPHRD_IEEE80211; 667 dev->type = ARPHRD_IEEE80211;
667 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 668 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
668 HERMES_TEST_MONITOR, 0, NULL); 669 HERMES_TEST_MONITOR, 0, NULL);
669 } else { 670 } else {
670 /* Disable monitor mode */ 671 /* Disable monitor mode */
671 dev->type = ARPHRD_ETHER; 672 dev->type = ARPHRD_ETHER;
672 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 673 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
673 HERMES_TEST_STOP, 0, NULL); 674 HERMES_TEST_STOP, 0, NULL);
674 } 675 }
675 if (err) 676 if (err)
@@ -695,8 +696,8 @@ int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
695 if ((key < 0) || (key >= 4)) 696 if ((key < 0) || (key >= 4))
696 return -EINVAL; 697 return -EINVAL;
697 698
698 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV, 699 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV,
699 sizeof(tsc_arr), NULL, &tsc_arr); 700 sizeof(tsc_arr), NULL, &tsc_arr);
700 if (!err) 701 if (!err)
701 memcpy(tsc, &tsc_arr[key][0], sizeof(tsc_arr[0])); 702 memcpy(tsc, &tsc_arr[key][0], sizeof(tsc_arr[0]));
702 703
@@ -875,7 +876,7 @@ int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
875 memcpy(key, priv->keys[i].key, 876 memcpy(key, priv->keys[i].key,
876 priv->keys[i].key_len); 877 priv->keys[i].key_len);
877 878
878 err = hermes_write_ltv(hw, USER_BAP, 879 err = hw->ops->write_ltv(hw, USER_BAP,
879 HERMES_RID_CNFDEFAULTKEY0 + i, 880 HERMES_RID_CNFDEFAULTKEY0 + i,
880 HERMES_BYTES_TO_RECLEN(keylen), 881 HERMES_BYTES_TO_RECLEN(keylen),
881 key); 882 key);
@@ -1092,7 +1093,7 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
1092 memcpy(mclist.addr[i++], ha->addr, ETH_ALEN); 1093 memcpy(mclist.addr[i++], ha->addr, ETH_ALEN);
1093 } 1094 }
1094 1095
1095 err = hermes_write_ltv(hw, USER_BAP, 1096 err = hw->ops->write_ltv(hw, USER_BAP,
1096 HERMES_RID_CNFGROUPADDRESSES, 1097 HERMES_RID_CNFGROUPADDRESSES,
1097 HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN), 1098 HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN),
1098 &mclist); 1099 &mclist);
@@ -1134,15 +1135,15 @@ int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
1134 rid = (priv->port_type == 3) ? HERMES_RID_CNFOWNSSID : 1135 rid = (priv->port_type == 3) ? HERMES_RID_CNFOWNSSID :
1135 HERMES_RID_CNFDESIREDSSID; 1136 HERMES_RID_CNFDESIREDSSID;
1136 1137
1137 err = hermes_read_ltv(hw, USER_BAP, rid, sizeof(essidbuf), 1138 err = hw->ops->read_ltv(hw, USER_BAP, rid, sizeof(essidbuf),
1138 NULL, &essidbuf); 1139 NULL, &essidbuf);
1139 if (err) 1140 if (err)
1140 goto fail_unlock; 1141 goto fail_unlock;
1141 } else { 1142 } else {
1142 *active = 0; 1143 *active = 0;
1143 1144
1144 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTSSID, 1145 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTSSID,
1145 sizeof(essidbuf), NULL, &essidbuf); 1146 sizeof(essidbuf), NULL, &essidbuf);
1146 if (err) 1147 if (err)
1147 goto fail_unlock; 1148 goto fail_unlock;
1148 } 1149 }
@@ -1213,8 +1214,8 @@ int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
1213 if (orinoco_lock(priv, &flags) != 0) 1214 if (orinoco_lock(priv, &flags) != 0)
1214 return -EBUSY; 1215 return -EBUSY;
1215 1216
1216 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_SUPPORTEDDATARATES, 1217 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_SUPPORTEDDATARATES,
1217 sizeof(list), NULL, &list); 1218 sizeof(list), NULL, &list);
1218 orinoco_unlock(priv, &flags); 1219 orinoco_unlock(priv, &flags);
1219 1220
1220 if (err) 1221 if (err)
@@ -1281,7 +1282,7 @@ int orinoco_hw_trigger_scan(struct orinoco_private *priv,
1281 idbuf.len = cpu_to_le16(len); 1282 idbuf.len = cpu_to_le16(len);
1282 memcpy(idbuf.val, ssid->ssid, len); 1283 memcpy(idbuf.val, ssid->ssid, len);
1283 1284
1284 err = hermes_write_ltv(hw, USER_BAP, 1285 err = hw->ops->write_ltv(hw, USER_BAP,
1285 HERMES_RID_CNFSCANSSID_AGERE, 1286 HERMES_RID_CNFSCANSSID_AGERE,
1286 HERMES_BYTES_TO_RECLEN(len + 2), 1287 HERMES_BYTES_TO_RECLEN(len + 2),
1287 &idbuf); 1288 &idbuf);
@@ -1345,8 +1346,8 @@ int orinoco_hw_get_current_bssid(struct orinoco_private *priv,
1345 hermes_t *hw = &priv->hw; 1346 hermes_t *hw = &priv->hw;
1346 int err; 1347 int err;
1347 1348
1348 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID, 1349 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
1349 ETH_ALEN, NULL, addr); 1350 ETH_ALEN, NULL, addr);
1350 1351
1351 return err; 1352 return err;
1352} 1353}
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 413e9ab6cab..1d60c7e4392 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -254,7 +254,7 @@ void set_port_type(struct orinoco_private *priv)
254/* Device methods */ 254/* Device methods */
255/********************************************************************/ 255/********************************************************************/
256 256
257static int orinoco_open(struct net_device *dev) 257int orinoco_open(struct net_device *dev)
258{ 258{
259 struct orinoco_private *priv = ndev_priv(dev); 259 struct orinoco_private *priv = ndev_priv(dev);
260 unsigned long flags; 260 unsigned long flags;
@@ -272,8 +272,9 @@ static int orinoco_open(struct net_device *dev)
272 272
273 return err; 273 return err;
274} 274}
275EXPORT_SYMBOL(orinoco_open);
275 276
276static int orinoco_stop(struct net_device *dev) 277int orinoco_stop(struct net_device *dev)
277{ 278{
278 struct orinoco_private *priv = ndev_priv(dev); 279 struct orinoco_private *priv = ndev_priv(dev);
279 int err = 0; 280 int err = 0;
@@ -281,25 +282,27 @@ static int orinoco_stop(struct net_device *dev)
281 /* We mustn't use orinoco_lock() here, because we need to be 282 /* We mustn't use orinoco_lock() here, because we need to be
282 able to close the interface even if hw_unavailable is set 283 able to close the interface even if hw_unavailable is set
283 (e.g. as we're released after a PC Card removal) */ 284 (e.g. as we're released after a PC Card removal) */
284 spin_lock_irq(&priv->lock); 285 orinoco_lock_irq(priv);
285 286
286 priv->open = 0; 287 priv->open = 0;
287 288
288 err = __orinoco_down(priv); 289 err = __orinoco_down(priv);
289 290
290 spin_unlock_irq(&priv->lock); 291 orinoco_unlock_irq(priv);
291 292
292 return err; 293 return err;
293} 294}
295EXPORT_SYMBOL(orinoco_stop);
294 296
295static struct net_device_stats *orinoco_get_stats(struct net_device *dev) 297struct net_device_stats *orinoco_get_stats(struct net_device *dev)
296{ 298{
297 struct orinoco_private *priv = ndev_priv(dev); 299 struct orinoco_private *priv = ndev_priv(dev);
298 300
299 return &priv->stats; 301 return &priv->stats;
300} 302}
303EXPORT_SYMBOL(orinoco_get_stats);
301 304
302static void orinoco_set_multicast_list(struct net_device *dev) 305void orinoco_set_multicast_list(struct net_device *dev)
303{ 306{
304 struct orinoco_private *priv = ndev_priv(dev); 307 struct orinoco_private *priv = ndev_priv(dev);
305 unsigned long flags; 308 unsigned long flags;
@@ -313,8 +316,9 @@ static void orinoco_set_multicast_list(struct net_device *dev)
313 __orinoco_set_multicast_list(dev); 316 __orinoco_set_multicast_list(dev);
314 orinoco_unlock(priv, &flags); 317 orinoco_unlock(priv, &flags);
315} 318}
319EXPORT_SYMBOL(orinoco_set_multicast_list);
316 320
317static int orinoco_change_mtu(struct net_device *dev, int new_mtu) 321int orinoco_change_mtu(struct net_device *dev, int new_mtu)
318{ 322{
319 struct orinoco_private *priv = ndev_priv(dev); 323 struct orinoco_private *priv = ndev_priv(dev);
320 324
@@ -330,6 +334,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
330 334
331 return 0; 335 return 0;
332} 336}
337EXPORT_SYMBOL(orinoco_change_mtu);
333 338
334/********************************************************************/ 339/********************************************************************/
335/* Tx path */ 340/* Tx path */
@@ -400,8 +405,8 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
400 memset(&desc, 0, sizeof(desc)); 405 memset(&desc, 0, sizeof(desc));
401 406
402 *txcntl = cpu_to_le16(tx_control); 407 *txcntl = cpu_to_le16(tx_control);
403 err = hermes_bap_pwrite(hw, USER_BAP, &desc, sizeof(desc), 408 err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
404 txfid, 0); 409 txfid, 0);
405 if (err) { 410 if (err) {
406 if (net_ratelimit()) 411 if (net_ratelimit())
407 printk(KERN_ERR "%s: Error %d writing Tx " 412 printk(KERN_ERR "%s: Error %d writing Tx "
@@ -414,8 +419,8 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
414 memset(&desc, 0, sizeof(desc)); 419 memset(&desc, 0, sizeof(desc));
415 420
416 desc.tx_control = cpu_to_le16(tx_control); 421 desc.tx_control = cpu_to_le16(tx_control);
417 err = hermes_bap_pwrite(hw, USER_BAP, &desc, sizeof(desc), 422 err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
418 txfid, 0); 423 txfid, 0);
419 if (err) { 424 if (err) {
420 if (net_ratelimit()) 425 if (net_ratelimit())
421 printk(KERN_ERR "%s: Error %d writing Tx " 426 printk(KERN_ERR "%s: Error %d writing Tx "
@@ -458,8 +463,8 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
458 memcpy(eh, &hdr, sizeof(hdr)); 463 memcpy(eh, &hdr, sizeof(hdr));
459 } 464 }
460 465
461 err = hermes_bap_pwrite(hw, USER_BAP, skb->data, skb->len, 466 err = hw->ops->bap_pwrite(hw, USER_BAP, skb->data, skb->len,
462 txfid, HERMES_802_3_OFFSET); 467 txfid, HERMES_802_3_OFFSET);
463 if (err) { 468 if (err) {
464 printk(KERN_ERR "%s: Error %d writing packet to BAP\n", 469 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
465 dev->name, err); 470 dev->name, err);
@@ -490,8 +495,8 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
490 skb->data + ETH_HLEN, skb->len - ETH_HLEN, mic); 495 skb->data + ETH_HLEN, skb->len - ETH_HLEN, mic);
491 496
492 /* Write the MIC */ 497 /* Write the MIC */
493 err = hermes_bap_pwrite(hw, USER_BAP, &mic_buf[0], len, 498 err = hw->ops->bap_pwrite(hw, USER_BAP, &mic_buf[0], len,
494 txfid, HERMES_802_3_OFFSET + offset); 499 txfid, HERMES_802_3_OFFSET + offset);
495 if (err) { 500 if (err) {
496 printk(KERN_ERR "%s: Error %d writing MIC to BAP\n", 501 printk(KERN_ERR "%s: Error %d writing MIC to BAP\n",
497 dev->name, err); 502 dev->name, err);
@@ -502,7 +507,7 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
502 /* Finally, we actually initiate the send */ 507 /* Finally, we actually initiate the send */
503 netif_stop_queue(dev); 508 netif_stop_queue(dev);
504 509
505 err = hermes_docmd_wait(hw, HERMES_CMD_TX | HERMES_CMD_RECL, 510 err = hw->ops->cmd_wait(hw, HERMES_CMD_TX | HERMES_CMD_RECL,
506 txfid, NULL); 511 txfid, NULL);
507 if (err) { 512 if (err) {
508 netif_start_queue(dev); 513 netif_start_queue(dev);
@@ -572,9 +577,9 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
572 return; /* Nothing's really happened */ 577 return; /* Nothing's really happened */
573 578
574 /* Read part of the frame header - we need status and addr1 */ 579 /* Read part of the frame header - we need status and addr1 */
575 err = hermes_bap_pread(hw, IRQ_BAP, &hdr, 580 err = hw->ops->bap_pread(hw, IRQ_BAP, &hdr,
576 sizeof(struct hermes_txexc_data), 581 sizeof(struct hermes_txexc_data),
577 fid, 0); 582 fid, 0);
578 583
579 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID); 584 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
580 stats->tx_errors++; 585 stats->tx_errors++;
@@ -615,7 +620,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
615 netif_wake_queue(dev); 620 netif_wake_queue(dev);
616} 621}
617 622
618static void orinoco_tx_timeout(struct net_device *dev) 623void orinoco_tx_timeout(struct net_device *dev)
619{ 624{
620 struct orinoco_private *priv = ndev_priv(dev); 625 struct orinoco_private *priv = ndev_priv(dev);
621 struct net_device_stats *stats = &priv->stats; 626 struct net_device_stats *stats = &priv->stats;
@@ -630,6 +635,7 @@ static void orinoco_tx_timeout(struct net_device *dev)
630 635
631 schedule_work(&priv->reset_work); 636 schedule_work(&priv->reset_work);
632} 637}
638EXPORT_SYMBOL(orinoco_tx_timeout);
633 639
634/********************************************************************/ 640/********************************************************************/
635/* Rx path (data frames) */ 641/* Rx path (data frames) */
@@ -764,9 +770,9 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
764 770
765 /* If any, copy the data from the card to the skb */ 771 /* If any, copy the data from the card to the skb */
766 if (datalen > 0) { 772 if (datalen > 0) {
767 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, datalen), 773 err = hw->ops->bap_pread(hw, IRQ_BAP, skb_put(skb, datalen),
768 ALIGN(datalen, 2), rxfid, 774 ALIGN(datalen, 2), rxfid,
769 HERMES_802_2_OFFSET); 775 HERMES_802_2_OFFSET);
770 if (err) { 776 if (err) {
771 printk(KERN_ERR "%s: error %d reading monitor frame\n", 777 printk(KERN_ERR "%s: error %d reading monitor frame\n",
772 dev->name, err); 778 dev->name, err);
@@ -792,7 +798,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
792 stats->rx_dropped++; 798 stats->rx_dropped++;
793} 799}
794 800
795static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) 801void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
796{ 802{
797 struct orinoco_private *priv = ndev_priv(dev); 803 struct orinoco_private *priv = ndev_priv(dev);
798 struct net_device_stats *stats = &priv->stats; 804 struct net_device_stats *stats = &priv->stats;
@@ -814,8 +820,8 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
814 820
815 rxfid = hermes_read_regn(hw, RXFID); 821 rxfid = hermes_read_regn(hw, RXFID);
816 822
817 err = hermes_bap_pread(hw, IRQ_BAP, desc, sizeof(*desc), 823 err = hw->ops->bap_pread(hw, IRQ_BAP, desc, sizeof(*desc),
818 rxfid, 0); 824 rxfid, 0);
819 if (err) { 825 if (err) {
820 printk(KERN_ERR "%s: error %d reading Rx descriptor. " 826 printk(KERN_ERR "%s: error %d reading Rx descriptor. "
821 "Frame dropped.\n", dev->name, err); 827 "Frame dropped.\n", dev->name, err);
@@ -882,9 +888,9 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
882 nothing is removed. 2 is for aligning the IP header. */ 888 nothing is removed. 2 is for aligning the IP header. */
883 skb_reserve(skb, ETH_HLEN + 2); 889 skb_reserve(skb, ETH_HLEN + 2);
884 890
885 err = hermes_bap_pread(hw, IRQ_BAP, skb_put(skb, length), 891 err = hw->ops->bap_pread(hw, IRQ_BAP, skb_put(skb, length),
886 ALIGN(length, 2), rxfid, 892 ALIGN(length, 2), rxfid,
887 HERMES_802_2_OFFSET); 893 HERMES_802_2_OFFSET);
888 if (err) { 894 if (err) {
889 printk(KERN_ERR "%s: error %d reading frame. " 895 printk(KERN_ERR "%s: error %d reading frame. "
890 "Frame dropped.\n", dev->name, err); 896 "Frame dropped.\n", dev->name, err);
@@ -913,6 +919,7 @@ update_stats:
913out: 919out:
914 kfree(desc); 920 kfree(desc);
915} 921}
922EXPORT_SYMBOL(__orinoco_ev_rx);
916 923
917static void orinoco_rx(struct net_device *dev, 924static void orinoco_rx(struct net_device *dev,
918 struct hermes_rx_descriptor *desc, 925 struct hermes_rx_descriptor *desc,
@@ -1145,9 +1152,9 @@ static void orinoco_join_ap(struct work_struct *work)
1145 goto out; 1152 goto out;
1146 1153
1147 /* Read scan results from the firmware */ 1154 /* Read scan results from the firmware */
1148 err = hermes_read_ltv(hw, USER_BAP, 1155 err = hw->ops->read_ltv(hw, USER_BAP,
1149 HERMES_RID_SCANRESULTSTABLE, 1156 HERMES_RID_SCANRESULTSTABLE,
1150 MAX_SCAN_LEN, &len, buf); 1157 MAX_SCAN_LEN, &len, buf);
1151 if (err) { 1158 if (err) {
1152 printk(KERN_ERR "%s: Cannot read scan results\n", 1159 printk(KERN_ERR "%s: Cannot read scan results\n",
1153 dev->name); 1160 dev->name);
@@ -1194,8 +1201,8 @@ static void orinoco_send_bssid_wevent(struct orinoco_private *priv)
1194 union iwreq_data wrqu; 1201 union iwreq_data wrqu;
1195 int err; 1202 int err;
1196 1203
1197 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID, 1204 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
1198 ETH_ALEN, NULL, wrqu.ap_addr.sa_data); 1205 ETH_ALEN, NULL, wrqu.ap_addr.sa_data);
1199 if (err != 0) 1206 if (err != 0)
1200 return; 1207 return;
1201 1208
@@ -1217,8 +1224,8 @@ static void orinoco_send_assocreqie_wevent(struct orinoco_private *priv)
1217 if (!priv->has_wpa) 1224 if (!priv->has_wpa)
1218 return; 1225 return;
1219 1226
1220 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_ASSOC_REQ_INFO, 1227 err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_ASSOC_REQ_INFO,
1221 sizeof(buf), NULL, &buf); 1228 sizeof(buf), NULL, &buf);
1222 if (err != 0) 1229 if (err != 0)
1223 return; 1230 return;
1224 1231
@@ -1247,8 +1254,9 @@ static void orinoco_send_assocrespie_wevent(struct orinoco_private *priv)
1247 if (!priv->has_wpa) 1254 if (!priv->has_wpa)
1248 return; 1255 return;
1249 1256
1250 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_ASSOC_RESP_INFO, 1257 err = hw->ops->read_ltv(hw, USER_BAP,
1251 sizeof(buf), NULL, &buf); 1258 HERMES_RID_CURRENT_ASSOC_RESP_INFO,
1259 sizeof(buf), NULL, &buf);
1252 if (err != 0) 1260 if (err != 0)
1253 return; 1261 return;
1254 1262
@@ -1353,7 +1361,7 @@ static void orinoco_process_scan_results(struct work_struct *work)
1353 spin_unlock_irqrestore(&priv->scan_lock, flags); 1361 spin_unlock_irqrestore(&priv->scan_lock, flags);
1354} 1362}
1355 1363
1356static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) 1364void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1357{ 1365{
1358 struct orinoco_private *priv = ndev_priv(dev); 1366 struct orinoco_private *priv = ndev_priv(dev);
1359 u16 infofid; 1367 u16 infofid;
@@ -1371,8 +1379,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1371 infofid = hermes_read_regn(hw, INFOFID); 1379 infofid = hermes_read_regn(hw, INFOFID);
1372 1380
1373 /* Read the info frame header - don't try too hard */ 1381 /* Read the info frame header - don't try too hard */
1374 err = hermes_bap_pread(hw, IRQ_BAP, &info, sizeof(info), 1382 err = hw->ops->bap_pread(hw, IRQ_BAP, &info, sizeof(info),
1375 infofid, 0); 1383 infofid, 0);
1376 if (err) { 1384 if (err) {
1377 printk(KERN_ERR "%s: error %d reading info frame. " 1385 printk(KERN_ERR "%s: error %d reading info frame. "
1378 "Frame dropped.\n", dev->name, err); 1386 "Frame dropped.\n", dev->name, err);
@@ -1393,8 +1401,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1393 len = sizeof(tallies); 1401 len = sizeof(tallies);
1394 } 1402 }
1395 1403
1396 err = hermes_bap_pread(hw, IRQ_BAP, &tallies, len, 1404 err = hw->ops->bap_pread(hw, IRQ_BAP, &tallies, len,
1397 infofid, sizeof(info)); 1405 infofid, sizeof(info));
1398 if (err) 1406 if (err)
1399 break; 1407 break;
1400 1408
@@ -1429,8 +1437,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1429 break; 1437 break;
1430 } 1438 }
1431 1439
1432 err = hermes_bap_pread(hw, IRQ_BAP, &linkstatus, len, 1440 err = hw->ops->bap_pread(hw, IRQ_BAP, &linkstatus, len,
1433 infofid, sizeof(info)); 1441 infofid, sizeof(info));
1434 if (err) 1442 if (err)
1435 break; 1443 break;
1436 newstatus = le16_to_cpu(linkstatus.linkstatus); 1444 newstatus = le16_to_cpu(linkstatus.linkstatus);
@@ -1494,8 +1502,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1494 } 1502 }
1495 1503
1496 /* Read scan data */ 1504 /* Read scan data */
1497 err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len, 1505 err = hw->ops->bap_pread(hw, IRQ_BAP, (void *) buf, len,
1498 infofid, sizeof(info)); 1506 infofid, sizeof(info));
1499 if (err) { 1507 if (err) {
1500 kfree(buf); 1508 kfree(buf);
1501 qabort_scan(priv); 1509 qabort_scan(priv);
@@ -1547,8 +1555,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1547 break; 1555 break;
1548 1556
1549 /* Read scan data */ 1557 /* Read scan data */
1550 err = hermes_bap_pread(hw, IRQ_BAP, (void *) bss, len, 1558 err = hw->ops->bap_pread(hw, IRQ_BAP, (void *) bss, len,
1551 infofid, sizeof(info)); 1559 infofid, sizeof(info));
1552 if (err) 1560 if (err)
1553 kfree(bss); 1561 kfree(bss);
1554 else 1562 else
@@ -1571,6 +1579,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1571 1579
1572 return; 1580 return;
1573} 1581}
1582EXPORT_SYMBOL(__orinoco_ev_info);
1574 1583
1575static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) 1584static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)
1576{ 1585{
@@ -1647,7 +1656,7 @@ static int orinoco_reinit_firmware(struct orinoco_private *priv)
1647 struct hermes *hw = &priv->hw; 1656 struct hermes *hw = &priv->hw;
1648 int err; 1657 int err;
1649 1658
1650 err = hermes_init(hw); 1659 err = hw->ops->init(hw);
1651 if (priv->do_fw_download && !err) { 1660 if (priv->do_fw_download && !err) {
1652 err = orinoco_download(priv); 1661 err = orinoco_download(priv);
1653 if (err) 1662 if (err)
@@ -1735,7 +1744,7 @@ void orinoco_reset(struct work_struct *work)
1735 } 1744 }
1736 1745
1737 /* This has to be called from user context */ 1746 /* This has to be called from user context */
1738 spin_lock_irq(&priv->lock); 1747 orinoco_lock_irq(priv);
1739 1748
1740 priv->hw_unavailable--; 1749 priv->hw_unavailable--;
1741 1750
@@ -1750,7 +1759,7 @@ void orinoco_reset(struct work_struct *work)
1750 dev->trans_start = jiffies; 1759 dev->trans_start = jiffies;
1751 } 1760 }
1752 1761
1753 spin_unlock_irq(&priv->lock); 1762 orinoco_unlock_irq(priv);
1754 1763
1755 return; 1764 return;
1756 disable: 1765 disable:
@@ -1984,7 +1993,7 @@ int orinoco_init(struct orinoco_private *priv)
1984 priv->nicbuf_size = IEEE80211_MAX_FRAME_LEN + ETH_HLEN; 1993 priv->nicbuf_size = IEEE80211_MAX_FRAME_LEN + ETH_HLEN;
1985 1994
1986 /* Initialize the firmware */ 1995 /* Initialize the firmware */
1987 err = hermes_init(hw); 1996 err = hw->ops->init(hw);
1988 if (err != 0) { 1997 if (err != 0) {
1989 dev_err(dev, "Failed to initialize firmware (err = %d)\n", 1998 dev_err(dev, "Failed to initialize firmware (err = %d)\n",
1990 err); 1999 err);
@@ -2067,9 +2076,9 @@ int orinoco_init(struct orinoco_private *priv)
2067 2076
2068 /* Make the hardware available, as long as it hasn't been 2077 /* Make the hardware available, as long as it hasn't been
2069 * removed elsewhere (e.g. by PCMCIA hot unplug) */ 2078 * removed elsewhere (e.g. by PCMCIA hot unplug) */
2070 spin_lock_irq(&priv->lock); 2079 orinoco_lock_irq(priv);
2071 priv->hw_unavailable--; 2080 priv->hw_unavailable--;
2072 spin_unlock_irq(&priv->lock); 2081 orinoco_unlock_irq(priv);
2073 2082
2074 dev_dbg(dev, "Ready\n"); 2083 dev_dbg(dev, "Ready\n");
2075 2084
@@ -2192,7 +2201,8 @@ EXPORT_SYMBOL(alloc_orinocodev);
2192 */ 2201 */
2193int orinoco_if_add(struct orinoco_private *priv, 2202int orinoco_if_add(struct orinoco_private *priv,
2194 unsigned long base_addr, 2203 unsigned long base_addr,
2195 unsigned int irq) 2204 unsigned int irq,
2205 const struct net_device_ops *ops)
2196{ 2206{
2197 struct wiphy *wiphy = priv_to_wiphy(priv); 2207 struct wiphy *wiphy = priv_to_wiphy(priv);
2198 struct wireless_dev *wdev; 2208 struct wireless_dev *wdev;
@@ -2211,12 +2221,17 @@ int orinoco_if_add(struct orinoco_private *priv,
2211 2221
2212 /* Setup / override net_device fields */ 2222 /* Setup / override net_device fields */
2213 dev->ieee80211_ptr = wdev; 2223 dev->ieee80211_ptr = wdev;
2214 dev->netdev_ops = &orinoco_netdev_ops;
2215 dev->watchdog_timeo = HZ; /* 1 second timeout */ 2224 dev->watchdog_timeo = HZ; /* 1 second timeout */
2216 dev->wireless_handlers = &orinoco_handler_def; 2225 dev->wireless_handlers = &orinoco_handler_def;
2217#ifdef WIRELESS_SPY 2226#ifdef WIRELESS_SPY
2218 dev->wireless_data = &priv->wireless_data; 2227 dev->wireless_data = &priv->wireless_data;
2219#endif 2228#endif
2229 /* Default to standard ops if not set */
2230 if (ops)
2231 dev->netdev_ops = ops;
2232 else
2233 dev->netdev_ops = &orinoco_netdev_ops;
2234
2220 /* we use the default eth_mac_addr for setting the MAC addr */ 2235 /* we use the default eth_mac_addr for setting the MAC addr */
2221 2236
2222 /* Reserve space in skb for the SNAP header */ 2237 /* Reserve space in skb for the SNAP header */
@@ -2305,7 +2320,7 @@ int orinoco_up(struct orinoco_private *priv)
2305 unsigned long flags; 2320 unsigned long flags;
2306 int err; 2321 int err;
2307 2322
2308 spin_lock_irqsave(&priv->lock, flags); 2323 priv->hw.ops->lock_irqsave(&priv->lock, &flags);
2309 2324
2310 err = orinoco_reinit_firmware(priv); 2325 err = orinoco_reinit_firmware(priv);
2311 if (err) { 2326 if (err) {
@@ -2325,7 +2340,7 @@ int orinoco_up(struct orinoco_private *priv)
2325 } 2340 }
2326 2341
2327exit: 2342exit:
2328 spin_unlock_irqrestore(&priv->lock, flags); 2343 priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
2329 2344
2330 return 0; 2345 return 0;
2331} 2346}
@@ -2337,7 +2352,7 @@ void orinoco_down(struct orinoco_private *priv)
2337 unsigned long flags; 2352 unsigned long flags;
2338 int err; 2353 int err;
2339 2354
2340 spin_lock_irqsave(&priv->lock, flags); 2355 priv->hw.ops->lock_irqsave(&priv->lock, &flags);
2341 err = __orinoco_down(priv); 2356 err = __orinoco_down(priv);
2342 if (err) 2357 if (err)
2343 printk(KERN_WARNING "%s: Error %d downing interface\n", 2358 printk(KERN_WARNING "%s: Error %d downing interface\n",
@@ -2345,7 +2360,7 @@ void orinoco_down(struct orinoco_private *priv)
2345 2360
2346 netif_device_detach(dev); 2361 netif_device_detach(dev);
2347 priv->hw_unavailable++; 2362 priv->hw_unavailable++;
2348 spin_unlock_irqrestore(&priv->lock, flags); 2363 priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
2349} 2364}
2350EXPORT_SYMBOL(orinoco_down); 2365EXPORT_SYMBOL(orinoco_down);
2351 2366
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index ff6b7b1d421..e9f415a56d4 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -190,12 +190,24 @@ extern void free_orinocodev(struct orinoco_private *priv);
190extern int orinoco_init(struct orinoco_private *priv); 190extern int orinoco_init(struct orinoco_private *priv);
191extern int orinoco_if_add(struct orinoco_private *priv, 191extern int orinoco_if_add(struct orinoco_private *priv,
192 unsigned long base_addr, 192 unsigned long base_addr,
193 unsigned int irq); 193 unsigned int irq,
194 const struct net_device_ops *ops);
194extern void orinoco_if_del(struct orinoco_private *priv); 195extern void orinoco_if_del(struct orinoco_private *priv);
195extern int orinoco_up(struct orinoco_private *priv); 196extern int orinoco_up(struct orinoco_private *priv);
196extern void orinoco_down(struct orinoco_private *priv); 197extern void orinoco_down(struct orinoco_private *priv);
197extern irqreturn_t orinoco_interrupt(int irq, void *dev_id); 198extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
198 199
200extern void __orinoco_ev_info(struct net_device *dev, hermes_t *hw);
201extern void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw);
202
203/* Common ndo functions exported for reuse by orinoco_usb */
204int orinoco_open(struct net_device *dev);
205int orinoco_stop(struct net_device *dev);
206struct net_device_stats *orinoco_get_stats(struct net_device *dev);
207void orinoco_set_multicast_list(struct net_device *dev);
208int orinoco_change_mtu(struct net_device *dev, int new_mtu);
209void orinoco_tx_timeout(struct net_device *dev);
210
199/********************************************************************/ 211/********************************************************************/
200/* Locking and synchronization functions */ 212/* Locking and synchronization functions */
201/********************************************************************/ 213/********************************************************************/
@@ -203,11 +215,11 @@ extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
203static inline int orinoco_lock(struct orinoco_private *priv, 215static inline int orinoco_lock(struct orinoco_private *priv,
204 unsigned long *flags) 216 unsigned long *flags)
205{ 217{
206 spin_lock_irqsave(&priv->lock, *flags); 218 priv->hw.ops->lock_irqsave(&priv->lock, flags);
207 if (priv->hw_unavailable) { 219 if (priv->hw_unavailable) {
208 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n", 220 DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
209 priv->ndev); 221 priv->ndev);
210 spin_unlock_irqrestore(&priv->lock, *flags); 222 priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
211 return -EBUSY; 223 return -EBUSY;
212 } 224 }
213 return 0; 225 return 0;
@@ -216,7 +228,17 @@ static inline int orinoco_lock(struct orinoco_private *priv,
216static inline void orinoco_unlock(struct orinoco_private *priv, 228static inline void orinoco_unlock(struct orinoco_private *priv,
217 unsigned long *flags) 229 unsigned long *flags)
218{ 230{
219 spin_unlock_irqrestore(&priv->lock, *flags); 231 priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
232}
233
234static inline void orinoco_lock_irq(struct orinoco_private *priv)
235{
236 priv->hw.ops->lock_irq(&priv->lock);
237}
238
239static inline void orinoco_unlock_irq(struct orinoco_private *priv)
240{
241 priv->hw.ops->unlock_irq(&priv->lock);
220} 242}
221 243
222/*** Navigate from net_device to orinoco_private ***/ 244/*** Navigate from net_device to orinoco_private ***/
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index fdc96137917..f99b13ba92b 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -296,7 +296,7 @@ orinoco_cs_config(struct pcmcia_device *link)
296 296
297 /* Register an interface with the stack */ 297 /* Register an interface with the stack */
298 if (orinoco_if_add(priv, link->io.BasePort1, 298 if (orinoco_if_add(priv, link->io.BasePort1,
299 link->irq.AssignedIRQ) != 0) { 299 link->irq.AssignedIRQ, NULL) != 0) {
300 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 300 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
301 goto failed; 301 goto failed;
302 } 302 }
@@ -327,9 +327,9 @@ orinoco_cs_release(struct pcmcia_device *link)
327 327
328 /* We're committed to taking the device away now, so mark the 328 /* We're committed to taking the device away now, so mark the
329 * hardware as unavailable */ 329 * hardware as unavailable */
330 spin_lock_irqsave(&priv->lock, flags); 330 priv->hw.ops->lock_irqsave(&priv->lock, &flags);
331 priv->hw_unavailable++; 331 priv->hw_unavailable++;
332 spin_unlock_irqrestore(&priv->lock, flags); 332 priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
333 333
334 pcmcia_disable_device(link); 334 pcmcia_disable_device(link);
335 if (priv->hw.iobase) 335 if (priv->hw.iobase)
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index 075f446b313..bc3ea0b67a4 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -220,7 +220,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
220 goto fail; 220 goto fail;
221 } 221 }
222 222
223 err = orinoco_if_add(priv, 0, 0); 223 err = orinoco_if_add(priv, 0, 0, NULL);
224 if (err) { 224 if (err) {
225 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 225 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
226 goto fail; 226 goto fail;
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index bda5317cc59..468197f8667 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -170,7 +170,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
170 goto fail; 170 goto fail;
171 } 171 }
172 172
173 err = orinoco_if_add(priv, 0, 0); 173 err = orinoco_if_add(priv, 0, 0, NULL);
174 if (err) { 174 if (err) {
175 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 175 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
176 goto fail; 176 goto fail;
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index e0d5874ab42..9358f4d2307 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -259,7 +259,7 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
259 goto fail; 259 goto fail;
260 } 260 }
261 261
262 err = orinoco_if_add(priv, 0, 0); 262 err = orinoco_if_add(priv, 0, 0, NULL);
263 if (err) { 263 if (err) {
264 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 264 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
265 goto fail; 265 goto fail;
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index 88cbc7902aa..784605f0af1 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -156,7 +156,7 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
156 goto fail; 156 goto fail;
157 } 157 }
158 158
159 err = orinoco_if_add(priv, 0, 0); 159 err = orinoco_if_add(priv, 0, 0, NULL);
160 if (err) { 160 if (err) {
161 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 161 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
162 goto fail; 162 goto fail;
diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
new file mode 100644
index 00000000000..e22093359f3
--- /dev/null
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -0,0 +1,1800 @@
1/*
2 * USB Orinoco driver
3 *
4 * Copyright (c) 2003 Manuel Estrada Sainz
5 *
6 * The contents of this file are subject to the Mozilla Public License
7 * Version 1.1 (the "License"); you may not use this file except in
8 * compliance with the License. You may obtain a copy of the License
9 * at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS"
12 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
13 * the License for the specific language governing rights and
14 * limitations under the License.
15 *
16 * Alternatively, the contents of this file may be used under the
17 * terms of the GNU General Public License version 2 (the "GPL"), in
18 * which case the provisions of the GPL are applicable instead of the
19 * above. If you wish to allow the use of your version of this file
20 * only under the terms of the GPL and not to allow others to use your
21 * version of this file under the MPL, indicate your decision by
22 * deleting the provisions above and replace them with the notice and
23 * other provisions required by the GPL. If you do not delete the
24 * provisions above, a recipient may use your version of this file
25 * under either the MPL or the GPL.
26 *
27 * Queueing code based on linux-wlan-ng 0.2.1-pre5
28 *
29 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
30 *
31 * The license is the same as above.
32 *
33 * Initialy based on USB Skeleton driver - 0.7
34 *
35 * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
36 *
37 * This program is free software; you can redistribute it and/or
38 * modify it under the terms of the GNU General Public License as
39 * published by the Free Software Foundation; either version 2 of
40 * the License, or (at your option) any later version.
41 *
42 * NOTE: The original USB Skeleton driver is GPL, but all that code is
43 * gone so MPL/GPL applies.
44 */
45
46#define DRIVER_NAME "orinoco_usb"
47#define PFX DRIVER_NAME ": "
48
49#include <linux/module.h>
50#include <linux/kernel.h>
51#include <linux/sched.h>
52#include <linux/signal.h>
53#include <linux/errno.h>
54#include <linux/poll.h>
55#include <linux/init.h>
56#include <linux/slab.h>
57#include <linux/fcntl.h>
58#include <linux/spinlock.h>
59#include <linux/list.h>
60#include <linux/smp_lock.h>
61#include <linux/usb.h>
62#include <linux/timer.h>
63
64#include <linux/netdevice.h>
65#include <linux/if_arp.h>
66#include <linux/etherdevice.h>
67#include <linux/wireless.h>
68#include <linux/firmware.h>
69
70#include "orinoco.h"
71
72#ifndef URB_ASYNC_UNLINK
73#define URB_ASYNC_UNLINK 0
74#endif
75
76/* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
77static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
78#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
79
80struct header_struct {
81 /* 802.3 */
82 u8 dest[ETH_ALEN];
83 u8 src[ETH_ALEN];
84 __be16 len;
85 /* 802.2 */
86 u8 dsap;
87 u8 ssap;
88 u8 ctrl;
89 /* SNAP */
90 u8 oui[3];
91 __be16 ethertype;
92} __attribute__ ((packed));
93
94struct ez_usb_fw {
95 u16 size;
96 const u8 *code;
97};
98
99static struct ez_usb_fw firmware = {
100 .size = 0,
101 .code = NULL,
102};
103
104#ifdef CONFIG_USB_DEBUG
105static int debug = 1;
106#else
107static int debug;
108#endif
109
110/* Debugging macros */
111#undef dbg
112#define dbg(format, arg...) \
113 do { if (debug) printk(KERN_DEBUG PFX "%s: " format "\n", \
114 __func__ , ## arg); } while (0)
115#undef err
116#define err(format, arg...) \
117 do { printk(KERN_ERR PFX format "\n", ## arg); } while (0)
118
119/* Module paramaters */
120module_param(debug, int, 0644);
121MODULE_PARM_DESC(debug, "Debug enabled or not");
122
123MODULE_FIRMWARE("orinoco_ezusb_fw");
124
125/*
126 * Under some conditions, the card gets stuck and stops paying attention
127 * to the world (i.e. data communication stalls) until we do something to
128 * it. Sending an INQ_TALLIES command seems to be enough and should be
129 * harmless otherwise. This behaviour has been observed when using the
130 * driver on a systemimager client during installation. In the past a
131 * timer was used to send INQ_TALLIES commands when there was no other
132 * activity, but it was troublesome and was removed.
133 */
134
135#define USB_COMPAQ_VENDOR_ID 0x049f /* Compaq Computer Corp. */
136#define USB_COMPAQ_WL215_ID 0x001f /* Compaq WL215 USB Adapter */
137#define USB_COMPAQ_W200_ID 0x0076 /* Compaq W200 USB Adapter */
138#define USB_HP_WL215_ID 0x0082 /* Compaq WL215 USB Adapter */
139
140#define USB_MELCO_VENDOR_ID 0x0411
141#define USB_BUFFALO_L11_ID 0x0006 /* BUFFALO WLI-USB-L11 */
142#define USB_BUFFALO_L11G_WR_ID 0x000B /* BUFFALO WLI-USB-L11G-WR */
143#define USB_BUFFALO_L11G_ID 0x000D /* BUFFALO WLI-USB-L11G */
144
145#define USB_LUCENT_VENDOR_ID 0x047E /* Lucent Technologies */
146#define USB_LUCENT_ORINOCO_ID 0x0300 /* Lucent/Agere Orinoco USB Client */
147
148#define USB_AVAYA8_VENDOR_ID 0x0D98
149#define USB_AVAYAE_VENDOR_ID 0x0D9E
150#define USB_AVAYA_WIRELESS_ID 0x0300 /* Avaya Wireless USB Card */
151
152#define USB_AGERE_VENDOR_ID 0x0D4E /* Agere Systems */
153#define USB_AGERE_MODEL0801_ID 0x1000 /* Wireless USB Card Model 0801 */
154#define USB_AGERE_MODEL0802_ID 0x1001 /* Wireless USB Card Model 0802 */
155#define USB_AGERE_REBRANDED_ID 0x047A /* WLAN USB Card */
156
157#define USB_ELSA_VENDOR_ID 0x05CC
158#define USB_ELSA_AIRLANCER_ID 0x3100 /* ELSA AirLancer USB-11 */
159
160#define USB_LEGEND_VENDOR_ID 0x0E7C
161#define USB_LEGEND_JOYNET_ID 0x0300 /* Joynet WLAN USB Card */
162
163#define USB_SAMSUNG_VENDOR_ID 0x04E8
164#define USB_SAMSUNG_SEW2001U1_ID 0x5002 /* Samsung SEW-2001u Card */
165#define USB_SAMSUNG_SEW2001U2_ID 0x5B11 /* Samsung SEW-2001u Card */
166#define USB_SAMSUNG_SEW2003U_ID 0x7011 /* Samsung SEW-2003U Card */
167
168#define USB_IGATE_VENDOR_ID 0x0681
169#define USB_IGATE_IGATE_11M_ID 0x0012 /* I-GATE 11M USB Card */
170
171#define USB_FUJITSU_VENDOR_ID 0x0BF8
172#define USB_FUJITSU_E1100_ID 0x1002 /* connect2AIR WLAN E-1100 USB */
173
174#define USB_2WIRE_VENDOR_ID 0x1630
175#define USB_2WIRE_WIRELESS_ID 0xff81 /* 2Wire Wireless USB adapter */
176
177
178#define EZUSB_REQUEST_FW_TRANS 0xA0
179#define EZUSB_REQUEST_TRIGER 0xAA
180#define EZUSB_REQUEST_TRIG_AC 0xAC
181#define EZUSB_CPUCS_REG 0x7F92
182
183#define EZUSB_RID_TX 0x0700
184#define EZUSB_RID_RX 0x0701
185#define EZUSB_RID_INIT1 0x0702
186#define EZUSB_RID_ACK 0x0710
187#define EZUSB_RID_READ_PDA 0x0800
188#define EZUSB_RID_PROG_INIT 0x0852
189#define EZUSB_RID_PROG_SET_ADDR 0x0853
190#define EZUSB_RID_PROG_BYTES 0x0854
191#define EZUSB_RID_PROG_END 0x0855
192#define EZUSB_RID_DOCMD 0x0860
193
194/* Recognize info frames */
195#define EZUSB_IS_INFO(id) ((id >= 0xF000) && (id <= 0xF2FF))
196
197#define EZUSB_MAGIC 0x0210
198
199#define EZUSB_FRAME_DATA 1
200#define EZUSB_FRAME_CONTROL 2
201
202#define DEF_TIMEOUT (3*HZ)
203
204#define BULK_BUF_SIZE 2048
205
206#define MAX_DL_SIZE (BULK_BUF_SIZE - sizeof(struct ezusb_packet))
207
208#define FW_BUF_SIZE 64
209#define FW_VAR_OFFSET_PTR 0x359
210#define FW_VAR_VALUE 0
211#define FW_HOLE_START 0x100
212#define FW_HOLE_END 0x300
213
214struct ezusb_packet {
215 __le16 magic; /* 0x0210 */
216 u8 req_reply_count;
217 u8 ans_reply_count;
218 __le16 frame_type; /* 0x01 for data frames, 0x02 otherwise */
219 __le16 size; /* transport size */
220 __le16 crc; /* CRC up to here */
221 __le16 hermes_len;
222 __le16 hermes_rid;
223 u8 data[0];
224} __attribute__ ((packed));
225
226/* Table of devices that work or may work with this driver */
227static struct usb_device_id ezusb_table[] = {
228 {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_WL215_ID)},
229 {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_HP_WL215_ID)},
230 {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_W200_ID)},
231 {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11_ID)},
232 {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_WR_ID)},
233 {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_ID)},
234 {USB_DEVICE(USB_LUCENT_VENDOR_ID, USB_LUCENT_ORINOCO_ID)},
235 {USB_DEVICE(USB_AVAYA8_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
236 {USB_DEVICE(USB_AVAYAE_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
237 {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0801_ID)},
238 {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0802_ID)},
239 {USB_DEVICE(USB_ELSA_VENDOR_ID, USB_ELSA_AIRLANCER_ID)},
240 {USB_DEVICE(USB_LEGEND_VENDOR_ID, USB_LEGEND_JOYNET_ID)},
241 {USB_DEVICE_VER(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U1_ID,
242 0, 0)},
243 {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U2_ID)},
244 {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2003U_ID)},
245 {USB_DEVICE(USB_IGATE_VENDOR_ID, USB_IGATE_IGATE_11M_ID)},
246 {USB_DEVICE(USB_FUJITSU_VENDOR_ID, USB_FUJITSU_E1100_ID)},
247 {USB_DEVICE(USB_2WIRE_VENDOR_ID, USB_2WIRE_WIRELESS_ID)},
248 {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_REBRANDED_ID)},
249 {} /* Terminating entry */
250};
251
252MODULE_DEVICE_TABLE(usb, ezusb_table);
253
254/* Structure to hold all of our device specific stuff */
255struct ezusb_priv {
256 struct usb_device *udev;
257 struct net_device *dev;
258 struct mutex mtx;
259 spinlock_t req_lock;
260 struct list_head req_pending;
261 struct list_head req_active;
262 spinlock_t reply_count_lock;
263 u16 hermes_reg_fake[0x40];
264 u8 *bap_buf;
265 struct urb *read_urb;
266 int read_pipe;
267 int write_pipe;
268 u8 reply_count;
269};
270
271enum ezusb_state {
272 EZUSB_CTX_START,
273 EZUSB_CTX_QUEUED,
274 EZUSB_CTX_REQ_SUBMITTED,
275 EZUSB_CTX_REQ_COMPLETE,
276 EZUSB_CTX_RESP_RECEIVED,
277 EZUSB_CTX_REQ_TIMEOUT,
278 EZUSB_CTX_REQ_FAILED,
279 EZUSB_CTX_RESP_TIMEOUT,
280 EZUSB_CTX_REQSUBMIT_FAIL,
281 EZUSB_CTX_COMPLETE,
282};
283
284struct request_context {
285 struct list_head list;
286 atomic_t refcount;
287 struct completion done; /* Signals that CTX is dead */
288 int killed;
289 struct urb *outurb; /* OUT for req pkt */
290 struct ezusb_priv *upriv;
291 struct ezusb_packet *buf;
292 int buf_length;
293 struct timer_list timer; /* Timeout handling */
294 enum ezusb_state state; /* Current state */
295 /* the RID that we will wait for */
296 u16 out_rid;
297 u16 in_rid;
298};
299
300
301/* Forward declarations */
302static void ezusb_ctx_complete(struct request_context *ctx);
303static void ezusb_req_queue_run(struct ezusb_priv *upriv);
304static void ezusb_bulk_in_callback(struct urb *urb);
305
306static inline u8 ezusb_reply_inc(u8 count)
307{
308 if (count < 0x7F)
309 return count + 1;
310 else
311 return 1;
312}
313
314static void ezusb_request_context_put(struct request_context *ctx)
315{
316 if (!atomic_dec_and_test(&ctx->refcount))
317 return;
318
319 WARN_ON(!ctx->done.done);
320 BUG_ON(ctx->outurb->status == -EINPROGRESS);
321 BUG_ON(timer_pending(&ctx->timer));
322 usb_free_urb(ctx->outurb);
323 kfree(ctx->buf);
324 kfree(ctx);
325}
326
327static inline void ezusb_mod_timer(struct ezusb_priv *upriv,
328 struct timer_list *timer,
329 unsigned long expire)
330{
331 if (!upriv->udev)
332 return;
333 mod_timer(timer, expire);
334}
335
336static void ezusb_request_timerfn(u_long _ctx)
337{
338 struct request_context *ctx = (void *) _ctx;
339
340 ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
341 if (usb_unlink_urb(ctx->outurb) == -EINPROGRESS) {
342 ctx->state = EZUSB_CTX_REQ_TIMEOUT;
343 } else {
344 ctx->state = EZUSB_CTX_RESP_TIMEOUT;
345 dbg("couldn't unlink");
346 atomic_inc(&ctx->refcount);
347 ctx->killed = 1;
348 ezusb_ctx_complete(ctx);
349 ezusb_request_context_put(ctx);
350 }
351};
352
353static struct request_context *ezusb_alloc_ctx(struct ezusb_priv *upriv,
354 u16 out_rid, u16 in_rid)
355{
356 struct request_context *ctx;
357
358 ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
359 if (!ctx)
360 return NULL;
361
362 memset(ctx, 0, sizeof(*ctx));
363
364 ctx->buf = kmalloc(BULK_BUF_SIZE, GFP_ATOMIC);
365 if (!ctx->buf) {
366 kfree(ctx);
367 return NULL;
368 }
369 ctx->outurb = usb_alloc_urb(0, GFP_ATOMIC);
370 if (!ctx->outurb) {
371 kfree(ctx->buf);
372 kfree(ctx);
373 return NULL;
374 }
375
376 ctx->upriv = upriv;
377 ctx->state = EZUSB_CTX_START;
378 ctx->out_rid = out_rid;
379 ctx->in_rid = in_rid;
380
381 atomic_set(&ctx->refcount, 1);
382 init_completion(&ctx->done);
383
384 init_timer(&ctx->timer);
385 ctx->timer.function = ezusb_request_timerfn;
386 ctx->timer.data = (u_long) ctx;
387 return ctx;
388}
389
390
391/* Hopefully the real complete_all will soon be exported, in the mean
392 * while this should work. */
393static inline void ezusb_complete_all(struct completion *comp)
394{
395 complete(comp);
396 complete(comp);
397 complete(comp);
398 complete(comp);
399}
400
401static void ezusb_ctx_complete(struct request_context *ctx)
402{
403 struct ezusb_priv *upriv = ctx->upriv;
404 unsigned long flags;
405
406 spin_lock_irqsave(&upriv->req_lock, flags);
407
408 list_del_init(&ctx->list);
409 if (upriv->udev) {
410 spin_unlock_irqrestore(&upriv->req_lock, flags);
411 ezusb_req_queue_run(upriv);
412 spin_lock_irqsave(&upriv->req_lock, flags);
413 }
414
415 switch (ctx->state) {
416 case EZUSB_CTX_COMPLETE:
417 case EZUSB_CTX_REQSUBMIT_FAIL:
418 case EZUSB_CTX_REQ_FAILED:
419 case EZUSB_CTX_REQ_TIMEOUT:
420 case EZUSB_CTX_RESP_TIMEOUT:
421 spin_unlock_irqrestore(&upriv->req_lock, flags);
422
423 if ((ctx->out_rid == EZUSB_RID_TX) && upriv->dev) {
424 struct net_device *dev = upriv->dev;
425 struct orinoco_private *priv = ndev_priv(dev);
426 struct net_device_stats *stats = &priv->stats;
427
428 if (ctx->state != EZUSB_CTX_COMPLETE)
429 stats->tx_errors++;
430 else
431 stats->tx_packets++;
432
433 netif_wake_queue(dev);
434 }
435 ezusb_complete_all(&ctx->done);
436 ezusb_request_context_put(ctx);
437 break;
438
439 default:
440 spin_unlock_irqrestore(&upriv->req_lock, flags);
441 if (!upriv->udev) {
442 /* This is normal, as all request contexts get flushed
443 * when the device is disconnected */
444 err("Called, CTX not terminating, but device gone");
445 ezusb_complete_all(&ctx->done);
446 ezusb_request_context_put(ctx);
447 break;
448 }
449
450 err("Called, CTX not in terminating state.");
451 /* Things are really bad if this happens. Just leak
452 * the CTX because it may still be linked to the
453 * queue or the OUT urb may still be active.
454 * Just leaking at least prevents an Oops or Panic.
455 */
456 break;
457 }
458}
459
460/**
461 * ezusb_req_queue_run:
462 * Description:
463 * Note: Only one active CTX at any one time, because there's no
464 * other (reliable) way to match the response URB to the correct
465 * CTX.
466 **/
467static void ezusb_req_queue_run(struct ezusb_priv *upriv)
468{
469 unsigned long flags;
470 struct request_context *ctx;
471 int result;
472
473 spin_lock_irqsave(&upriv->req_lock, flags);
474
475 if (!list_empty(&upriv->req_active))
476 goto unlock;
477
478 if (list_empty(&upriv->req_pending))
479 goto unlock;
480
481 ctx =
482 list_entry(upriv->req_pending.next, struct request_context,
483 list);
484
485 if (!ctx->upriv->udev)
486 goto unlock;
487
488 /* We need to split this off to avoid a race condition */
489 list_move_tail(&ctx->list, &upriv->req_active);
490
491 if (ctx->state == EZUSB_CTX_QUEUED) {
492 atomic_inc(&ctx->refcount);
493 result = usb_submit_urb(ctx->outurb, GFP_ATOMIC);
494 if (result) {
495 ctx->state = EZUSB_CTX_REQSUBMIT_FAIL;
496
497 spin_unlock_irqrestore(&upriv->req_lock, flags);
498
499 err("Fatal, failed to submit command urb."
500 " error=%d\n", result);
501
502 ezusb_ctx_complete(ctx);
503 ezusb_request_context_put(ctx);
504 goto done;
505 }
506
507 ctx->state = EZUSB_CTX_REQ_SUBMITTED;
508 ezusb_mod_timer(ctx->upriv, &ctx->timer,
509 jiffies + DEF_TIMEOUT);
510 }
511
512 unlock:
513 spin_unlock_irqrestore(&upriv->req_lock, flags);
514
515 done:
516 return;
517}
518
519static void ezusb_req_enqueue_run(struct ezusb_priv *upriv,
520 struct request_context *ctx)
521{
522 unsigned long flags;
523
524 spin_lock_irqsave(&upriv->req_lock, flags);
525
526 if (!ctx->upriv->udev) {
527 spin_unlock_irqrestore(&upriv->req_lock, flags);
528 goto done;
529 }
530 atomic_inc(&ctx->refcount);
531 list_add_tail(&ctx->list, &upriv->req_pending);
532 spin_unlock_irqrestore(&upriv->req_lock, flags);
533
534 ctx->state = EZUSB_CTX_QUEUED;
535 ezusb_req_queue_run(upriv);
536
537 done:
538 return;
539}
540
541static void ezusb_request_out_callback(struct urb *urb)
542{
543 unsigned long flags;
544 enum ezusb_state state;
545 struct request_context *ctx = urb->context;
546 struct ezusb_priv *upriv = ctx->upriv;
547
548 spin_lock_irqsave(&upriv->req_lock, flags);
549
550 del_timer(&ctx->timer);
551
552 if (ctx->killed) {
553 spin_unlock_irqrestore(&upriv->req_lock, flags);
554 pr_warning("interrupt called with dead ctx");
555 goto out;
556 }
557
558 state = ctx->state;
559
560 if (urb->status == 0) {
561 switch (state) {
562 case EZUSB_CTX_REQ_SUBMITTED:
563 if (ctx->in_rid) {
564 ctx->state = EZUSB_CTX_REQ_COMPLETE;
565 /* reply URB still pending */
566 ezusb_mod_timer(upriv, &ctx->timer,
567 jiffies + DEF_TIMEOUT);
568 spin_unlock_irqrestore(&upriv->req_lock,
569 flags);
570 break;
571 }
572 /* fall through */
573 case EZUSB_CTX_RESP_RECEIVED:
574 /* IN already received before this OUT-ACK */
575 ctx->state = EZUSB_CTX_COMPLETE;
576 spin_unlock_irqrestore(&upriv->req_lock, flags);
577 ezusb_ctx_complete(ctx);
578 break;
579
580 default:
581 spin_unlock_irqrestore(&upriv->req_lock, flags);
582 err("Unexpected state(0x%x, %d) in OUT URB",
583 state, urb->status);
584 break;
585 }
586 } else {
587 /* If someone cancels the OUT URB then its status
588 * should be either -ECONNRESET or -ENOENT.
589 */
590 switch (state) {
591 case EZUSB_CTX_REQ_SUBMITTED:
592 case EZUSB_CTX_RESP_RECEIVED:
593 ctx->state = EZUSB_CTX_REQ_FAILED;
594 /* fall through */
595
596 case EZUSB_CTX_REQ_FAILED:
597 case EZUSB_CTX_REQ_TIMEOUT:
598 spin_unlock_irqrestore(&upriv->req_lock, flags);
599
600 ezusb_ctx_complete(ctx);
601 break;
602
603 default:
604 spin_unlock_irqrestore(&upriv->req_lock, flags);
605
606 err("Unexpected state(0x%x, %d) in OUT URB",
607 state, urb->status);
608 break;
609 }
610 }
611 out:
612 ezusb_request_context_put(ctx);
613}
614
615static void ezusb_request_in_callback(struct ezusb_priv *upriv,
616 struct urb *urb)
617{
618 struct ezusb_packet *ans = urb->transfer_buffer;
619 struct request_context *ctx = NULL;
620 enum ezusb_state state;
621 unsigned long flags;
622
623 /* Find the CTX on the active queue that requested this URB */
624 spin_lock_irqsave(&upriv->req_lock, flags);
625 if (upriv->udev) {
626 struct list_head *item;
627
628 list_for_each(item, &upriv->req_active) {
629 struct request_context *c;
630 int reply_count;
631
632 c = list_entry(item, struct request_context, list);
633 reply_count =
634 ezusb_reply_inc(c->buf->req_reply_count);
635 if ((ans->ans_reply_count == reply_count)
636 && (le16_to_cpu(ans->hermes_rid) == c->in_rid)) {
637 ctx = c;
638 break;
639 }
640 dbg("Skipped (0x%x/0x%x) (%d/%d)",
641 le16_to_cpu(ans->hermes_rid),
642 c->in_rid, ans->ans_reply_count, reply_count);
643 }
644 }
645
646 if (ctx == NULL) {
647 spin_unlock_irqrestore(&upriv->req_lock, flags);
648 err("%s: got unexpected RID: 0x%04X", __func__,
649 le16_to_cpu(ans->hermes_rid));
650 ezusb_req_queue_run(upriv);
651 return;
652 }
653
654 /* The data we want is in the in buffer, exchange */
655 urb->transfer_buffer = ctx->buf;
656 ctx->buf = (void *) ans;
657 ctx->buf_length = urb->actual_length;
658
659 state = ctx->state;
660 switch (state) {
661 case EZUSB_CTX_REQ_SUBMITTED:
662 /* We have received our response URB before
663 * our request has been acknowledged. Do NOT
664 * destroy our CTX yet, because our OUT URB
665 * is still alive ...
666 */
667 ctx->state = EZUSB_CTX_RESP_RECEIVED;
668 spin_unlock_irqrestore(&upriv->req_lock, flags);
669
670 /* Let the machine continue running. */
671 break;
672
673 case EZUSB_CTX_REQ_COMPLETE:
674 /* This is the usual path: our request
675 * has already been acknowledged, and
676 * we have now received the reply.
677 */
678 ctx->state = EZUSB_CTX_COMPLETE;
679
680 /* Stop the intimer */
681 del_timer(&ctx->timer);
682 spin_unlock_irqrestore(&upriv->req_lock, flags);
683
684 /* Call the completion handler */
685 ezusb_ctx_complete(ctx);
686 break;
687
688 default:
689 spin_unlock_irqrestore(&upriv->req_lock, flags);
690
691 pr_warning("Matched IN URB, unexpected context state(0x%x)",
692 state);
693 /* Throw this CTX away and try submitting another */
694 del_timer(&ctx->timer);
695 ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
696 usb_unlink_urb(ctx->outurb);
697 ezusb_req_queue_run(upriv);
698 break;
699 } /* switch */
700}
701
702
703static void ezusb_req_ctx_wait(struct ezusb_priv *upriv,
704 struct request_context *ctx)
705{
706 switch (ctx->state) {
707 case EZUSB_CTX_QUEUED:
708 case EZUSB_CTX_REQ_SUBMITTED:
709 case EZUSB_CTX_REQ_COMPLETE:
710 case EZUSB_CTX_RESP_RECEIVED:
711 if (in_softirq()) {
712 /* If we get called from a timer, timeout timers don't
713 * get the chance to run themselves. So we make sure
714 * that we don't sleep for ever */
715 int msecs = DEF_TIMEOUT * (1000 / HZ);
716 while (!ctx->done.done && msecs--)
717 udelay(1000);
718 } else {
719 wait_event_interruptible(ctx->done.wait,
720 ctx->done.done);
721 }
722 break;
723 default:
724 /* Done or failed - nothing to wait for */
725 break;
726 }
727}
728
729static inline u16 build_crc(struct ezusb_packet *data)
730{
731 u16 crc = 0;
732 u8 *bytes = (u8 *)data;
733 int i;
734
735 for (i = 0; i < 8; i++)
736 crc = (crc << 1) + bytes[i];
737
738 return crc;
739}
740
741/**
742 * ezusb_fill_req:
743 *
744 * if data == NULL and length > 0 the data is assumed to be already in
745 * the target buffer and only the header is filled.
746 *
747 */
748static int ezusb_fill_req(struct ezusb_packet *req, u16 length, u16 rid,
749 const void *data, u16 frame_type, u8 reply_count)
750{
751 int total_size = sizeof(*req) + length;
752
753 BUG_ON(total_size > BULK_BUF_SIZE);
754
755 req->magic = cpu_to_le16(EZUSB_MAGIC);
756 req->req_reply_count = reply_count;
757 req->ans_reply_count = 0;
758 req->frame_type = cpu_to_le16(frame_type);
759 req->size = cpu_to_le16(length + 4);
760 req->crc = cpu_to_le16(build_crc(req));
761 req->hermes_len = cpu_to_le16(HERMES_BYTES_TO_RECLEN(length));
762 req->hermes_rid = cpu_to_le16(rid);
763 if (data)
764 memcpy(req->data, data, length);
765 return total_size;
766}
767
768static int ezusb_submit_in_urb(struct ezusb_priv *upriv)
769{
770 int retval = 0;
771 void *cur_buf = upriv->read_urb->transfer_buffer;
772
773 if (upriv->read_urb->status == -EINPROGRESS) {
774 dbg("urb busy, not resubmiting");
775 retval = -EBUSY;
776 goto exit;
777 }
778 usb_fill_bulk_urb(upriv->read_urb, upriv->udev, upriv->read_pipe,
779 cur_buf, BULK_BUF_SIZE,
780 ezusb_bulk_in_callback, upriv);
781 upriv->read_urb->transfer_flags = 0;
782 retval = usb_submit_urb(upriv->read_urb, GFP_ATOMIC);
783 if (retval)
784 err("%s submit failed %d", __func__, retval);
785
786 exit:
787 return retval;
788}
789
790static inline int ezusb_8051_cpucs(struct ezusb_priv *upriv, int reset)
791{
792 u8 res_val = reset; /* avoid argument promotion */
793
794 if (!upriv->udev) {
795 err("%s: !upriv->udev", __func__);
796 return -EFAULT;
797 }
798 return usb_control_msg(upriv->udev,
799 usb_sndctrlpipe(upriv->udev, 0),
800 EZUSB_REQUEST_FW_TRANS,
801 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
802 USB_DIR_OUT, EZUSB_CPUCS_REG, 0, &res_val,
803 sizeof(res_val), DEF_TIMEOUT);
804}
805
806static int ezusb_firmware_download(struct ezusb_priv *upriv,
807 struct ez_usb_fw *fw)
808{
809 u8 fw_buffer[FW_BUF_SIZE];
810 int retval, addr;
811 int variant_offset;
812
813 /*
814 * This byte is 1 and should be replaced with 0. The offset is
815 * 0x10AD in version 0.0.6. The byte in question should follow
816 * the end of the code pointed to by the jump in the beginning
817 * of the firmware. Also, it is read by code located at 0x358.
818 */
819 variant_offset = be16_to_cpup((__be16 *) &fw->code[FW_VAR_OFFSET_PTR]);
820 if (variant_offset >= fw->size) {
821 printk(KERN_ERR PFX "Invalid firmware variant offset: "
822 "0x%04x\n", variant_offset);
823 retval = -EINVAL;
824 goto fail;
825 }
826
827 retval = ezusb_8051_cpucs(upriv, 1);
828 if (retval < 0)
829 goto fail;
830 for (addr = 0; addr < fw->size; addr += FW_BUF_SIZE) {
831 /* 0x100-0x300 should be left alone, it contains card
832 * specific data, like USB enumeration information */
833 if ((addr >= FW_HOLE_START) && (addr < FW_HOLE_END))
834 continue;
835
836 memcpy(fw_buffer, &fw->code[addr], FW_BUF_SIZE);
837 if (variant_offset >= addr &&
838 variant_offset < addr + FW_BUF_SIZE) {
839 dbg("Patching card_variant byte at 0x%04X",
840 variant_offset);
841 fw_buffer[variant_offset - addr] = FW_VAR_VALUE;
842 }
843 retval = usb_control_msg(upriv->udev,
844 usb_sndctrlpipe(upriv->udev, 0),
845 EZUSB_REQUEST_FW_TRANS,
846 USB_TYPE_VENDOR | USB_RECIP_DEVICE
847 | USB_DIR_OUT,
848 addr, 0x0,
849 fw_buffer, FW_BUF_SIZE,
850 DEF_TIMEOUT);
851
852 if (retval < 0)
853 goto fail;
854 }
855 retval = ezusb_8051_cpucs(upriv, 0);
856 if (retval < 0)
857 goto fail;
858
859 goto exit;
860 fail:
861 printk(KERN_ERR PFX "Firmware download failed, error %d\n",
862 retval);
863 exit:
864 return retval;
865}
866
867static int ezusb_access_ltv(struct ezusb_priv *upriv,
868 struct request_context *ctx,
869 u16 length, const void *data, u16 frame_type,
870 void *ans_buff, int ans_size, u16 *ans_length)
871{
872 int req_size;
873 int retval = 0;
874 enum ezusb_state state;
875
876 BUG_ON(in_irq());
877
878 if (!upriv->udev) {
879 dbg("Device disconnected");
880 return -ENODEV;
881 }
882
883 if (upriv->read_urb->status != -EINPROGRESS)
884 err("%s: in urb not pending", __func__);
885
886 /* protect upriv->reply_count, guarantee sequential numbers */
887 spin_lock_bh(&upriv->reply_count_lock);
888 req_size = ezusb_fill_req(ctx->buf, length, ctx->out_rid, data,
889 frame_type, upriv->reply_count);
890 usb_fill_bulk_urb(ctx->outurb, upriv->udev, upriv->write_pipe,
891 ctx->buf, req_size,
892 ezusb_request_out_callback, ctx);
893
894 if (ctx->in_rid)
895 upriv->reply_count = ezusb_reply_inc(upriv->reply_count);
896
897 ezusb_req_enqueue_run(upriv, ctx);
898
899 spin_unlock_bh(&upriv->reply_count_lock);
900
901 if (ctx->in_rid)
902 ezusb_req_ctx_wait(upriv, ctx);
903
904 state = ctx->state;
905 switch (state) {
906 case EZUSB_CTX_COMPLETE:
907 retval = ctx->outurb->status;
908 break;
909
910 case EZUSB_CTX_QUEUED:
911 case EZUSB_CTX_REQ_SUBMITTED:
912 if (!ctx->in_rid)
913 break;
914 default:
915 err("%s: Unexpected context state %d", __func__,
916 state);
917 /* fall though */
918 case EZUSB_CTX_REQ_TIMEOUT:
919 case EZUSB_CTX_REQ_FAILED:
920 case EZUSB_CTX_RESP_TIMEOUT:
921 case EZUSB_CTX_REQSUBMIT_FAIL:
922 printk(KERN_ERR PFX "Access failed, resetting (state %d,"
923 " reply_count %d)\n", state, upriv->reply_count);
924 upriv->reply_count = 0;
925 if (state == EZUSB_CTX_REQ_TIMEOUT
926 || state == EZUSB_CTX_RESP_TIMEOUT) {
927 printk(KERN_ERR PFX "ctx timed out\n");
928 retval = -ETIMEDOUT;
929 } else {
930 printk(KERN_ERR PFX "ctx failed\n");
931 retval = -EFAULT;
932 }
933 goto exit;
934 break;
935 }
936 if (ctx->in_rid) {
937 struct ezusb_packet *ans = ctx->buf;
938 int exp_len;
939
940 if (ans->hermes_len != 0)
941 exp_len = le16_to_cpu(ans->hermes_len) * 2 + 12;
942 else
943 exp_len = 14;
944
945 if (exp_len != ctx->buf_length) {
946 err("%s: length mismatch for RID 0x%04x: "
947 "expected %d, got %d", __func__,
948 ctx->in_rid, exp_len, ctx->buf_length);
949 retval = -EIO;
950 goto exit;
951 }
952
953 if (ans_buff)
954 memcpy(ans_buff, ans->data,
955 min_t(int, exp_len, ans_size));
956 if (ans_length)
957 *ans_length = le16_to_cpu(ans->hermes_len);
958 }
959 exit:
960 ezusb_request_context_put(ctx);
961 return retval;
962}
963
964static int ezusb_write_ltv(hermes_t *hw, int bap, u16 rid,
965 u16 length, const void *data)
966{
967 struct ezusb_priv *upriv = hw->priv;
968 u16 frame_type;
969 struct request_context *ctx;
970
971 if (length == 0)
972 return -EINVAL;
973
974 length = HERMES_RECLEN_TO_BYTES(length);
975
976 /* On memory mapped devices HERMES_RID_CNFGROUPADDRESSES can be
977 * set to be empty, but the USB bridge doesn't like it */
978 if (length == 0)
979 return 0;
980
981 ctx = ezusb_alloc_ctx(upriv, rid, EZUSB_RID_ACK);
982 if (!ctx)
983 return -ENOMEM;
984
985 if (rid == EZUSB_RID_TX)
986 frame_type = EZUSB_FRAME_DATA;
987 else
988 frame_type = EZUSB_FRAME_CONTROL;
989
990 return ezusb_access_ltv(upriv, ctx, length, data, frame_type,
991 NULL, 0, NULL);
992}
993
994static int ezusb_read_ltv(hermes_t *hw, int bap, u16 rid,
995 unsigned bufsize, u16 *length, void *buf)
996{
997 struct ezusb_priv *upriv = hw->priv;
998 struct request_context *ctx;
999
1000 if ((bufsize < 0) || (bufsize % 2))
1001 return -EINVAL;
1002
1003 ctx = ezusb_alloc_ctx(upriv, rid, rid);
1004 if (!ctx)
1005 return -ENOMEM;
1006
1007 return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL,
1008 buf, bufsize, length);
1009}
1010
1011static int ezusb_doicmd_wait(hermes_t *hw, u16 cmd, u16 parm0, u16 parm1,
1012 u16 parm2, struct hermes_response *resp)
1013{
1014 struct ezusb_priv *upriv = hw->priv;
1015 struct request_context *ctx;
1016
1017 __le16 data[4] = {
1018 cpu_to_le16(cmd),
1019 cpu_to_le16(parm0),
1020 cpu_to_le16(parm1),
1021 cpu_to_le16(parm2),
1022 };
1023 dbg("0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X",
1024 cmd, parm0, parm1, parm2);
1025 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
1026 if (!ctx)
1027 return -ENOMEM;
1028
1029 return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
1030 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1031}
1032
1033static int ezusb_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
1034 struct hermes_response *resp)
1035{
1036 struct ezusb_priv *upriv = hw->priv;
1037 struct request_context *ctx;
1038
1039 __le16 data[4] = {
1040 cpu_to_le16(cmd),
1041 cpu_to_le16(parm0),
1042 0,
1043 0,
1044 };
1045 dbg("0x%04X, parm0 0x%04X", cmd, parm0);
1046 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
1047 if (!ctx)
1048 return -ENOMEM;
1049
1050 return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
1051 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1052}
1053
1054static int ezusb_bap_pread(struct hermes *hw, int bap,
1055 void *buf, int len, u16 id, u16 offset)
1056{
1057 struct ezusb_priv *upriv = hw->priv;
1058 struct ezusb_packet *ans = (void *) upriv->read_urb->transfer_buffer;
1059 int actual_length = upriv->read_urb->actual_length;
1060
1061 if (id == EZUSB_RID_RX) {
1062 if ((sizeof(*ans) + offset + len) > actual_length) {
1063 printk(KERN_ERR PFX "BAP read beyond buffer end "
1064 "in rx frame\n");
1065 return -EINVAL;
1066 }
1067 memcpy(buf, ans->data + offset, len);
1068 return 0;
1069 }
1070
1071 if (EZUSB_IS_INFO(id)) {
1072 /* Include 4 bytes for length/type */
1073 if ((sizeof(*ans) + offset + len - 4) > actual_length) {
1074 printk(KERN_ERR PFX "BAP read beyond buffer end "
1075 "in info frame\n");
1076 return -EFAULT;
1077 }
1078 memcpy(buf, ans->data + offset - 4, len);
1079 } else {
1080 printk(KERN_ERR PFX "Unexpected fid 0x%04x\n", id);
1081 return -EINVAL;
1082 }
1083
1084 return 0;
1085}
1086
1087static int ezusb_read_pda(struct hermes *hw, __le16 *pda,
1088 u32 pda_addr, u16 pda_len)
1089{
1090 struct ezusb_priv *upriv = hw->priv;
1091 struct request_context *ctx;
1092 __le16 data[] = {
1093 cpu_to_le16(pda_addr & 0xffff),
1094 cpu_to_le16(pda_len - 4)
1095 };
1096 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_READ_PDA, EZUSB_RID_READ_PDA);
1097 if (!ctx)
1098 return -ENOMEM;
1099
1100 /* wl_lkm does not include PDA size in the PDA area.
1101 * We will pad the information into pda, so other routines
1102 * don't have to be modified */
1103 pda[0] = cpu_to_le16(pda_len - 2);
1104 /* Includes CFG_PROD_DATA but not itself */
1105 pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
1106
1107 return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
1108 EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4,
1109 NULL);
1110}
1111
1112static int ezusb_program_init(struct hermes *hw, u32 entry_point)
1113{
1114 struct ezusb_priv *upriv = hw->priv;
1115 struct request_context *ctx;
1116 __le32 data = cpu_to_le32(entry_point);
1117
1118 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_INIT, EZUSB_RID_ACK);
1119 if (!ctx)
1120 return -ENOMEM;
1121
1122 return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
1123 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1124}
1125
1126static int ezusb_program_end(struct hermes *hw)
1127{
1128 struct ezusb_priv *upriv = hw->priv;
1129 struct request_context *ctx;
1130
1131 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_END, EZUSB_RID_ACK);
1132 if (!ctx)
1133 return -ENOMEM;
1134
1135 return ezusb_access_ltv(upriv, ctx, 0, NULL,
1136 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1137}
1138
1139static int ezusb_program_bytes(struct hermes *hw, const char *buf,
1140 u32 addr, u32 len)
1141{
1142 struct ezusb_priv *upriv = hw->priv;
1143 struct request_context *ctx;
1144 __le32 data = cpu_to_le32(addr);
1145 int err;
1146
1147 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_SET_ADDR, EZUSB_RID_ACK);
1148 if (!ctx)
1149 return -ENOMEM;
1150
1151 err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
1152 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1153 if (err)
1154 return err;
1155
1156 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_BYTES, EZUSB_RID_ACK);
1157 if (!ctx)
1158 return -ENOMEM;
1159
1160 return ezusb_access_ltv(upriv, ctx, len, buf,
1161 EZUSB_FRAME_CONTROL, NULL, 0, NULL);
1162}
1163
1164static int ezusb_program(struct hermes *hw, const char *buf,
1165 u32 addr, u32 len)
1166{
1167 u32 ch_addr;
1168 u32 ch_len;
1169 int err = 0;
1170
1171 /* We can only send 2048 bytes out of the bulk xmit at a time,
1172 * so we have to split any programming into chunks of <2048
1173 * bytes. */
1174
1175 ch_len = (len < MAX_DL_SIZE) ? len : MAX_DL_SIZE;
1176 ch_addr = addr;
1177
1178 while (ch_addr < (addr + len)) {
1179 pr_debug("Programming subblock of length %d "
1180 "to address 0x%08x. Data @ %p\n",
1181 ch_len, ch_addr, &buf[ch_addr - addr]);
1182
1183 err = ezusb_program_bytes(hw, &buf[ch_addr - addr],
1184 ch_addr, ch_len);
1185 if (err)
1186 break;
1187
1188 ch_addr += ch_len;
1189 ch_len = ((addr + len - ch_addr) < MAX_DL_SIZE) ?
1190 (addr + len - ch_addr) : MAX_DL_SIZE;
1191 }
1192
1193 return err;
1194}
1195
1196static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
1197{
1198 struct orinoco_private *priv = ndev_priv(dev);
1199 struct net_device_stats *stats = &priv->stats;
1200 struct ezusb_priv *upriv = priv->card;
1201 int err = 0;
1202 char *p;
1203 struct ethhdr *eh;
1204 int len, data_len, data_off;
1205 __le16 tx_control;
1206 unsigned long flags;
1207 struct request_context *ctx;
1208 u8 *buf;
1209 int tx_size;
1210
1211 if (!netif_running(dev)) {
1212 printk(KERN_ERR "%s: Tx on stopped device!\n",
1213 dev->name);
1214 return NETDEV_TX_BUSY;
1215 }
1216
1217 if (netif_queue_stopped(dev)) {
1218 printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
1219 dev->name);
1220 return NETDEV_TX_BUSY;
1221 }
1222
1223 if (orinoco_lock(priv, &flags) != 0) {
1224 printk(KERN_ERR
1225 "%s: orinoco_xmit() called while hw_unavailable\n",
1226 dev->name);
1227 return NETDEV_TX_BUSY;
1228 }
1229
1230 if (!netif_carrier_ok(dev) ||
1231 (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
1232 /* Oops, the firmware hasn't established a connection,
1233 silently drop the packet (this seems to be the
1234 safest approach). */
1235 stats->tx_errors++;
1236 orinoco_unlock(priv, &flags);
1237 dev_kfree_skb(skb);
1238 return NETDEV_TX_OK;
1239 }
1240
1241 ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
1242 if (!ctx)
1243 goto fail;
1244
1245 memset(ctx->buf, 0, BULK_BUF_SIZE);
1246 buf = ctx->buf->data;
1247
1248 /* Length of the packet body */
1249 /* FIXME: what if the skb is smaller than this? */
1250 len = max_t(int, skb->len - ETH_HLEN, ETH_ZLEN - ETH_HLEN);
1251
1252 eh = (struct ethhdr *) skb->data;
1253
1254 tx_control = cpu_to_le16(0);
1255 memcpy(buf, &tx_control, sizeof(tx_control));
1256 buf += sizeof(tx_control);
1257 /* Encapsulate Ethernet-II frames */
1258 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
1259 struct header_struct *hdr = (void *) buf;
1260 buf += sizeof(*hdr);
1261 data_len = len;
1262 data_off = sizeof(tx_control) + sizeof(*hdr);
1263 p = skb->data + ETH_HLEN;
1264
1265 /* 802.3 header */
1266 memcpy(hdr->dest, eh->h_dest, ETH_ALEN);
1267 memcpy(hdr->src, eh->h_source, ETH_ALEN);
1268 hdr->len = htons(data_len + ENCAPS_OVERHEAD);
1269
1270 /* 802.2 header */
1271 memcpy(&hdr->dsap, &encaps_hdr, sizeof(encaps_hdr));
1272
1273 hdr->ethertype = eh->h_proto;
1274 } else { /* IEEE 802.3 frame */
1275 data_len = len + ETH_HLEN;
1276 data_off = sizeof(tx_control);
1277 p = skb->data;
1278 }
1279
1280 memcpy(buf, p, data_len);
1281 buf += data_len;
1282
1283 /* Finally, we actually initiate the send */
1284 netif_stop_queue(dev);
1285
1286 /* The card may behave better if we send evenly sized usb transfers */
1287 tx_size = ALIGN(buf - ctx->buf->data, 2);
1288
1289 err = ezusb_access_ltv(upriv, ctx, tx_size, NULL,
1290 EZUSB_FRAME_DATA, NULL, 0, NULL);
1291
1292 if (err) {
1293 netif_start_queue(dev);
1294 if (net_ratelimit())
1295 printk(KERN_ERR "%s: Error %d transmitting packet\n",
1296 dev->name, err);
1297 stats->tx_errors++;
1298 goto fail;
1299 }
1300
1301 dev->trans_start = jiffies;
1302 stats->tx_bytes += data_off + data_len;
1303
1304 orinoco_unlock(priv, &flags);
1305
1306 dev_kfree_skb(skb);
1307
1308 return NETDEV_TX_OK;
1309
1310 fail:
1311 orinoco_unlock(priv, &flags);
1312 return NETDEV_TX_BUSY;
1313}
1314
1315static int ezusb_allocate(struct hermes *hw, u16 size, u16 *fid)
1316{
1317 *fid = EZUSB_RID_TX;
1318 return 0;
1319}
1320
1321
1322static int ezusb_hard_reset(struct orinoco_private *priv)
1323{
1324 struct ezusb_priv *upriv = priv->card;
1325 int retval = ezusb_8051_cpucs(upriv, 1);
1326
1327 if (retval < 0) {
1328 err("Failed to reset");
1329 return retval;
1330 }
1331
1332 retval = ezusb_8051_cpucs(upriv, 0);
1333 if (retval < 0) {
1334 err("Failed to unreset");
1335 return retval;
1336 }
1337
1338 dbg("sending control message");
1339 retval = usb_control_msg(upriv->udev,
1340 usb_sndctrlpipe(upriv->udev, 0),
1341 EZUSB_REQUEST_TRIGER,
1342 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
1343 USB_DIR_OUT, 0x0, 0x0, NULL, 0,
1344 DEF_TIMEOUT);
1345 if (retval < 0) {
1346 err("EZUSB_REQUEST_TRIGER failed retval %d", retval);
1347 return retval;
1348 }
1349#if 0
1350 dbg("Sending EZUSB_REQUEST_TRIG_AC");
1351 retval = usb_control_msg(upriv->udev,
1352 usb_sndctrlpipe(upriv->udev, 0),
1353 EZUSB_REQUEST_TRIG_AC,
1354 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
1355 USB_DIR_OUT, 0x00FA, 0x0, NULL, 0,
1356 DEF_TIMEOUT);
1357 if (retval < 0) {
1358 err("EZUSB_REQUEST_TRIG_AC failed retval %d", retval);
1359 return retval;
1360 }
1361#endif
1362
1363 return 0;
1364}
1365
1366
1367static int ezusb_init(hermes_t *hw)
1368{
1369 struct ezusb_priv *upriv = hw->priv;
1370 int retval;
1371
1372 BUG_ON(in_interrupt());
1373 BUG_ON(!upriv);
1374
1375 upriv->reply_count = 0;
1376 /* Write the MAGIC number on the simulated registers to keep
1377 * orinoco.c happy */
1378 hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
1379 hermes_write_regn(hw, RXFID, EZUSB_RID_RX);
1380
1381 usb_kill_urb(upriv->read_urb);
1382 ezusb_submit_in_urb(upriv);
1383
1384 retval = ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1,
1385 HERMES_BYTES_TO_RECLEN(2), "\x10\x00");
1386 if (retval < 0) {
1387 printk(KERN_ERR PFX "EZUSB_RID_INIT1 error %d\n", retval);
1388 return retval;
1389 }
1390
1391 retval = ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL);
1392 if (retval < 0) {
1393 printk(KERN_ERR PFX "HERMES_CMD_INIT error %d\n", retval);
1394 return retval;
1395 }
1396
1397 return 0;
1398}
1399
1400static void ezusb_bulk_in_callback(struct urb *urb)
1401{
1402 struct ezusb_priv *upriv = (struct ezusb_priv *) urb->context;
1403 struct ezusb_packet *ans = urb->transfer_buffer;
1404 u16 crc;
1405 u16 hermes_rid;
1406
1407 if (upriv->udev == NULL) {
1408 dbg("disconnected");
1409 return;
1410 }
1411
1412 if (urb->status == -ETIMEDOUT) {
1413 /* When a device gets unplugged we get this every time
1414 * we resubmit, flooding the logs. Since we don't use
1415 * USB timeouts, it shouldn't happen any other time*/
1416 pr_warning("%s: urb timed out, not resubmiting", __func__);
1417 return;
1418 }
1419 if (urb->status == -ECONNABORTED) {
1420 pr_warning("%s: connection abort, resubmiting urb",
1421 __func__);
1422 goto resubmit;
1423 }
1424 if ((urb->status == -EILSEQ)
1425 || (urb->status == -ENOENT)
1426 || (urb->status == -ECONNRESET)) {
1427 dbg("status %d, not resubmiting", urb->status);
1428 return;
1429 }
1430 if (urb->status)
1431 dbg("status: %d length: %d",
1432 urb->status, urb->actual_length);
1433 if (urb->actual_length < sizeof(*ans)) {
1434 err("%s: short read, ignoring", __func__);
1435 goto resubmit;
1436 }
1437 crc = build_crc(ans);
1438 if (le16_to_cpu(ans->crc) != crc) {
1439 err("CRC error, ignoring packet");
1440 goto resubmit;
1441 }
1442
1443 hermes_rid = le16_to_cpu(ans->hermes_rid);
1444 if ((hermes_rid != EZUSB_RID_RX) && !EZUSB_IS_INFO(hermes_rid)) {
1445 ezusb_request_in_callback(upriv, urb);
1446 } else if (upriv->dev) {
1447 struct net_device *dev = upriv->dev;
1448 struct orinoco_private *priv = ndev_priv(dev);
1449 hermes_t *hw = &priv->hw;
1450
1451 if (hermes_rid == EZUSB_RID_RX) {
1452 __orinoco_ev_rx(dev, hw);
1453 } else {
1454 hermes_write_regn(hw, INFOFID,
1455 le16_to_cpu(ans->hermes_rid));
1456 __orinoco_ev_info(dev, hw);
1457 }
1458 }
1459
1460 resubmit:
1461 if (upriv->udev)
1462 ezusb_submit_in_urb(upriv);
1463}
1464
1465static inline void ezusb_delete(struct ezusb_priv *upriv)
1466{
1467 struct net_device *dev;
1468 struct list_head *item;
1469 struct list_head *tmp_item;
1470 unsigned long flags;
1471
1472 BUG_ON(in_interrupt());
1473 BUG_ON(!upriv);
1474
1475 dev = upriv->dev;
1476 mutex_lock(&upriv->mtx);
1477
1478 upriv->udev = NULL; /* No timer will be rearmed from here */
1479
1480 usb_kill_urb(upriv->read_urb);
1481
1482 spin_lock_irqsave(&upriv->req_lock, flags);
1483 list_for_each_safe(item, tmp_item, &upriv->req_active) {
1484 struct request_context *ctx;
1485 int err;
1486
1487 ctx = list_entry(item, struct request_context, list);
1488 atomic_inc(&ctx->refcount);
1489
1490 ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
1491 err = usb_unlink_urb(ctx->outurb);
1492
1493 spin_unlock_irqrestore(&upriv->req_lock, flags);
1494 if (err == -EINPROGRESS)
1495 wait_for_completion(&ctx->done);
1496
1497 del_timer_sync(&ctx->timer);
1498 /* FIXME: there is an slight chance for the irq handler to
1499 * be running */
1500 if (!list_empty(&ctx->list))
1501 ezusb_ctx_complete(ctx);
1502
1503 ezusb_request_context_put(ctx);
1504 spin_lock_irqsave(&upriv->req_lock, flags);
1505 }
1506 spin_unlock_irqrestore(&upriv->req_lock, flags);
1507
1508 list_for_each_safe(item, tmp_item, &upriv->req_pending)
1509 ezusb_ctx_complete(list_entry(item,
1510 struct request_context, list));
1511
1512 if (upriv->read_urb->status == -EINPROGRESS)
1513 printk(KERN_ERR PFX "Some URB in progress\n");
1514
1515 mutex_unlock(&upriv->mtx);
1516
1517 kfree(upriv->read_urb->transfer_buffer);
1518 if (upriv->bap_buf != NULL)
1519 kfree(upriv->bap_buf);
1520 if (upriv->read_urb != NULL)
1521 usb_free_urb(upriv->read_urb);
1522 if (upriv->dev) {
1523 struct orinoco_private *priv = ndev_priv(upriv->dev);
1524 orinoco_if_del(priv);
1525 free_orinocodev(priv);
1526 }
1527}
1528
1529static void ezusb_lock_irqsave(spinlock_t *lock,
1530 unsigned long *flags) __acquires(lock)
1531{
1532 spin_lock_bh(lock);
1533}
1534
1535static void ezusb_unlock_irqrestore(spinlock_t *lock,
1536 unsigned long *flags) __releases(lock)
1537{
1538 spin_unlock_bh(lock);
1539}
1540
1541static void ezusb_lock_irq(spinlock_t *lock) __acquires(lock)
1542{
1543 spin_lock_bh(lock);
1544}
1545
1546static void ezusb_unlock_irq(spinlock_t *lock) __releases(lock)
1547{
1548 spin_unlock_bh(lock);
1549}
1550
1551static const struct hermes_ops ezusb_ops = {
1552 .init = ezusb_init,
1553 .cmd_wait = ezusb_docmd_wait,
1554 .init_cmd_wait = ezusb_doicmd_wait,
1555 .allocate = ezusb_allocate,
1556 .read_ltv = ezusb_read_ltv,
1557 .write_ltv = ezusb_write_ltv,
1558 .bap_pread = ezusb_bap_pread,
1559 .read_pda = ezusb_read_pda,
1560 .program_init = ezusb_program_init,
1561 .program_end = ezusb_program_end,
1562 .program = ezusb_program,
1563 .lock_irqsave = ezusb_lock_irqsave,
1564 .unlock_irqrestore = ezusb_unlock_irqrestore,
1565 .lock_irq = ezusb_lock_irq,
1566 .unlock_irq = ezusb_unlock_irq,
1567};
1568
1569static const struct net_device_ops ezusb_netdev_ops = {
1570 .ndo_open = orinoco_open,
1571 .ndo_stop = orinoco_stop,
1572 .ndo_start_xmit = ezusb_xmit,
1573 .ndo_set_multicast_list = orinoco_set_multicast_list,
1574 .ndo_change_mtu = orinoco_change_mtu,
1575 .ndo_set_mac_address = eth_mac_addr,
1576 .ndo_validate_addr = eth_validate_addr,
1577 .ndo_tx_timeout = orinoco_tx_timeout,
1578 .ndo_get_stats = orinoco_get_stats,
1579};
1580
1581static int ezusb_probe(struct usb_interface *interface,
1582 const struct usb_device_id *id)
1583{
1584 struct usb_device *udev = interface_to_usbdev(interface);
1585 struct orinoco_private *priv;
1586 hermes_t *hw;
1587 struct ezusb_priv *upriv = NULL;
1588 struct usb_interface_descriptor *iface_desc;
1589 struct usb_endpoint_descriptor *ep;
1590 const struct firmware *fw_entry;
1591 int retval = 0;
1592 int i;
1593
1594 priv = alloc_orinocodev(sizeof(*upriv), &udev->dev,
1595 ezusb_hard_reset, NULL);
1596 if (!priv) {
1597 err("Couldn't allocate orinocodev");
1598 goto exit;
1599 }
1600
1601 hw = &priv->hw;
1602
1603 upriv = priv->card;
1604
1605 mutex_init(&upriv->mtx);
1606 spin_lock_init(&upriv->reply_count_lock);
1607
1608 spin_lock_init(&upriv->req_lock);
1609 INIT_LIST_HEAD(&upriv->req_pending);
1610 INIT_LIST_HEAD(&upriv->req_active);
1611
1612 upriv->udev = udev;
1613
1614 hw->iobase = (void __force __iomem *) &upriv->hermes_reg_fake;
1615 hw->reg_spacing = HERMES_16BIT_REGSPACING;
1616 hw->priv = upriv;
1617 hw->ops = &ezusb_ops;
1618
1619 /* set up the endpoint information */
1620 /* check out the endpoints */
1621
1622 iface_desc = &interface->altsetting[0].desc;
1623 for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
1624 ep = &interface->altsetting[0].endpoint[i].desc;
1625
1626 if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
1627 == USB_DIR_IN) &&
1628 ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
1629 == USB_ENDPOINT_XFER_BULK)) {
1630 /* we found a bulk in endpoint */
1631 if (upriv->read_urb != NULL) {
1632 pr_warning("Found a second bulk in ep, ignored");
1633 continue;
1634 }
1635
1636 upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
1637 if (!upriv->read_urb) {
1638 err("No free urbs available");
1639 goto error;
1640 }
1641 if (le16_to_cpu(ep->wMaxPacketSize) != 64)
1642 pr_warning("bulk in: wMaxPacketSize!= 64");
1643 if (ep->bEndpointAddress != (2 | USB_DIR_IN))
1644 pr_warning("bulk in: bEndpointAddress: %d",
1645 ep->bEndpointAddress);
1646 upriv->read_pipe = usb_rcvbulkpipe(udev,
1647 ep->
1648 bEndpointAddress);
1649 upriv->read_urb->transfer_buffer =
1650 kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
1651 if (!upriv->read_urb->transfer_buffer) {
1652 err("Couldn't allocate IN buffer");
1653 goto error;
1654 }
1655 }
1656
1657 if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
1658 == USB_DIR_OUT) &&
1659 ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
1660 == USB_ENDPOINT_XFER_BULK)) {
1661 /* we found a bulk out endpoint */
1662 if (upriv->bap_buf != NULL) {
1663 pr_warning("Found a second bulk out ep, ignored");
1664 continue;
1665 }
1666
1667 if (le16_to_cpu(ep->wMaxPacketSize) != 64)
1668 pr_warning("bulk out: wMaxPacketSize != 64");
1669 if (ep->bEndpointAddress != 2)
1670 pr_warning("bulk out: bEndpointAddress: %d",
1671 ep->bEndpointAddress);
1672 upriv->write_pipe = usb_sndbulkpipe(udev,
1673 ep->
1674 bEndpointAddress);
1675 upriv->bap_buf = kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
1676 if (!upriv->bap_buf) {
1677 err("Couldn't allocate bulk_out_buffer");
1678 goto error;
1679 }
1680 }
1681 }
1682 if (!upriv->bap_buf || !upriv->read_urb) {
1683 err("Didn't find the required bulk endpoints");
1684 goto error;
1685 }
1686
1687 if (request_firmware(&fw_entry, "orinoco_ezusb_fw",
1688 &interface->dev) == 0) {
1689 firmware.size = fw_entry->size;
1690 firmware.code = fw_entry->data;
1691 }
1692 if (firmware.size && firmware.code) {
1693 ezusb_firmware_download(upriv, &firmware);
1694 } else {
1695 err("No firmware to download");
1696 goto error;
1697 }
1698
1699 if (ezusb_hard_reset(priv) < 0) {
1700 err("Cannot reset the device");
1701 goto error;
1702 }
1703
1704 /* If the firmware is already downloaded orinoco.c will call
1705 * ezusb_init but if the firmware is not already there, that will make
1706 * the kernel very unstable, so we try initializing here and quit in
1707 * case of error */
1708 if (ezusb_init(hw) < 0) {
1709 err("Couldn't initialize the device");
1710 err("Firmware may not be downloaded or may be wrong.");
1711 goto error;
1712 }
1713
1714 /* Initialise the main driver */
1715 if (orinoco_init(priv) != 0) {
1716 err("orinoco_init() failed\n");
1717 goto error;
1718 }
1719
1720 if (orinoco_if_add(priv, 0, 0, &ezusb_netdev_ops) != 0) {
1721 upriv->dev = NULL;
1722 err("%s: orinoco_if_add() failed", __func__);
1723 goto error;
1724 }
1725 upriv->dev = priv->ndev;
1726
1727 goto exit;
1728
1729 error:
1730 ezusb_delete(upriv);
1731 if (upriv->dev) {
1732 /* upriv->dev was 0, so ezusb_delete() didn't free it */
1733 free_orinocodev(priv);
1734 }
1735 upriv = NULL;
1736 retval = -EFAULT;
1737 exit:
1738 if (fw_entry) {
1739 firmware.code = NULL;
1740 firmware.size = 0;
1741 release_firmware(fw_entry);
1742 }
1743 usb_set_intfdata(interface, upriv);
1744 return retval;
1745}
1746
1747
1748static void ezusb_disconnect(struct usb_interface *intf)
1749{
1750 struct ezusb_priv *upriv = usb_get_intfdata(intf);
1751 usb_set_intfdata(intf, NULL);
1752 ezusb_delete(upriv);
1753 printk(KERN_INFO PFX "Disconnected\n");
1754}
1755
1756
1757/* usb specific object needed to register this driver with the usb subsystem */
1758static struct usb_driver orinoco_driver = {
1759 .name = DRIVER_NAME,
1760 .probe = ezusb_probe,
1761 .disconnect = ezusb_disconnect,
1762 .id_table = ezusb_table,
1763};
1764
1765/* Can't be declared "const" or the whole __initdata section will
1766 * become const */
1767static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
1768 " (Manuel Estrada Sainz)";
1769
1770static int __init ezusb_module_init(void)
1771{
1772 int err;
1773
1774 printk(KERN_DEBUG "%s\n", version);
1775
1776 /* register this driver with the USB subsystem */
1777 err = usb_register(&orinoco_driver);
1778 if (err < 0) {
1779 printk(KERN_ERR PFX "usb_register failed, error %d\n",
1780 err);
1781 return err;
1782 }
1783
1784 return 0;
1785}
1786
1787static void __exit ezusb_module_exit(void)
1788{
1789 /* deregister this driver with the USB subsystem */
1790 usb_deregister(&orinoco_driver);
1791}
1792
1793
1794module_init(ezusb_module_init);
1795module_exit(ezusb_module_exit);
1796
1797MODULE_AUTHOR("Manuel Estrada Sainz");
1798MODULE_DESCRIPTION
1799 ("Driver for Orinoco wireless LAN cards using EZUSB bridge");
1800MODULE_LICENSE("Dual MPL/GPL");
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 59bda240fdc..9b1af4976bf 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -349,6 +349,7 @@ spectrum_cs_config(struct pcmcia_device *link)
349 goto failed; 349 goto failed;
350 350
351 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 351 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
352 hw->eeprom_pda = true;
352 353
353 /* 354 /*
354 * This actually configures the PCMCIA socket -- setting up 355 * This actually configures the PCMCIA socket -- setting up
@@ -374,7 +375,7 @@ spectrum_cs_config(struct pcmcia_device *link)
374 375
375 /* Register an interface with the stack */ 376 /* Register an interface with the stack */
376 if (orinoco_if_add(priv, link->io.BasePort1, 377 if (orinoco_if_add(priv, link->io.BasePort1,
377 link->irq.AssignedIRQ) != 0) { 378 link->irq.AssignedIRQ, NULL) != 0) {
378 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 379 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
379 goto failed; 380 goto failed;
380 } 381 }
@@ -405,9 +406,9 @@ spectrum_cs_release(struct pcmcia_device *link)
405 406
406 /* We're committed to taking the device away now, so mark the 407 /* We're committed to taking the device away now, so mark the
407 * hardware as unavailable */ 408 * hardware as unavailable */
408 spin_lock_irqsave(&priv->lock, flags); 409 priv->hw.ops->lock_irqsave(&priv->lock, &flags);
409 priv->hw_unavailable++; 410 priv->hw_unavailable++;
410 spin_unlock_irqrestore(&priv->lock, flags); 411 priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
411 412
412 pcmcia_disable_device(link); 413 pcmcia_disable_device(link);
413 if (priv->hw.iobase) 414 if (priv->hw.iobase)
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index a1006bf430c..5775124e2ae 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -458,7 +458,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
458 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { 458 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
459 /* Fast channel change - no commit if successful */ 459 /* Fast channel change - no commit if successful */
460 hermes_t *hw = &priv->hw; 460 hermes_t *hw = &priv->hw;
461 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 461 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
462 HERMES_TEST_SET_CHANNEL, 462 HERMES_TEST_SET_CHANNEL,
463 chan, NULL); 463 chan, NULL);
464 } 464 }
@@ -1273,8 +1273,8 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
1273 if (orinoco_lock(priv, &flags) != 0) 1273 if (orinoco_lock(priv, &flags) != 0)
1274 return -EBUSY; 1274 return -EBUSY;
1275 1275
1276 err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length, 1276 err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
1277 extra); 1277 extra);
1278 if (err) 1278 if (err)
1279 goto out; 1279 goto out;
1280 1280