netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski-mXXj517/zsQ@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: orinoco-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 18/21] orinoco: support PCI suspend/resume for Nortel, PLX and TMD adaptors
Date: Fri, 07 Apr 2006 04:10:55 -0400	[thread overview]
Message-ID: <20060407081055.16107.7233.stgit@dv.roinet.com> (raw)
In-Reply-To: <20060407081019.16107.67672.stgit-fdEtzkpK75rby3iVrkZq2A@public.gmane.org>

From: Pavel Roskin <proski-mXXj517/zsQ@public.gmane.org>

Copy PCI suspend/resume functions from orinoco_pci.c.

Signed-off-by: Pavel Roskin <proski-mXXj517/zsQ@public.gmane.org>
---

 drivers/net/wireless/orinoco_nortel.c |   87 +++++++++++++++++++++++++++++++--
 drivers/net/wireless/orinoco_plx.c    |   79 ++++++++++++++++++++++++++++++
 drivers/net/wireless/orinoco_tmd.c    |   79 ++++++++++++++++++++++++++++++
 3 files changed, 241 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index d1a670b..3fff013 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -263,6 +263,83 @@ static void __devexit nortel_pci_remove_
 	pci_disable_device(pdev);
 }
 
+static int orinoco_nortel_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	err = orinoco_lock(priv, &flags);
+	if (err) {
+		printk(KERN_ERR "%s: cannot lock hardware for suspend\n",
+		       dev->name);
+		return err;
+	}
+
+	err = __orinoco_down(dev);
+	if (err)
+		printk(KERN_WARNING "%s: error %d bringing interface down "
+		       "for suspend\n", dev->name, err);
+	
+	netif_device_detach(dev);
+
+	priv->hw_unavailable++;
+	
+	orinoco_unlock(priv, &flags);
+
+	free_irq(pdev->irq, dev);
+	pci_save_state(pdev);
+	pci_disable_device(pdev);
+	pci_set_power_state(pdev, PCI_D3hot);
+
+	return 0;
+}
+
+static int orinoco_nortel_resume(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	pci_set_power_state(pdev, 0);
+	pci_enable_device(pdev);
+	pci_restore_state(pdev);
+
+	err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
+			  dev->name, dev);
+	if (err) {
+		printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
+		       dev->name);
+		pci_disable_device(pdev);
+		return -EBUSY;
+	}
+
+	err = orinoco_reinit_firmware(dev);
+	if (err) {
+		printk(KERN_ERR "%s: error %d re-initializing firmware "
+		       "on resume\n", dev->name, err);
+		return err;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	netif_device_attach(dev);
+
+	priv->hw_unavailable--;
+
+	if (priv->open && (! priv->hw_unavailable)) {
+		err = __orinoco_up(dev);
+		if (err)
+			printk(KERN_ERR "%s: Error %d restarting card on resume\n",
+			       dev->name, err);
+	}
+	
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
 
 static struct pci_device_id nortel_pci_id_table[] = {
 	/* Nortel emobility PCI */
@@ -275,10 +352,12 @@ static struct pci_device_id nortel_pci_i
 MODULE_DEVICE_TABLE(pci, nortel_pci_id_table);
 
 static struct pci_driver nortel_pci_driver = {
-	.name = DRIVER_NAME,
-	.id_table = nortel_pci_id_table,
-	.probe = nortel_pci_init_one,
-	.remove = __devexit_p(nortel_pci_remove_one),
+	.name		= DRIVER_NAME,
+	.id_table	= nortel_pci_id_table,
+	.probe		= nortel_pci_init_one,
+	.remove		= __devexit_p(nortel_pci_remove_one),
+	.suspend	= orinoco_nortel_suspend,
+	.resume		= orinoco_nortel_resume,
 };
 
 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
diff --git a/drivers/net/wireless/orinoco_plx.c b/drivers/net/wireless/orinoco_plx.c
index 210e737..3fe7a2f 100644
--- a/drivers/net/wireless/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco_plx.c
@@ -343,6 +343,83 @@ static void __devexit orinoco_plx_remove
 	pci_disable_device(pdev);
 }
 
+static int orinoco_plx_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	err = orinoco_lock(priv, &flags);
+	if (err) {
+		printk(KERN_ERR "%s: cannot lock hardware for suspend\n",
+		       dev->name);
+		return err;
+	}
+
+	err = __orinoco_down(dev);
+	if (err)
+		printk(KERN_WARNING "%s: error %d bringing interface down "
+		       "for suspend\n", dev->name, err);
+	
+	netif_device_detach(dev);
+
+	priv->hw_unavailable++;
+	
+	orinoco_unlock(priv, &flags);
+
+	free_irq(pdev->irq, dev);
+	pci_save_state(pdev);
+	pci_disable_device(pdev);
+	pci_set_power_state(pdev, PCI_D3hot);
+
+	return 0;
+}
+
+static int orinoco_plx_resume(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	pci_set_power_state(pdev, 0);
+	pci_enable_device(pdev);
+	pci_restore_state(pdev);
+
+	err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
+			  dev->name, dev);
+	if (err) {
+		printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
+		       dev->name);
+		pci_disable_device(pdev);
+		return -EBUSY;
+	}
+
+	err = orinoco_reinit_firmware(dev);
+	if (err) {
+		printk(KERN_ERR "%s: error %d re-initializing firmware "
+		       "on resume\n", dev->name, err);
+		return err;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	netif_device_attach(dev);
+
+	priv->hw_unavailable--;
+
+	if (priv->open && (! priv->hw_unavailable)) {
+		err = __orinoco_up(dev);
+		if (err)
+			printk(KERN_ERR "%s: Error %d restarting card on resume\n",
+			       dev->name, err);
+	}
+	
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
 
 static struct pci_device_id orinoco_plx_pci_id_table[] = {
 	{0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,},	/* Siemens SpeedStream SS1023 */
@@ -369,6 +446,8 @@ static struct pci_driver orinoco_plx_dri
 	.id_table	= orinoco_plx_pci_id_table,
 	.probe		= orinoco_plx_init_one,
 	.remove		= __devexit_p(orinoco_plx_remove_one),
+	.suspend	= orinoco_plx_suspend,
+	.resume		= orinoco_plx_resume,
 };
 
 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
diff --git a/drivers/net/wireless/orinoco_tmd.c b/drivers/net/wireless/orinoco_tmd.c
index 5e68b70..b74807d 100644
--- a/drivers/net/wireless/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco_tmd.c
@@ -215,6 +215,83 @@ static void __devexit orinoco_tmd_remove
 	pci_disable_device(pdev);
 }
 
+static int orinoco_tmd_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	err = orinoco_lock(priv, &flags);
+	if (err) {
+		printk(KERN_ERR "%s: cannot lock hardware for suspend\n",
+		       dev->name);
+		return err;
+	}
+
+	err = __orinoco_down(dev);
+	if (err)
+		printk(KERN_WARNING "%s: error %d bringing interface down "
+		       "for suspend\n", dev->name, err);
+	
+	netif_device_detach(dev);
+
+	priv->hw_unavailable++;
+	
+	orinoco_unlock(priv, &flags);
+
+	free_irq(pdev->irq, dev);
+	pci_save_state(pdev);
+	pci_disable_device(pdev);
+	pci_set_power_state(pdev, PCI_D3hot);
+
+	return 0;
+}
+
+static int orinoco_tmd_resume(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	struct orinoco_private *priv = netdev_priv(dev);
+	unsigned long flags;
+	int err;
+
+	pci_set_power_state(pdev, 0);
+	pci_enable_device(pdev);
+	pci_restore_state(pdev);
+
+	err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
+			  dev->name, dev);
+	if (err) {
+		printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
+		       dev->name);
+		pci_disable_device(pdev);
+		return -EBUSY;
+	}
+
+	err = orinoco_reinit_firmware(dev);
+	if (err) {
+		printk(KERN_ERR "%s: error %d re-initializing firmware "
+		       "on resume\n", dev->name, err);
+		return err;
+	}
+
+	spin_lock_irqsave(&priv->lock, flags);
+
+	netif_device_attach(dev);
+
+	priv->hw_unavailable--;
+
+	if (priv->open && (! priv->hw_unavailable)) {
+		err = __orinoco_up(dev);
+		if (err)
+			printk(KERN_ERR "%s: Error %d restarting card on resume\n",
+			       dev->name, err);
+	}
+	
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
 
 static struct pci_device_id orinoco_tmd_pci_id_table[] = {
 	{0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,},      /* NDC and OEMs, e.g. pheecom */
@@ -228,6 +305,8 @@ static struct pci_driver orinoco_tmd_dri
 	.id_table	= orinoco_tmd_pci_id_table,
 	.probe		= orinoco_tmd_init_one,
 	.remove		= __devexit_p(orinoco_tmd_remove_one),
+	.suspend	= orinoco_tmd_suspend,
+	.resume		= orinoco_tmd_resume,
 };
 
 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

  parent reply	other threads:[~2006-04-07  8:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-07  8:10 [PATCH 01/21] orinoco: Remove useless CIS validation Pavel Roskin
     [not found] ` <20060407081019.16107.67672.stgit-fdEtzkpK75rby3iVrkZq2A@public.gmane.org>
2006-04-07  8:10   ` [PATCH 02/21] orinoco: remove PCMCIA audio support, it's useless for wireless cards Pavel Roskin
2006-04-07  8:10   ` [PATCH 03/21] orinoco: remove underscores from little-endian field names Pavel Roskin
2006-04-07  8:10   ` [PATCH 04/21] orinoco: fix truncating commsquality RID with the latest Symbol firmware Pavel Roskin
2006-04-07  8:10   ` [PATCH 05/21] orinoco: remove tracing code, it's unused Pavel Roskin
2006-04-07  8:10   ` [PATCH 06/21] orinoco: remove debug buffer code and userspace include support Pavel Roskin
2006-04-07  8:10   ` [PATCH 07/21] orinoco: Symbol card supported by spectrum_cs is LA4137, not LA4100 Pavel Roskin
2006-04-07  8:10   ` [PATCH 08/21] orinoco: optimize Tx exception handling in orinoco Pavel Roskin
2006-04-07  8:10   ` [PATCH 09/21] orinoco: orinoco_xmit() should only return valid symbolic constants Pavel Roskin
2006-04-07  8:10   ` [PATCH 10/21] orinoco replace hermes_write_words() with hermes_write_bytes() Pavel Roskin
2006-04-07  8:10   ` [PATCH 11/21] orinoco: don't use any padding for Tx frames Pavel Roskin
2006-04-07  8:10   ` [PATCH 12/21] orinoco: refactor and clean up Tx error handling Pavel Roskin
2006-04-07  8:10   ` [PATCH 13/21] orinoco: simplify 802.3 encapsulation code Pavel Roskin
2006-04-07  8:10   ` [PATCH 14/21] orinoco: fix BAP0 offset error after several days of operation Pavel Roskin
2006-04-07  8:10   ` [PATCH 15/21] orinoco: delay FID allocation after firmware initialization Pavel Roskin
2006-04-07  8:10   ` [PATCH 16/21] orinoco_pci: disable device and free IRQ when suspending Pavel Roskin
     [not found]     ` <20060407081051.16107.87289.stgit-fdEtzkpK75rby3iVrkZq2A@public.gmane.org>
2006-04-07 21:24       ` Francois Romieu
     [not found]         ` <20060407212429.GA15720-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2006-04-07 22:12           ` Pavel Roskin
2006-04-07 23:08             ` Francois Romieu
2006-04-07  8:10   ` [PATCH 17/21] orinoco_pci: use pci_iomap() for resources Pavel Roskin
     [not found]     ` <20060407081053.16107.19347.stgit-fdEtzkpK75rby3iVrkZq2A@public.gmane.org>
2006-04-07 21:36       ` Francois Romieu
     [not found]         ` <20060407213619.GB15720-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2006-04-07 22:21           ` Pavel Roskin
2006-04-07 23:38             ` Francois Romieu
     [not found]               ` <20060407233819.GB15667-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2006-04-08  0:07                 ` Pavel Roskin
     [not found]                   ` <20060407200731.mqskowo8808gccs8-2RFepEojUI3Rd1RZctBqVdHuzzzSOjJt@public.gmane.org>
2006-04-08 15:00                     ` Jeff Garzik
2006-04-07  8:10   ` Pavel Roskin [this message]
2006-04-07  8:10   ` [PATCH 19/21] orinoco: reduce differences between PCI drivers, create orinoco_pci.h Pavel Roskin
     [not found]     ` <20060407081057.16107.82106.stgit-fdEtzkpK75rby3iVrkZq2A@public.gmane.org>
2006-04-07 22:10       ` Francois Romieu
     [not found]         ` <20060407221041.GC15720-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2006-04-07 22:43           ` Pavel Roskin
2006-04-07  8:11   ` [PATCH 20/21] orinoco: further comment cleanup in the PCI drivers Pavel Roskin
2006-04-07  8:11   ` [PATCH 21/21] orinoco: bump version to 0.15 Pavel Roskin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060407081055.16107.7233.stgit@dv.roinet.com \
    --to=proski-mxxj517/zsq@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=orinoco-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).