mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 2.5] 3c59x.c: pci_{save,restore}_extended_state
@ 2003-01-24 18:26 Ivan Kokshaysky
  0 siblings, 0 replies; only message in thread
From: Ivan Kokshaysky @ 2003-01-24 18:26 UTC (permalink / raw)
  To: Jeff Garzik, David S. Miller, willy; +Cc: linux-kernel

This one is kind of example of converting to new
pci_XX_extended_state stuff.
I used 3c905B to test the changes, but it has only
the PM capability and actually works fine with just
pci_{save,restore}_state.

Ivan.

--- 2.5.59/drivers/net/3c59x.c	Fri Jan 17 05:21:33 2003
+++ linux/drivers/net/3c59x.c	Tue Jan 21 15:55:20 2003
@@ -814,7 +814,7 @@ struct vortex_private {
 	u16 io_size;						/* Size of PCI region (for release_region) */
 	spinlock_t lock;					/* Serialise access to device & its vortex_private */
 	spinlock_t mdio_lock;				/* Serialise access to mdio hardware */
-	u32 power_state[16];
+	u32 *power_state;
 };
 
 #define DEVICE_PCI(dev) (((dev)->bus == &pci_bus_type) ? to_pci_dev((dev)) : NULL)
@@ -1142,6 +1142,13 @@ static int __devinit vortex_probe1(struc
 		if (request_region(ioaddr, vci->io_size, print_name) != NULL)
 			vp->must_free_region = 1;
 
+		vp->power_state = pci_alloc_extended_state(pdev);
+		if (!vp->power_state) {
+			printk (KERN_ERR PFX "unable to allocate "
+				"power_state buffer, aborting\n");
+			goto free_region;
+		}
+
 		/* enable bus-mastering if necessary */		
 		if (vci->flags & PCI_USES_MASTER)
 			pci_set_master (pdev);
@@ -1172,7 +1179,6 @@ static int __devinit vortex_probe1(struc
 	vp->rx_ring = pci_alloc_consistent(pdev, sizeof(struct boom_rx_desc) * RX_RING_SIZE
 					   + sizeof(struct boom_tx_desc) * TX_RING_SIZE,
 					   &vp->rx_ring_dma);
-	retval = -ENOMEM;
 	if (vp->rx_ring == 0)
 		goto free_region;
 
@@ -1435,7 +1441,7 @@ static int __devinit vortex_probe1(struc
 	dev->watchdog_timeo = (watchdog * HZ) / 1000;
 	if (pdev && vp->enable_wol) {
 		vp->pm_state_valid = 1;
- 		pci_save_state(VORTEX_PCI(vp), vp->power_state);
+ 		pci_save_extended_state(VORTEX_PCI(vp), vp->power_state);
  		acpi_set_WOL(dev);
 	}
 	retval = register_netdev(dev);
@@ -1492,7 +1498,7 @@ vortex_up(struct net_device *dev)
 
 	if (VORTEX_PCI(vp) && vp->enable_wol) {
 		pci_set_power_state(VORTEX_PCI(vp), 0);	/* Go active */
-		pci_restore_state(VORTEX_PCI(vp), vp->power_state);
+		pci_restore_extended_state(VORTEX_PCI(vp), vp->power_state);
 	}
 
 	/* Before initializing select the active media port. */
@@ -2632,7 +2638,7 @@ vortex_down(struct net_device *dev)
 		outl(0, ioaddr + DownListPtr);
 
 	if (VORTEX_PCI(vp) && vp->enable_wol) {
-		pci_save_state(VORTEX_PCI(vp), vp->power_state);
+		pci_save_extended_state(VORTEX_PCI(vp), vp->power_state);
 		acpi_set_WOL(dev);
 	}
 }
@@ -3024,7 +3030,9 @@ static void __devexit vortex_remove_one 
 	if (VORTEX_PCI(vp) && vp->enable_wol) {
 		pci_set_power_state(VORTEX_PCI(vp), 0);	/* Go active */
 		if (vp->pm_state_valid)
-			pci_restore_state(VORTEX_PCI(vp), vp->power_state);
+			pci_restore_extended_state(VORTEX_PCI(vp),
+						   vp->power_state);
+		kfree(vp->power_state);
 	}
 
 	pci_free_consistent(pdev,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-24 18:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-24 18:26 [patch 2.5] 3c59x.c: pci_{save,restore}_extended_state Ivan Kokshaysky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®