orinoco_pci.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* orinoco_pci.h
  2. *
  3. * Common code for all Orinoco drivers for PCI devices, including
  4. * both native PCI and PCMCIA-to-PCI bridges.
  5. *
  6. * Copyright (C) 2005, Pavel Roskin.
  7. * See main.c for license.
  8. */
  9. #ifndef _ORINOCO_PCI_H
  10. #define _ORINOCO_PCI_H
  11. #include <linux/netdevice.h>
  12. /* Driver specific data */
  13. struct orinoco_pci_card {
  14. void __iomem *bridge_io;
  15. void __iomem *attr_io;
  16. };
  17. #ifdef CONFIG_PM
  18. static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
  19. {
  20. struct orinoco_private *priv = pci_get_drvdata(pdev);
  21. orinoco_down(priv);
  22. free_irq(pdev->irq, priv);
  23. pci_save_state(pdev);
  24. pci_disable_device(pdev);
  25. pci_set_power_state(pdev, PCI_D3hot);
  26. return 0;
  27. }
  28. static int orinoco_pci_resume(struct pci_dev *pdev)
  29. {
  30. struct orinoco_private *priv = pci_get_drvdata(pdev);
  31. struct net_device *dev = priv->ndev;
  32. int err;
  33. pci_set_power_state(pdev, PCI_D0);
  34. err = pci_enable_device(pdev);
  35. if (err) {
  36. printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
  37. dev->name);
  38. return err;
  39. }
  40. pci_restore_state(pdev);
  41. err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
  42. dev->name, priv);
  43. if (err) {
  44. printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
  45. dev->name);
  46. pci_disable_device(pdev);
  47. return -EBUSY;
  48. }
  49. err = orinoco_up(priv);
  50. return err;
  51. }
  52. #else
  53. #define orinoco_pci_suspend NULL
  54. #define orinoco_pci_resume NULL
  55. #endif
  56. #endif /* _ORINOCO_PCI_H */