From: Hauke Mehrtens Date: Sat, 1 Jan 2011 14:23:35 +0000 (-0800) Subject: compat: add generic functions for suspend/resume X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=dcd6955e683d812efef2df62deb4d19d9a15339a;p=openwrt%2Fstaging%2Fblogic.git compat: add generic functions for suspend/resume 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 --- diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 78b2d58d273a..b4e123691edf 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -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 */