Skip to contentSkip to conversation

orinoco: Add support for Agere based USB cards

RFC New David Kilroy 1 participant 6 messages Apr 19, 2010 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover orinoco: Add support for Agere based USB cards

This patch series adds the orinoco_usb driver, originally written by Manuel Estrada Sainz.

I believe the main stumbling block the last time this driver was submitted for inclusion was the way it handled the orinoco driver locking. I've reworked this into something reasonably sane (patch 3).

The resulting driver has been basically tested with a Compaq WL215 (thanks to Mark Davis for supplying one). Managed mode with WEP works on this card while a WPA-enabled PCMCIA orinoco card is running.

I'm not familiar with the USB subsystem, so there may be issues that need to be resolved in that area. Also the original driver used in_atomic in one location. I left this as-is in the main driver commit (patch 4), and the subsequent patch (5) is my attempt to fix this up. It works, but there may be a better way to do this.

Regards,

Dave.

---
David Kilroy (5):
orinoco: add hermes_ops
orinoco: allow driver to specify netdev_ops
orinoco: encapsulate driver locking
orinoco: add orinoco_usb driver
orinoco_usb: avoid in_atomic

 drivers/net/wireless/orinoco/Kconfig          |    7 +
 drivers/net/wireless/orinoco/Makefile         |    1 +
 drivers/net/wireless/orinoco/airport.c        |    4 +-
 drivers/net/wireless/orinoco/cfg.c            |    2 +-
 drivers/net/wireless/orinoco/fw.c             |    2 +-
 drivers/net/wireless/orinoco/hermes.c         |   76 +-
 drivers/net/wireless/orinoco/hermes.h         |   55 +-
 drivers/net/wireless/orinoco/hermes_dld.c     |   34 +-
 drivers/net/wireless/orinoco/hw.c             |   63 +-
 drivers/net/wireless/orinoco/main.c           |  129 ++-
 drivers/net/wireless/orinoco/orinoco.h        |   30 +-
 drivers/net/wireless/orinoco/orinoco_cs.c     |    2 +-
 drivers/net/wireless/orinoco/orinoco_nortel.c |    2 +-
 drivers/net/wireless/orinoco/orinoco_pci.c    |    2 +-
 drivers/net/wireless/orinoco/orinoco_plx.c    |    2 +-
 drivers/net/wireless/orinoco/orinoco_tmd.c    |    2 +-
 drivers/net/wireless/orinoco/orinoco_usb.c    | 1678 +++++++++++++++++++++++++
 drivers/net/wireless/orinoco/spectrum_cs.c    |    2 +-
 drivers/net/wireless/orinoco/wext.c           |    6 +-
 19 files changed, 1932 insertions(+), 167 deletions(-)
 create mode 100644 drivers/net/wireless/orinoco/orinoco_usb.c
#1 lore raw

RFC 1/5 orinoco: add hermes_ops

Pave the way for introducing USB alternative functions.

Force callers to dereference ops instead of providing wrappers.

---
 drivers/net/wireless/orinoco/airport.c    |    2 +-
 drivers/net/wireless/orinoco/cfg.c        |    2 +-
 drivers/net/wireless/orinoco/fw.c         |    2 +-
 drivers/net/wireless/orinoco/hermes.c     |   52 ++++++++++--------
 drivers/net/wireless/orinoco/hermes.h     |   50 ++++++++++--------
 drivers/net/wireless/orinoco/hermes_dld.c |   34 ++++++------
 drivers/net/wireless/orinoco/hw.c         |   63 +++++++++++-----------
 drivers/net/wireless/orinoco/main.c       |   83 +++++++++++++++--------------
 drivers/net/wireless/orinoco/wext.c       |    6 +-
 9 files changed, 154 insertions(+), 140 deletions(-)
drivers/net/wireless/orinoco/airport.c +1 -1
index c60df2c..ea23c4f 100644
@@ -195,7 +195,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
 	ssleep(1);
 
 	/* Reset it before we get the interrupt */
-	hermes_init(hw);
+	hw->ops->init(hw);
 
 	if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) {
 		printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq);
drivers/net/wireless/orinoco/cfg.c +1 -1
index 90dd4d0..81d228d 100644
@@ -189,7 +189,7 @@ static int orinoco_set_channel(struct wiphy *wiphy,
 	if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
 		/* Fast channel change - no commit if successful */
 		hermes_t *hw = &priv->hw;
-		err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
+		err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
 					    HERMES_TEST_SET_CHANNEL,
 					channel, NULL);
 	}
drivers/net/wireless/orinoco/fw.c +1 -1
index 5ea0f7c..4c99240 100644
@@ -260,7 +260,7 @@ symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
 	}
 
 	/* Reset hermes chip and make sure it responds */
-	ret = hermes_init(hw);
+	ret = hw->ops->init(hw);
 
 	/* hermes_reset() should return 0 with the secondary firmware */
 	if (secondary && ret != 0)
drivers/net/wireless/orinoco/hermes.c +29 -23

144 lines not on this page · raw message

drivers/net/wireless/orinoco/hermes.h +28 -22

92 lines not on this page · raw message

drivers/net/wireless/orinoco/hermes_dld.c +17 -17
index fb157eb..8f22e20 100644
@@ -293,7 +293,7 @@ int hermes_read_pda(hermes_t *hw,
 		/* PDA of spectrum symbol is in eeprom */
 
 		/* Issue command to read EEPROM */
-		ret = hermes_docmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
+		ret = hw->ops->cmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
 		if (ret)
 			return ret;
 	} else {
@@ -408,16 +408,16 @@ int hermesi_program_init(hermes_t *hw, u32 offset)
 	/* Acknowledge any outstanding command */
 	hermes_write_regn(hw, EVACK, 0xFFFF);
 
-	/* Using doicmd_wait rather than docmd_wait */
-	err = hermes_doicmd_wait(hw,
-				 0x0100 | HERMES_CMD_INIT,
-				 0, 0, 0, NULL);
+	/* Using init_cmd_wait rather than cmd_wait */
+	err = hw->ops->init_cmd_wait(hw,
+				     0x0100 | HERMES_CMD_INIT,
+				     0, 0, 0, NULL);
 	if (err)
 		return err;
 
-	err = hermes_doicmd_wait(hw,
-				 0x0000 | HERMES_CMD_INIT,
-				 0, 0, 0, NULL);
+	err = hw->ops->init_cmd_wait(hw,
+				     0x0000 | HERMES_CMD_INIT,
+				     0, 0, 0, NULL);
 	if (err)
 		return err;
 
@@ -428,12 +428,12 @@ int hermesi_program_init(hermes_t *hw, u32 offset)
 		return err;
 
 	pr_debug(PFX "Enabling volatile, EP 0x%08x\n", offset);
-	err = hermes_doicmd_wait(hw,
-				 HERMES_PROGRAM_ENABLE_VOLATILE,
-				 offset & 0xFFFFu,
-				 offset >> 16,
-				 0,
-				 NULL);
+	err = hw->ops->init_cmd_wait(hw,
+				     HERMES_PROGRAM_ENABLE_VOLATILE,
+				     offset & 0xFFFFu,
+				     offset >> 16,
+				     0,
+				     NULL);
 	pr_debug(PFX "PROGRAM_ENABLE returned %d\n", err);
 
 	return err;
@@ -451,7 +451,7 @@ int hermesi_program_end(hermes_t *hw)
 	int rc = 0;
 	int err;
 
-	rc = hermes_docmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp);
+	rc = hw->ops->cmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp);
 
 	pr_debug(PFX "PROGRAM_DISABLE returned %d, "
 		 "r0 0x%04x, r1 0x%04x, r2 0x%04x\n",
@@ -468,8 +468,8 @@ int hermesi_program_end(hermes_t *hw)
 	hermes_write_regn(hw, EVACK, 0xFFFF);
 
 	/* Reinitialise, ignoring return */
-	(void) hermes_doicmd_wait(hw, 0x0000 | HERMES_CMD_INIT,
-				  0, 0, 0, NULL);
+	(void) hw->ops->init_cmd_wait(hw, 0x0000 | HERMES_CMD_INIT,
+				      0, 0, 0, NULL);
 
 	return rc ? rc : err;
 }
drivers/net/wireless/orinoco/hw.c +32 -31

171 lines not on this page · raw message

drivers/net/wireless/orinoco/main.c +42 -41

203 lines not on this page · raw message

drivers/net/wireless/orinoco/wext.c +3 -3
index a1006bf..5775124 100644
@@ -458,7 +458,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
 	if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
 		/* Fast channel change - no commit if successful */
 		hermes_t *hw = &priv->hw;
-		err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
+		err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
 					    HERMES_TEST_SET_CHANNEL,
 					chan, NULL);
 	}
@@ -1273,8 +1273,8 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
 	if (orinoco_lock(priv, &flags) != 0)
 		return -EBUSY;
 
-	err = hermes_read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
-			      extra);
+	err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
+				extra);
 	if (err)
 		goto out;
 
Signature · 1 line
1.6.4.4
#2 lore raw

RFC 2/5 orinoco: allow driver to specify netdev_ops

In reply to David Kilroy

Allow the main drivers to specify a custom version of the net_device_ops structure. This is required by orinoco_usb to supply a separate transmit function.

Export existing net_device_ops callbacks so that the drivers can reuse some of the existing code.

---
 drivers/net/wireless/orinoco/airport.c        |    2 +-
 drivers/net/wireless/orinoco/main.c           |   28 +++++++++++++++++-------
 drivers/net/wireless/orinoco/orinoco.h        |   11 +++++++++-
 drivers/net/wireless/orinoco/orinoco_cs.c     |    2 +-
 drivers/net/wireless/orinoco/orinoco_nortel.c |    2 +-
 drivers/net/wireless/orinoco/orinoco_pci.c    |    2 +-
 drivers/net/wireless/orinoco/orinoco_plx.c    |    2 +-
 drivers/net/wireless/orinoco/orinoco_tmd.c    |    2 +-
 drivers/net/wireless/orinoco/spectrum_cs.c    |    2 +-
 9 files changed, 37 insertions(+), 16 deletions(-)
drivers/net/wireless/orinoco/airport.c +1 -1
index ea23c4f..7dac5ad 100644
@@ -210,7 +210,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
 	}
 
 	/* Register an interface with the stack */
-	if (orinoco_if_add(priv, phys_addr, card->irq) != 0) {
+	if (orinoco_if_add(priv, phys_addr, card->irq, NULL) != 0) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto failed;
 	}
drivers/net/wireless/orinoco/main.c +20 -8
index 8c8009c..9dc458d 100644
@@ -254,7 +254,7 @@ void set_port_type(struct orinoco_private *priv)
 /* Device methods                                                   */
 /********************************************************************/
 
-static int orinoco_open(struct net_device *dev)
+int orinoco_open(struct net_device *dev)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	unsigned long flags;
@@ -272,8 +272,9 @@ static int orinoco_open(struct net_device *dev)
 
 	return err;
 }
+EXPORT_SYMBOL(orinoco_open);
 
-static int orinoco_stop(struct net_device *dev)
+int orinoco_stop(struct net_device *dev)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	int err = 0;
@@ -291,15 +292,17 @@ static int orinoco_stop(struct net_device *dev)
 
 	return err;
 }
+EXPORT_SYMBOL(orinoco_stop);
 
-static struct net_device_stats *orinoco_get_stats(struct net_device *dev)
+struct net_device_stats *orinoco_get_stats(struct net_device *dev)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 
 	return &priv->stats;
 }
+EXPORT_SYMBOL(orinoco_get_stats);
 
-static void orinoco_set_multicast_list(struct net_device *dev)
+void orinoco_set_multicast_list(struct net_device *dev)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	unsigned long flags;
@@ -313,8 +316,9 @@ static void orinoco_set_multicast_list(struct net_device *dev)
 	__orinoco_set_multicast_list(dev);
 	orinoco_unlock(priv, &flags);
 }
+EXPORT_SYMBOL(orinoco_set_multicast_list);
 
-static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
+int orinoco_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 
@@ -330,6 +334,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
 
 	return 0;
 }
+EXPORT_SYMBOL(orinoco_change_mtu);
 
 /********************************************************************/
 /* Tx path                                                          */
@@ -615,7 +620,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
 	netif_wake_queue(dev);
 }
 
-static void orinoco_tx_timeout(struct net_device *dev)
+void orinoco_tx_timeout(struct net_device *dev)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	struct net_device_stats *stats = &priv->stats;
@@ -630,6 +635,7 @@ static void orinoco_tx_timeout(struct net_device *dev)
 
 	schedule_work(&priv->reset_work);
 }
+EXPORT_SYMBOL(orinoco_tx_timeout);
 
 /********************************************************************/
 /* Rx path (data frames)                                            */
@@ -2193,7 +2199,8 @@ EXPORT_SYMBOL(alloc_orinocodev);
  */
 int orinoco_if_add(struct orinoco_private *priv,
 		   unsigned long base_addr,
-		   unsigned int irq)
+		   unsigned int irq,
+		   const struct net_device_ops *ops)
 {
 	struct wiphy *wiphy = priv_to_wiphy(priv);
 	struct wireless_dev *wdev;
@@ -2212,12 +2219,17 @@ int orinoco_if_add(struct orinoco_private *priv,
 
 	/* Setup / override net_device fields */
 	dev->ieee80211_ptr = wdev;
-	dev->netdev_ops = &orinoco_netdev_ops;
 	dev->watchdog_timeo = HZ; /* 1 second timeout */
 	dev->wireless_handlers = &orinoco_handler_def;
 #ifdef WIRELESS_SPY
 	dev->wireless_data = &priv->wireless_data;
 #endif
+	/* Default to standard ops if not set */
+	if (ops)
+		dev->netdev_ops = ops;
+	else
+		dev->netdev_ops = &orinoco_netdev_ops;
+
 	/* we use the default eth_mac_addr for setting the MAC addr */
 
 	/* Reserve space in skb for the SNAP header */
drivers/net/wireless/orinoco/orinoco.h +10 -1
index ff6b7b1..f1901d6 100644
@@ -190,12 +190,21 @@ extern void free_orinocodev(struct orinoco_private *priv);
 extern int orinoco_init(struct orinoco_private *priv);
 extern int orinoco_if_add(struct orinoco_private *priv,
 			  unsigned long base_addr,
-			  unsigned int irq);
+			  unsigned int irq,
+			  const struct net_device_ops *ops);
 extern void orinoco_if_del(struct orinoco_private *priv);
 extern int orinoco_up(struct orinoco_private *priv);
 extern void orinoco_down(struct orinoco_private *priv);
 extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
 
+/* Common ndo functions exported for reuse by orinoco_usb */
+int orinoco_open(struct net_device *dev);
+int orinoco_stop(struct net_device *dev);
+struct net_device_stats *orinoco_get_stats(struct net_device *dev);
+void orinoco_set_multicast_list(struct net_device *dev);
+int orinoco_change_mtu(struct net_device *dev, int new_mtu);
+void orinoco_tx_timeout(struct net_device *dev);
+
 /********************************************************************/
 /* Locking and synchronization functions                            */
 /********************************************************************/
drivers/net/wireless/orinoco/orinoco_cs.c +1 -1
index fdc9613..525f74e 100644
@@ -296,7 +296,7 @@ orinoco_cs_config(struct pcmcia_device *link)
 
 	/* Register an interface with the stack */
 	if (orinoco_if_add(priv, link->io.BasePort1,
-			   link->irq.AssignedIRQ) != 0) {
+			   link->irq.AssignedIRQ, NULL) != 0) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto failed;
 	}
drivers/net/wireless/orinoco/orinoco_nortel.c +1 -1
index 075f446..bc3ea0b 100644
@@ -220,7 +220,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
 		goto fail;
 	}
 
-	err = orinoco_if_add(priv, 0, 0);
+	err = orinoco_if_add(priv, 0, 0, NULL);
 	if (err) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto fail;
drivers/net/wireless/orinoco/orinoco_pci.c +1 -1
index bda5317..468197f 100644
@@ -170,7 +170,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
 		goto fail;
 	}
 
-	err = orinoco_if_add(priv, 0, 0);
+	err = orinoco_if_add(priv, 0, 0, NULL);
 	if (err) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto fail;
drivers/net/wireless/orinoco/orinoco_plx.c +1 -1
index e0d5874..9358f4d 100644
@@ -259,7 +259,7 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
 		goto fail;
 	}
 
-	err = orinoco_if_add(priv, 0, 0);
+	err = orinoco_if_add(priv, 0, 0, NULL);
 	if (err) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto fail;
drivers/net/wireless/orinoco/orinoco_tmd.c +1 -1
index 88cbc79..784605f 100644
@@ -156,7 +156,7 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
 		goto fail;
 	}
 
-	err = orinoco_if_add(priv, 0, 0);
+	err = orinoco_if_add(priv, 0, 0, NULL);
 	if (err) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto fail;
drivers/net/wireless/orinoco/spectrum_cs.c +1 -1
index 59bda24..77b5871 100644
@@ -374,7 +374,7 @@ spectrum_cs_config(struct pcmcia_device *link)
 
 	/* Register an interface with the stack */
 	if (orinoco_if_add(priv, link->io.BasePort1,
-			   link->irq.AssignedIRQ) != 0) {
+			   link->irq.AssignedIRQ, NULL) != 0) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto failed;
 	}
Signature · 1 line
1.6.4.4
#3 lore raw

RFC 3/5 orinoco: encapsulate driver locking

In reply to David Kilroy

Local bus and USB drivers will need to do locking differently.

The original orinoco_usb patches had a boolean variable controlling whether spin_lock_bh was used, or irq based locking. This version provides wrappers for the lock functions and the drivers specify the functions pointers needed.

This will introduce a performance penalty, but I'm not expecting it to be noticable.

---
 drivers/net/wireless/orinoco/hermes.c  |   26 +++++++++++++++++++++++++-
 drivers/net/wireless/orinoco/hermes.h  |    4 ++++
 drivers/net/wireless/orinoco/main.c    |   12 ++++++------
 drivers/net/wireless/orinoco/orinoco.h |   16 +++++++++++++---
 4 files changed, 48 insertions(+), 10 deletions(-)
drivers/net/wireless/orinoco/hermes.c +25 -1
index a7df524..6448366 100644
@@ -529,6 +529,26 @@ static int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
 	return err;
 }
 
+void hermes_lock_irqsave(spinlock_t *lock, unsigned long *flags)
+{
+	spin_lock_irqsave(lock, *flags);
+}
+
+void hermes_unlock_irqrestore(spinlock_t *lock, unsigned long *flags)
+{
+	spin_unlock_irqrestore(lock, *flags);
+}
+
+void hermes_lock_irq(spinlock_t *lock)
+{
+	spin_lock_irq(lock);
+}
+
+void hermes_unlock_irq(spinlock_t *lock)
+{
+	spin_unlock_irq(lock);
+}
+
 /* Hermes operations for local buses */
 static const struct hermes_ops hermes_ops_local = {
 	.init = hermes_init,
@@ -538,5 +558,9 @@ static const struct hermes_ops hermes_ops_local = {
 	.read_ltv = hermes_read_ltv,
 	.write_ltv = hermes_write_ltv,
 	.bap_pread = hermes_bap_pread,
-	.bap_pwrite = hermes_bap_pwrite
+	.bap_pwrite = hermes_bap_pwrite,
+	.lock_irqsave = hermes_lock_irqsave,
+	.unlock_irqrestore = hermes_unlock_irqrestore,
+	.lock_irq = hermes_lock_irq,
+	.unlock_irq = hermes_unlock_irq,
 };
drivers/net/wireless/orinoco/hermes.h +4 -0
index 18b268c..9e21ecd 100644
@@ -393,6 +393,10 @@ struct hermes_ops {
 			 u16 id, u16 offset);
 	int (*bap_pwrite)(struct hermes *hw, int bap, const void *buf,
 			  int len, u16 id, u16 offset);
+	void (*lock_irqsave)(spinlock_t *lock, unsigned long *flags);
+	void (*unlock_irqrestore)(spinlock_t *lock, unsigned long *flags);
+	void (*lock_irq)(spinlock_t *lock);
+	void (*unlock_irq)(spinlock_t *lock);
 };
 
 /* Basic control structure */
drivers/net/wireless/orinoco/main.c +6 -6
index 9dc458d..9485da2 100644
@@ -282,13 +282,13 @@ int orinoco_stop(struct net_device *dev)
 	/* We mustn't use orinoco_lock() here, because we need to be
 	   able to close the interface even if hw_unavailable is set
 	   (e.g. as we're released after a PC Card removal) */
-	spin_lock_irq(&priv->lock);
+	orinoco_lock_irq(priv);
 
 	priv->open = 0;
 
 	err = __orinoco_down(priv);
 
-	spin_unlock_irq(&priv->lock);
+	orinoco_unlock_irq(priv);
 
 	return err;
 }
@@ -1742,7 +1742,7 @@ void orinoco_reset(struct work_struct *work)
 	}
 
 	/* This has to be called from user context */
-	spin_lock_irq(&priv->lock);
+	orinoco_lock_irq(priv);
 
 	priv->hw_unavailable--;
 
@@ -1757,7 +1757,7 @@ void orinoco_reset(struct work_struct *work)
 			dev->trans_start = jiffies;
 	}
 
-	spin_unlock_irq(&priv->lock);
+	orinoco_unlock_irq(priv);
 
 	return;
  disable:
@@ -2074,9 +2074,9 @@ int orinoco_init(struct orinoco_private *priv)
 
 	/* Make the hardware available, as long as it hasn't been
 	 * removed elsewhere (e.g. by PCMCIA hot unplug) */
-	spin_lock_irq(&priv->lock);
+	orinoco_lock_irq(priv);
 	priv->hw_unavailable--;
-	spin_unlock_irq(&priv->lock);
+	orinoco_unlock_irq(priv);
 
 	dev_dbg(dev, "Ready\n");
 
drivers/net/wireless/orinoco/orinoco.h +13 -3
index f1901d6..80a1386 100644
@@ -212,11 +212,11 @@ void orinoco_tx_timeout(struct net_device *dev);
 static inline int orinoco_lock(struct orinoco_private *priv,
 			       unsigned long *flags)
 {
-	spin_lock_irqsave(&priv->lock, *flags);
+	priv->hw.ops->lock_irqsave(&priv->lock, flags);
 	if (priv->hw_unavailable) {
 		DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
 		       priv->ndev);
-		spin_unlock_irqrestore(&priv->lock, *flags);
+		priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
 		return -EBUSY;
 	}
 	return 0;
@@ -225,7 +225,17 @@ static inline int orinoco_lock(struct orinoco_private *priv,
 static inline void orinoco_unlock(struct orinoco_private *priv,
 				  unsigned long *flags)
 {
-	spin_unlock_irqrestore(&priv->lock, *flags);
+	priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
+}
+
+static inline void orinoco_lock_irq(struct orinoco_private *priv)
+{
+	priv->hw.ops->lock_irq(&priv->lock);
+}
+
+static inline void orinoco_unlock_irq(struct orinoco_private *priv)
+{
+	priv->hw.ops->unlock_irq(&priv->lock);
 }
 
 /*** Navigate from net_device to orinoco_private ***/
Signature · 1 line
1.6.4.4
#4 lore raw

RFC 4/5 orinoco: add orinoco_usb driver

In reply to David Kilroy

This driver uses the core orinoco modules for the bulk of the functionality. The low level hermes routines (for local bus cards) are replaced, the driver supplies its own ndo_xmit_start function, and locking is done with the _bh variant.

Some recent functionality is not available to the USB cards yet (firmware loading and WPA).

Out-of-tree driver originally written by Manuel Estrada Sainz.

Thanks to Mark Davis for supplying hardware to test the updates.

---
 drivers/net/wireless/orinoco/Kconfig       |    7 +
 drivers/net/wireless/orinoco/Makefile      |    1 +
 drivers/net/wireless/orinoco/hermes.h      |    1 +
 drivers/net/wireless/orinoco/main.c        |    6 +-
 drivers/net/wireless/orinoco/orinoco.h     |    3 +
 drivers/net/wireless/orinoco/orinoco_usb.c | 1678 ++++++++++++++++++++++++++++
 6 files changed, 1694 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/wireless/orinoco/orinoco_usb.c
drivers/net/wireless/orinoco/Kconfig +7 -0
index 6116b54..60819bc 100644
@@ -132,3 +132,10 @@ config PCMCIA_SPECTRUM
 	  This driver requires firmware download on startup.  Utilities
 	  for downloading Symbol firmware are available at
 	  <http://sourceforge.net/projects/orinoco/>
+
+config ORINOCO_USB
+	tristate "Agere Orinoco USB support"
+	depends on USB && HERMES
+	select FW_LOADER
+	---help---
+	  This driver is for USB versions of the Agere Orinoco card.
drivers/net/wireless/orinoco/Makefile +1 -0
index e645269..bfdefb8 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_PCI_HERMES)	+= orinoco_pci.o
 obj-$(CONFIG_TMD_HERMES)	+= orinoco_tmd.o
 obj-$(CONFIG_NORTEL_HERMES)	+= orinoco_nortel.o
 obj-$(CONFIG_PCMCIA_SPECTRUM)	+= spectrum_cs.o
+obj-$(CONFIG_ORINOCO_USB)	+= orinoco_usb.o
 
 # Orinoco should be endian clean.
 ccflags-y += -D__CHECK_ENDIAN__
drivers/net/wireless/orinoco/hermes.h +1 -0
index 9e21ecd..aed14ff 100644
@@ -407,6 +407,7 @@ typedef struct hermes {
 #define HERMES_32BIT_REGSPACING	1
 	u16 inten; /* Which interrupts should be enabled? */
 	const struct hermes_ops *ops;
+	void *priv;
 } hermes_t;
 
 /* Register access convenience macros */
drivers/net/wireless/orinoco/main.c +4 -2
index 9485da2..e48d6a0 100644
@@ -798,7 +798,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
 	stats->rx_dropped++;
 }
 
-static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
+void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	struct net_device_stats *stats = &priv->stats;
@@ -919,6 +919,7 @@ update_stats:
 out:
 	kfree(desc);
 }
+EXPORT_SYMBOL(__orinoco_ev_rx);
 
 static void orinoco_rx(struct net_device *dev,
 		       struct hermes_rx_descriptor *desc,
@@ -1360,7 +1361,7 @@ static void orinoco_process_scan_results(struct work_struct *work)
 	spin_unlock_irqrestore(&priv->scan_lock, flags);
 }
 
-static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
+void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
 {
 	struct orinoco_private *priv = ndev_priv(dev);
 	u16 infofid;
@@ -1578,6 +1579,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
 
 	return;
 }
+EXPORT_SYMBOL(__orinoco_ev_info);
 
 static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)
 {
drivers/net/wireless/orinoco/orinoco.h +3 -0
index 80a1386..e9f415a 100644
@@ -197,6 +197,9 @@ extern int orinoco_up(struct orinoco_private *priv);
 extern void orinoco_down(struct orinoco_private *priv);
 extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
 
+extern void __orinoco_ev_info(struct net_device *dev, hermes_t *hw);
+extern void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw);
+
 /* Common ndo functions exported for reuse by orinoco_usb */
 int orinoco_open(struct net_device *dev);
 int orinoco_stop(struct net_device *dev);
drivers/net/wireless/orinoco/orinoco_usb.c new file +1678 -0

1,678 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#5 lore raw

RFC 5/5 orinoco_usb: avoid in_atomic

In reply to David Kilroy

We expect to be either in process contect or soft interrupt context. So use in_softirq instead.

---
 drivers/net/wireless/orinoco/orinoco_usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/orinoco/orinoco_usb.c +1 -1
index eaec04e..1abc303 100644
@@ -701,7 +701,7 @@ static void ezusb_req_ctx_wait(struct ezusb_priv *upriv,
 	case EZUSB_CTX_REQ_SUBMITTED:
 	case EZUSB_CTX_REQ_COMPLETE:
 	case EZUSB_CTX_RESP_RECEIVED:
-		if (in_atomic()) {
+		if (in_softirq()) {
 			/* If we get called from a timer, timeout timers don't
 			 * get the chance to run themselves. So we make sure
 			 * that we don't sleep for ever */
Signature · 1 line
1.6.4.4