@@ -155,11 +155,10 @@ static int ioh_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
155155 return 0 ;
156156}
157157
158- #ifdef CONFIG_PM
159158/*
160159 * Save register configuration and disable interrupts.
161160 */
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 )
163162{
164163 int i ;
165164
@@ -185,7 +184,7 @@ static void ioh_gpio_save_reg_conf(struct ioh_gpio *chip)
185184/*
186185 * This function restores the register configuration of the GPIO device.
187186 */
188- static void ioh_gpio_restore_reg_conf (struct ioh_gpio * chip )
187+ static void __maybe_unused ioh_gpio_restore_reg_conf (struct ioh_gpio * chip )
189188{
190189 int i ;
191190
@@ -207,7 +206,6 @@ static void ioh_gpio_restore_reg_conf(struct ioh_gpio *chip)
207206 & chip -> reg -> ioh_sel_reg [i ]);
208207 }
209208}
210- #endif
211209
212210static int ioh_gpio_to_irq (struct gpio_chip * gpio , unsigned offset )
213211{
@@ -522,47 +520,23 @@ static void ioh_gpio_remove(struct pci_dev *pdev)
522520 kfree (chip );
523521}
524522
525- #ifdef CONFIG_PM
526- static int ioh_gpio_suspend (struct pci_dev * pdev , pm_message_t state )
523+ static int __maybe_unused ioh_gpio_suspend (struct device * dev )
527524{
528- s32 ret ;
529- struct ioh_gpio * chip = pci_get_drvdata (pdev );
525+ struct ioh_gpio * chip = dev_get_drvdata (dev );
530526 unsigned long flags ;
531527
532528 spin_lock_irqsave (& chip -> spinlock , flags );
533529 ioh_gpio_save_reg_conf (chip );
534530 spin_unlock_irqrestore (& chip -> spinlock , flags );
535531
536- ret = pci_save_state (pdev );
537- if (ret ) {
538- dev_err (& pdev -> dev , "pci_save_state Failed-%d\n" , ret );
539- return ret ;
540- }
541- pci_disable_device (pdev );
542- pci_set_power_state (pdev , PCI_D0 );
543- ret = pci_enable_wake (pdev , PCI_D0 , 1 );
544- if (ret )
545- dev_err (& pdev -> dev , "pci_enable_wake Failed -%d\n" , ret );
546-
547532 return 0 ;
548533}
549534
550- static int ioh_gpio_resume (struct pci_dev * pdev )
535+ static int __maybe_unused ioh_gpio_resume (struct device * dev )
551536{
552- s32 ret ;
553- struct ioh_gpio * chip = pci_get_drvdata (pdev );
537+ struct ioh_gpio * chip = dev_get_drvdata (dev );
554538 unsigned long flags ;
555539
556- ret = pci_enable_wake (pdev , PCI_D0 , 0 );
557-
558- pci_set_power_state (pdev , PCI_D0 );
559- ret = pci_enable_device (pdev );
560- if (ret ) {
561- dev_err (& pdev -> dev , "pci_enable_device Failed-%d " , ret );
562- return ret ;
563- }
564- pci_restore_state (pdev );
565-
566540 spin_lock_irqsave (& chip -> spinlock , flags );
567541 iowrite32 (0x01 , & chip -> reg -> srst );
568542 iowrite32 (0x00 , & chip -> reg -> srst );
@@ -571,10 +545,8 @@ static int ioh_gpio_resume(struct pci_dev *pdev)
571545
572546 return 0 ;
573547}
574- #else
575- #define ioh_gpio_suspend NULL
576- #define ioh_gpio_resume NULL
577- #endif
548+
549+ static SIMPLE_DEV_PM_OPS (ioh_gpio_pm_ops , ioh_gpio_suspend , ioh_gpio_resume ) ;
578550
579551static const struct pci_device_id ioh_gpio_pcidev_id [] = {
580552 { PCI_DEVICE (PCI_VENDOR_ID_ROHM , 0x802E ) },
@@ -587,8 +559,9 @@ static struct pci_driver ioh_gpio_driver = {
587559 .id_table = ioh_gpio_pcidev_id ,
588560 .probe = ioh_gpio_probe ,
589561 .remove = ioh_gpio_remove ,
590- .suspend = ioh_gpio_suspend ,
591- .resume = ioh_gpio_resume
562+ .driver = {
563+ .pm = & ioh_gpio_pm_ops ,
564+ },
592565};
593566
594567module_pci_driver (ioh_gpio_driver );
0 commit comments