Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: ml-ioh: Convert to dev_pm_ops

Convert the legacy callback .suspend() and .resume()
to the generic ones.

While at it, replace ifdeffery by __maybe_unused attribute.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

authored by

Vaibhav Gupta and committed by
Andy Shevchenko
40bb0e3e e73f0f0e

+11 -38
+11 -38
drivers/gpio/gpio-ml-ioh.c
··· 155 155 return 0; 156 156 } 157 157 158 - #ifdef CONFIG_PM 159 158 /* 160 159 * Save register configuration and disable interrupts. 161 160 */ 162 - static void ioh_gpio_save_reg_conf(struct ioh_gpio *chip) 161 + static void __maybe_unused ioh_gpio_save_reg_conf(struct ioh_gpio *chip) 163 162 { 164 163 int i; 165 164 ··· 184 185 /* 185 186 * This function restores the register configuration of the GPIO device. 186 187 */ 187 - static void ioh_gpio_restore_reg_conf(struct ioh_gpio *chip) 188 + static void __maybe_unused ioh_gpio_restore_reg_conf(struct ioh_gpio *chip) 188 189 { 189 190 int i; 190 191 ··· 206 207 &chip->reg->ioh_sel_reg[i]); 207 208 } 208 209 } 209 - #endif 210 210 211 211 static int ioh_gpio_to_irq(struct gpio_chip *gpio, unsigned offset) 212 212 { ··· 520 522 kfree(chip); 521 523 } 522 524 523 - #ifdef CONFIG_PM 524 - static int ioh_gpio_suspend(struct pci_dev *pdev, pm_message_t state) 525 + static int __maybe_unused ioh_gpio_suspend(struct device *dev) 525 526 { 526 - s32 ret; 527 - struct ioh_gpio *chip = pci_get_drvdata(pdev); 527 + struct ioh_gpio *chip = dev_get_drvdata(dev); 528 528 unsigned long flags; 529 529 530 530 spin_lock_irqsave(&chip->spinlock, flags); 531 531 ioh_gpio_save_reg_conf(chip); 532 532 spin_unlock_irqrestore(&chip->spinlock, flags); 533 533 534 - ret = pci_save_state(pdev); 535 - if (ret) { 536 - dev_err(&pdev->dev, "pci_save_state Failed-%d\n", ret); 537 - return ret; 538 - } 539 - pci_disable_device(pdev); 540 - pci_set_power_state(pdev, PCI_D0); 541 - ret = pci_enable_wake(pdev, PCI_D0, 1); 542 - if (ret) 543 - dev_err(&pdev->dev, "pci_enable_wake Failed -%d\n", ret); 544 - 545 534 return 0; 546 535 } 547 536 548 - static int ioh_gpio_resume(struct pci_dev *pdev) 537 + static int __maybe_unused ioh_gpio_resume(struct device *dev) 549 538 { 550 - s32 ret; 551 - struct ioh_gpio *chip = pci_get_drvdata(pdev); 539 + struct ioh_gpio *chip = dev_get_drvdata(dev); 552 540 unsigned long flags; 553 - 554 - ret = pci_enable_wake(pdev, PCI_D0, 0); 555 - 556 - pci_set_power_state(pdev, PCI_D0); 557 - ret = pci_enable_device(pdev); 558 - if (ret) { 559 - dev_err(&pdev->dev, "pci_enable_device Failed-%d ", ret); 560 - return ret; 561 - } 562 - pci_restore_state(pdev); 563 541 564 542 spin_lock_irqsave(&chip->spinlock, flags); 565 543 iowrite32(0x01, &chip->reg->srst); ··· 545 571 546 572 return 0; 547 573 } 548 - #else 549 - #define ioh_gpio_suspend NULL 550 - #define ioh_gpio_resume NULL 551 - #endif 574 + 575 + static SIMPLE_DEV_PM_OPS(ioh_gpio_pm_ops, ioh_gpio_suspend, ioh_gpio_resume); 552 576 553 577 static const struct pci_device_id ioh_gpio_pcidev_id[] = { 554 578 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x802E) }, ··· 559 587 .id_table = ioh_gpio_pcidev_id, 560 588 .probe = ioh_gpio_probe, 561 589 .remove = ioh_gpio_remove, 562 - .suspend = ioh_gpio_suspend, 563 - .resume = ioh_gpio_resume 590 + .driver = { 591 + .pm = &ioh_gpio_pm_ops, 592 + }, 564 593 }; 565 594 566 595 module_pci_driver(ioh_gpio_driver);