From patchwork Wed Oct 7 06:30:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 52164 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n976aKA8027610 for ; Wed, 7 Oct 2009 06:36:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756289AbZJGGbT (ORCPT ); Wed, 7 Oct 2009 02:31:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754987AbZJGGbT (ORCPT ); Wed, 7 Oct 2009 02:31:19 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:40032 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755186AbZJGGbS (ORCPT ); Wed, 7 Oct 2009 02:31:18 -0400 Received: from mcgrof by bombadil.infradead.org with local (Exim 4.69 #1 (Red Hat Linux)) id 1MvQ2p-0005qJ-Ag; Wed, 07 Oct 2009 06:30:39 +0000 Date: Wed, 7 Oct 2009 02:30:39 -0400 From: "Luis R. Rodriguez" To: "Luis R. Rodriguez" Cc: Hin-Tak Leung , linux-wireless@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH] compat-2.6: adding ethtool.h to compat-2.6.31.h Message-ID: <20091007063039.GA19944@bombadil.infradead.org> References: <1254886762-17211-1-git-send-email-HinTak.Leung@gmail.com> <3ace41890910062045s626777dew4b47fe18bc8d9aee@mail.gmail.com> <43e72e890910062241k3c4660eaobbcee4456485be93@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <43e72e890910062241k3c4660eaobbcee4456485be93@mail.gmail.com> User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org diff --git a/compat/compat-2.6.32.h b/compat/compat-2.6.32.h index 418b521..9c2dba9 100644 --- a/compat/compat-2.6.32.h +++ b/compat/compat-2.6.32.h @@ -8,6 +8,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) #include +#include #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 @@ -43,6 +44,31 @@ enum netdev_tx { typedef enum netdev_tx netdev_tx_t; #endif /* __KERNEL__ */ + +/* + * dev_pm_ops is only available on kernels >= 2.6.29, for + * older kernels we rely on reverting the work to old + * power management style stuff. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) +/* + * Use this if you want to use the same suspend and resume callbacks for suspend + * to RAM and hibernation. + */ +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ +struct dev_pm_ops name = { \ + .suspend = suspend_fn, \ + .resume = resume_fn, \ + .freeze = suspend_fn, \ + .thaw = resume_fn, \ + .poweroff = suspend_fn, \ + .restore = resume_fn, \ +} +#else +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) +#endif /* >= 2.6.29 */ + + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ #endif /* LINUX_26_32_COMPAT_H */ diff --git a/compat/patches/11-dev-pm-ops.patch b/compat/patches/11-dev-pm-ops.patch new file mode 100644 index 0000000..e01eafc --- /dev/null +++ b/compat/patches/11-dev-pm-ops.patch @@ -0,0 +1,57 @@ +The 2.6.29 kernel has new struct dev_pm_ops [1] which are used +on the pci device to distinguish power management hooks for suspend +to RAM and hibernation. Older kernels don't have these so we need +to resort back to the good ol' suspend/resume. Fortunately the calls +are not so different so it should be possible to resuse the same +calls on compat code with only slight modifications. + +[1] http://lxr.linux.no/#linux+v2.6.29/include/linux/pm.h#L170 + +--- a/drivers/net/wireless/ath/ath5k/base.c 2009-10-07 01:58:19.000000000 -0400 ++++ b/drivers/net/wireless/ath/ath5k/base.c 2009-10-07 02:19:58.000000000 -0400 +@@ -197,6 +197,32 @@ + #ifdef CONFIG_PM + static int ath5k_pci_suspend(struct device *dev); + static int ath5k_pci_resume(struct device *dev); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) ++#endif ++static int ath5k_pci_suspend_compat(struct pci_dev *pdev, pm_message_t state) ++{ ++ int r; ++ ++ r = ath5k_pci_suspend(pdev->dev); ++ if (r) ++ return r; ++ ++ pci_save_state(pdev); ++ pci_disable_device(pdev); ++ pci_set_power_state(pdev, PCI_D3hot); ++} ++ ++static int ath5k_pci_resume_compat(struct pci_dev *pdev) ++{ ++ int r; ++ ++ pci_restore_state(pdev); ++ r = pci_enable_device(pdev); ++ if (r) ++ return r; ++ ++ return ath5k_pci_resume(pdev->dev); ++} + + SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume); + #define ATH5K_PM_OPS (&ath5k_pm_ops) +@@ -209,7 +235,12 @@ + .id_table = ath5k_pci_id_table, + .probe = ath5k_pci_probe, + .remove = __devexit_p(ath5k_pci_remove), ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) + .driver.pm = ATH5K_PM_OPS, ++#else ++ .suspend = ath5k_pci_suspend_compat, ++ .resume = ath5k_pci_resume_compat, ++#endif + }; + +