Skip to contentSkip to conversation

rtl818x_pci: use generic power management

PATCH In review Vaibhav Gupta 2 participants 3 messages Jun 23, 2020 – Jul 15, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtl818x_pci: use generic power management

Earlier, drivers had to manage the device's power states, and related operations, themselves. With the generic approach, these are done by PCI core.

The only driver-specific jobs, .suspend() and .resume() doing were invoking PCI helper functions pci_save/restore_state() and pci_set_power_state(). This is not recommeneded as PCI core takes care of that. Hence they became empty-body functions, thus define them NULL.

Compile-tested only.

---
 .../wireless/realtek/rtl818x/rtl8180/dev.c    | 23 ++++---------------
 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c +4 -19
index d5f65372356b..ba3286f732cc 100644
@@ -1966,32 +1966,17 @@ static void rtl8180_remove(struct pci_dev *pdev)
 	ieee80211_free_hw(dev);
 }
 
-#ifdef CONFIG_PM
-static int rtl8180_suspend(struct pci_dev *pdev, pm_message_t state)
-{
-	pci_save_state(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-	return 0;
-}
-
-static int rtl8180_resume(struct pci_dev *pdev)
-{
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-	return 0;
-}
+#define rtl8180_suspend NULL
+#define rtl8180_resume NULL
 
-#endif /* CONFIG_PM */
+static SIMPLE_DEV_PM_OPS(rtl8180_pm_ops, rtl8180_suspend, rtl8180_resume);
 
 static struct pci_driver rtl8180_driver = {
 	.name		= KBUILD_MODNAME,
 	.id_table	= rtl8180_table,
 	.probe		= rtl8180_probe,
 	.remove		= rtl8180_remove,
-#ifdef CONFIG_PM
-	.suspend	= rtl8180_suspend,
-	.resume		= rtl8180_resume,
-#endif /* CONFIG_PM */
+	.driver.pm	= &rtl8180_pm_ops,
 };
 
 module_pci_driver(rtl8180_driver);
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 4 lines · Vaibhav Gupta

Earlier, drivers had to manage the device's power states, and related operations, themselves. With the generic approach, these are done by PCI core.

Quoted 8 lines

The only driver-specific jobs, .suspend() and .resume() doing were invoking PCI helper functions pci_save/restore_state() and pci_set_power_state(). This is not recommeneded as PCI core takes care of that. Hence they became empty-body functions, thus define them NULL.

Compile-tested only.

Patch applied to wireless-drivers-next.git, thanks.

ef6425107ccc rtl818x_pci: use generic power management

Signature · 3 lines
https://patchwork.kernel.org/patch/11620213/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#2 lore raw
In reply to Vaibhav Gupta
Quoted 4 lines · Vaibhav Gupta

Earlier, drivers had to manage the device's power states, and related operations, themselves. With the generic approach, these are done by PCI core.

Quoted 8 lines

The only driver-specific jobs, .suspend() and .resume() doing were invoking PCI helper functions pci_save/restore_state() and pci_set_power_state(). This is not recommeneded as PCI core takes care of that. Hence they became empty-body functions, thus define them NULL.

Compile-tested only.

Patch applied to wireless-drivers-next.git, thanks.

ef6425107ccc rtl818x_pci: use generic power management

Signature · 8 lines
https://patchwork.kernel.org/patch/11620213/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees