]> git.openfabrics.org - compat-rdma/compat.git/commitdiff
compat: add generic functions for suspend/resume
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 1 Jan 2011 14:23:35 +0000 (06:23 -0800)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 5 Jan 2011 23:20:09 +0000 (15:20 -0800)
This define is used to generate a suspend and a resume function for pci
devices using the old power management interface. The new interface was
introduced in kernel 2.6.29.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
include/linux/compat-2.6.29.h

index 78b2d58d273af0a03e600f0b41efb881af2bc1e1..b4e123691edf6ecc7731e38959b2e6461326b831 100644 (file)
@@ -278,6 +278,36 @@ static inline struct net *read_pnet(struct net * const *pnet)
 
 extern int             init_dummy_netdev(struct net_device *dev);
 
+#define compat_pci_suspend(fn)                                         \
+       int fn##_compat(struct pci_dev *pdev, pm_message_t state)       \
+       {                                                               \
+               int r;                                                  \
+                                                                       \
+               r = fn(&pdev->dev);                                     \
+               if (r)                                                  \
+                       return r;                                       \
+                                                                       \
+               pci_save_state(pdev);                                   \
+               pci_disable_device(pdev);                               \
+               pci_set_power_state(pdev, PCI_D3hot);                   \
+                                                                       \
+               return 0;                                               \
+       }
+
+#define compat_pci_resume(fn)                                          \
+       int fn##_compat(struct pci_dev *pdev)                           \
+       {                                                               \
+               int r;                                                  \
+                                                                       \
+               pci_set_power_state(pdev, PCI_D0);                      \
+               r = pci_enable_device(pdev);                            \
+               if (r)                                                  \
+                       return r;                                       \
+               pci_restore_state(pdev);                                \
+                                                                       \
+               return fn(&pdev->dev);                                  \
+       }
+
 #else
 
 static inline void netdev_attach_ops(struct net_device *dev,
@@ -285,6 +315,10 @@ static inline void netdev_attach_ops(struct net_device *dev,
 {
        dev->netdev_ops = ops;
 }
+
+#define compat_pci_suspend(fn)
+#define compat_pci_resume(fn)
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
 
 #endif /*  LINUX_26_29_COMPAT_H */