orinoco_pci.h 1.4 KB
Newer Older
1
/* orinoco_pci.h
A
Andrey Borzenkov 已提交
2
 *
3 4 5 6
 * Common code for all Orinoco drivers for PCI devices, including
 * both native PCI and PCMCIA-to-PCI bridges.
 *
 * Copyright (C) 2005, Pavel Roskin.
D
David Kilroy 已提交
7
 * See main.c for license.
8 9 10 11 12 13 14 15 16 17 18 19 20
 */

#ifndef _ORINOCO_PCI_H
#define _ORINOCO_PCI_H

#include <linux/netdevice.h>

/* Driver specific data */
struct orinoco_pci_card {
	void __iomem *bridge_io;
	void __iomem *attr_io;
};

21
#ifdef CONFIG_PM
22 23
static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
24
	struct orinoco_private *priv = pci_get_drvdata(pdev);
25

26
	orinoco_down(priv);
27
	free_irq(pdev->irq, priv);
28 29 30 31 32 33 34 35 36
	pci_save_state(pdev);
	pci_disable_device(pdev);
	pci_set_power_state(pdev, PCI_D3hot);

	return 0;
}

static int orinoco_pci_resume(struct pci_dev *pdev)
{
37 38
	struct orinoco_private *priv = pci_get_drvdata(pdev);
	struct net_device *dev = priv->ndev;
39 40 41
	int err;

	pci_set_power_state(pdev, 0);
42 43 44 45 46 47
	err = pci_enable_device(pdev);
	if (err) {
		printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
		       dev->name);
		return err;
	}
48 49
	pci_restore_state(pdev);

50
	err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
51
			  dev->name, priv);
52 53 54 55 56 57 58
	if (err) {
		printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
		       dev->name);
		pci_disable_device(pdev);
		return -EBUSY;
	}

59
	err = orinoco_up(priv);
60

61
	return err;
62
}
63 64 65 66
#else
#define orinoco_pci_suspend NULL
#define orinoco_pci_resume NULL
#endif
67 68

#endif /* _ORINOCO_PCI_H */