1919#include <linux/of_address.h>
2020#include <linux/of_irq.h>
2121#include <linux/platform_device.h>
22- #include <linux/syscore_ops .h>
22+ #include <linux/pm .h>
2323
2424#include <dt-bindings/interrupt-controller/arm-gic.h>
2525
@@ -64,8 +64,6 @@ struct stm32_exti_host_data {
6464 bool dt_has_irqs_desc ; /* skip internal desc_irqs array and get it from DT */
6565};
6666
67- static struct stm32_exti_host_data * stm32_host_data ;
68-
6967static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
7068 .imr_ofst = 0x00 ,
7169 .emr_ofst = 0x04 ,
@@ -622,50 +620,32 @@ static int stm32_exti_h_set_affinity(struct irq_data *d,
622620 return IRQ_SET_MASK_OK_DONE ;
623621}
624622
625- static int __maybe_unused stm32_exti_h_suspend (void )
623+ static int stm32_exti_h_suspend (struct device * dev )
626624{
625+ struct stm32_exti_host_data * host_data = dev_get_drvdata (dev );
627626 struct stm32_exti_chip_data * chip_data ;
628627 int i ;
629628
630- for (i = 0 ; i < stm32_host_data -> drv_data -> bank_nr ; i ++ ) {
631- chip_data = & stm32_host_data -> chips_data [i ];
632- raw_spin_lock (& chip_data -> rlock );
629+ for (i = 0 ; i < host_data -> drv_data -> bank_nr ; i ++ ) {
630+ chip_data = & host_data -> chips_data [i ];
633631 stm32_chip_suspend (chip_data , chip_data -> wake_active );
634- raw_spin_unlock (& chip_data -> rlock );
635632 }
636633
637634 return 0 ;
638635}
639636
640- static void __maybe_unused stm32_exti_h_resume (void )
637+ static int stm32_exti_h_resume (struct device * dev )
641638{
639+ struct stm32_exti_host_data * host_data = dev_get_drvdata (dev );
642640 struct stm32_exti_chip_data * chip_data ;
643641 int i ;
644642
645- for (i = 0 ; i < stm32_host_data -> drv_data -> bank_nr ; i ++ ) {
646- chip_data = & stm32_host_data -> chips_data [i ];
647- raw_spin_lock (& chip_data -> rlock );
643+ for (i = 0 ; i < host_data -> drv_data -> bank_nr ; i ++ ) {
644+ chip_data = & host_data -> chips_data [i ];
648645 stm32_chip_resume (chip_data , chip_data -> mask_cache );
649- raw_spin_unlock (& chip_data -> rlock );
650646 }
651- }
652647
653- static struct syscore_ops stm32_exti_h_syscore_ops = {
654- #ifdef CONFIG_PM_SLEEP
655- .suspend = stm32_exti_h_suspend ,
656- .resume = stm32_exti_h_resume ,
657- #endif
658- };
659-
660- static void stm32_exti_h_syscore_init (struct stm32_exti_host_data * host_data )
661- {
662- stm32_host_data = host_data ;
663- register_syscore_ops (& stm32_exti_h_syscore_ops );
664- }
665-
666- static void stm32_exti_h_syscore_deinit (void )
667- {
668- unregister_syscore_ops (& stm32_exti_h_syscore_ops );
648+ return 0 ;
669649}
670650
671651static int stm32_exti_h_retrigger (struct irq_data * d )
@@ -789,8 +769,6 @@ stm32_exti_host_data *stm32_exti_host_init(const struct stm32_exti_drv_data *dd,
789769 goto free_chips_data ;
790770 }
791771
792- stm32_host_data = host_data ;
793-
794772 return host_data ;
795773
796774free_chips_data :
@@ -916,11 +894,6 @@ static void stm32_exti_remove_irq(void *data)
916894 irq_domain_remove (domain );
917895}
918896
919- static void stm32_exti_remove (struct platform_device * pdev )
920- {
921- stm32_exti_h_syscore_deinit ();
922- }
923-
924897static int stm32_exti_probe (struct platform_device * pdev )
925898{
926899 int ret , i ;
@@ -934,6 +907,8 @@ static int stm32_exti_probe(struct platform_device *pdev)
934907 if (!host_data )
935908 return - ENOMEM ;
936909
910+ dev_set_drvdata (dev , host_data );
911+
937912 /* check for optional hwspinlock which may be not available yet */
938913 ret = of_hwspin_lock_get_id (np , 0 );
939914 if (ret == - EPROBE_DEFER )
@@ -996,8 +971,6 @@ static int stm32_exti_probe(struct platform_device *pdev)
996971 if (of_property_read_bool (np , "interrupts-extended" ))
997972 host_data -> dt_has_irqs_desc = true;
998973
999- stm32_exti_h_syscore_init (host_data );
1000-
1001974 return 0 ;
1002975}
1003976
@@ -1009,12 +982,16 @@ static const struct of_device_id stm32_exti_ids[] = {
1009982};
1010983MODULE_DEVICE_TABLE (of , stm32_exti_ids );
1011984
985+ static const struct dev_pm_ops stm32_exti_dev_pm_ops = {
986+ NOIRQ_SYSTEM_SLEEP_PM_OPS (stm32_exti_h_suspend , stm32_exti_h_resume )
987+ };
988+
1012989static struct platform_driver stm32_exti_driver = {
1013990 .probe = stm32_exti_probe ,
1014- .remove_new = stm32_exti_remove ,
1015991 .driver = {
1016992 .name = "stm32_exti" ,
1017993 .of_match_table = stm32_exti_ids ,
994+ .pm = & stm32_exti_dev_pm_ops ,
1018995 },
1019996};
1020997
0 commit comments