linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] driver: gpio-bt8xx: use generic PCI PM
@ 2025-10-10 10:53 Vaibhav Gupta
  2025-10-11  1:43 ` kernel test robot
  0 siblings, 1 reply; 23+ messages in thread
From: Vaibhav Gupta @ 2025-10-10 10:53 UTC (permalink / raw)
  To: Michael Buesch
  Cc: Vaibhav Gupta, Bjorn Helgaas, Linus Walleij, Bartosz Golaszewski,
	linux-gpio, linux-kernel

Switch to the new generic PCI power management framework and remove legacy
callbacks like .suspend() and .resume(). With the generic framework, the
standard PCI related work like:
	- pci_save/restore_state()
	- pci_enable/disable_device()
	- pci_set_power_state()
is handled by the PCI core and this driver should implement only gpio-bt8xx
specific operations in its respective callback functions.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/gpio/gpio-bt8xx.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c
index 05401da03ca3..e8d0c67bb618 100644
--- a/drivers/gpio/gpio-bt8xx.c
+++ b/drivers/gpio/gpio-bt8xx.c
@@ -224,9 +224,9 @@ static void bt8xxgpio_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
-#ifdef CONFIG_PM
-static int bt8xxgpio_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused bt8xxgpio_suspend(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct bt8xxgpio *bg = pci_get_drvdata(pdev);
 
 	scoped_guard(spinlock_irqsave, &bg->lock) {
@@ -238,23 +238,13 @@ static int bt8xxgpio_suspend(struct pci_dev *pdev, pm_message_t state)
 		bgwrite(0x0, BT848_GPIO_OUT_EN);
 	}
 
-	pci_save_state(pdev);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-
 	return 0;
 }
 
-static int bt8xxgpio_resume(struct pci_dev *pdev)
+static int __maybe_unused bt8xxgpio_resume(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct bt8xxgpio *bg = pci_get_drvdata(pdev);
-	int err;
-
-	pci_set_power_state(pdev, PCI_D0);
-	err = pci_enable_device(pdev);
-	if (err)
-		return err;
-	pci_restore_state(pdev);
 
 	guard(spinlock_irqsave)(&bg->lock);
 
@@ -267,10 +257,8 @@ static int bt8xxgpio_resume(struct pci_dev *pdev)
 
 	return 0;
 }
-#else
-#define bt8xxgpio_suspend NULL
-#define bt8xxgpio_resume NULL
-#endif /* CONFIG_PM */
+
+static SIMPLE_DEV_PM_OPS(bt8xxgpio_pm_ops, bt8xxgpio_suspend, bt8xxgpio_resume);
 
 static const struct pci_device_id bt8xxgpio_pci_tbl[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848) },
@@ -286,8 +274,7 @@ static struct pci_driver bt8xxgpio_pci_driver = {
 	.id_table	= bt8xxgpio_pci_tbl,
 	.probe		= bt8xxgpio_probe,
 	.remove		= bt8xxgpio_remove,
-	.suspend	= bt8xxgpio_suspend,
-	.resume		= bt8xxgpio_resume,
+	.driver.pm	= &bt8xxgpio_pm_ops,
 };
 
 module_pci_driver(bt8xxgpio_pci_driver);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-10-23  7:59 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10 10:53 [PATCH v1] driver: gpio-bt8xx: use generic PCI PM Vaibhav Gupta
2025-10-11  1:43 ` kernel test robot
2025-10-11 10:26   ` Michael Büsch
2025-10-11 11:32     ` Vaibhav Gupta
2025-10-11 12:31       ` Michael Büsch
2025-10-11 12:37         ` Vaibhav Gupta
2025-10-11 12:57         ` [PATCH v3] " Vaibhav Gupta
2025-10-13 11:04           ` [PATCH v4] driver: gpio: bt8xx: " Vaibhav Gupta
2025-10-11 12:32       ` [PATCH v2] driver: gpio-bt8xx: " Vaibhav Gupta
2025-10-13  9:41       ` [PATCH v1] " Bartosz Golaszewski
2025-10-13 11:03         ` Vaibhav Gupta
2025-10-13 15:36           ` Bartosz Golaszewski
2025-10-13 15:51             ` Vaibhav Gupta
2025-10-13 15:52               ` [PATCH v5] gpio: bt8xx: " Vaibhav Gupta
2025-10-13 17:43                 ` Bjorn Helgaas
2025-10-16 16:36                   ` [PATCH v6] gpio: bt8xx: use generic power management Vaibhav Gupta
2025-10-21  8:48                     ` Bartosz Golaszewski
2025-10-22 19:29                       ` Bjorn Helgaas
2025-10-23  7:49                         ` Vaibhav Gupta
2025-10-23  7:55                           ` Bartosz Golaszewski
2025-10-23  7:58                             ` Vaibhav Gupta
2025-10-23  7:59                     ` Bartosz Golaszewski
2025-10-16 16:37                   ` [PATCH v5] gpio: bt8xx: use generic PCI PM Vaibhav Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).