Skip to content

Commit

Permalink
iwlwifi: Convert to new PCI PM framework
Browse files Browse the repository at this point in the history
Use the new PCI PM and let the PCI core code handle the PCI-specific
details of power transitions.

Based on similarly titled ath9k patch posted by Rafael J. Wysocki.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
  • Loading branch information
John W. Linville committed Nov 15, 2010
1 parent b923757 commit f60dc01
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
5 changes: 1 addition & 4 deletions drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4838,10 +4838,7 @@ static struct pci_driver iwl_driver = {
.id_table = iwl_hw_card_ids,
.probe = iwl_pci_probe,
.remove = __devexit_p(iwl_pci_remove),
#ifdef CONFIG_PM
.suspend = iwl_pci_suspend,
.resume = iwl_pci_resume,
#endif
.driver.pm = IWL_PM_OPS,
};

static int __init iwl_init(void)
Expand Down
26 changes: 14 additions & 12 deletions drivers/net/wireless/iwlwifi/iwl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,8 +2592,9 @@ EXPORT_SYMBOL(iwl_add_beacon_time);

#ifdef CONFIG_PM

int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
int iwl_pci_suspend(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct iwl_priv *priv = pci_get_drvdata(pdev);

/*
Expand All @@ -2605,18 +2606,14 @@ int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
*/
iwl_apm_stop(priv);

pci_save_state(pdev);
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);

return 0;
}
EXPORT_SYMBOL(iwl_pci_suspend);

int iwl_pci_resume(struct pci_dev *pdev)
int iwl_pci_resume(struct device *device)
{
struct pci_dev *pdev = to_pci_dev(device);
struct iwl_priv *priv = pci_get_drvdata(pdev);
int ret;
bool hw_rfkill = false;

/*
Expand All @@ -2625,11 +2622,6 @@ int iwl_pci_resume(struct pci_dev *pdev)
*/
pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);

pci_set_power_state(pdev, PCI_D0);
ret = pci_enable_device(pdev);
if (ret)
return ret;
pci_restore_state(pdev);
iwl_enable_interrupts(priv);

if (!(iwl_read32(priv, CSR_GP_CNTRL) &
Expand All @@ -2647,4 +2639,14 @@ int iwl_pci_resume(struct pci_dev *pdev)
}
EXPORT_SYMBOL(iwl_pci_resume);

const struct dev_pm_ops iwl_pm_ops = {
.suspend = iwl_pci_suspend,
.resume = iwl_pci_resume,
.freeze = iwl_pci_suspend,
.thaw = iwl_pci_resume,
.poweroff = iwl_pci_suspend,
.restore = iwl_pci_resume,
};
EXPORT_SYMBOL(iwl_pm_ops);

#endif /* CONFIG_PM */
14 changes: 11 additions & 3 deletions drivers/net/wireless/iwlwifi/iwl-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,17 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base,
u32 addon, u32 beacon_interval);

#ifdef CONFIG_PM
int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state);
int iwl_pci_resume(struct pci_dev *pdev);
#endif /* CONFIG_PM */
int iwl_pci_suspend(struct device *device);
int iwl_pci_resume(struct device *device);
extern const struct dev_pm_ops iwl_pm_ops;

#define IWL_PM_OPS (&iwl_pm_ops)

#else /* !CONFIG_PM */

#define IWL_PM_OPS NULL

#endif /* !CONFIG_PM */

/*****************************************************
* Error Handling Debugging
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/wireless/iwlwifi/iwl3945-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -4275,10 +4275,7 @@ static struct pci_driver iwl3945_driver = {
.id_table = iwl3945_hw_card_ids,
.probe = iwl3945_pci_probe,
.remove = __devexit_p(iwl3945_pci_remove),
#ifdef CONFIG_PM
.suspend = iwl_pci_suspend,
.resume = iwl_pci_resume,
#endif
.driver.pm = IWL_PM_OPS,
};

static int __init iwl3945_init(void)
Expand Down

0 comments on commit f60dc01

Please sign in to comment.