26
26
#include <linux/list.h>
27
27
#include <linux/module.h>
28
28
#include <linux/msi.h>
29
- #include <linux/notifier.h>
30
29
#include <linux/of_irq.h>
31
30
#include <linux/pci-ecam.h>
32
31
@@ -667,12 +666,16 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
667
666
return NULL ;
668
667
}
669
668
670
- static int apple_pcie_add_device (struct apple_pcie_port * port ,
671
- struct pci_dev * pdev )
669
+ static int apple_pcie_enable_device (struct pci_host_bridge * bridge , struct pci_dev * pdev )
672
670
{
673
671
u32 sid , rid = pci_dev_id (pdev );
672
+ struct apple_pcie_port * port ;
674
673
int idx , err ;
675
674
675
+ port = apple_pcie_get_port (pdev );
676
+ if (!port )
677
+ return 0 ;
678
+
676
679
dev_dbg (& pdev -> dev , "added to bus %s, index %d\n" ,
677
680
pci_name (pdev -> bus -> self ), port -> idx );
678
681
@@ -698,12 +701,16 @@ static int apple_pcie_add_device(struct apple_pcie_port *port,
698
701
return idx >= 0 ? 0 : - ENOSPC ;
699
702
}
700
703
701
- static void apple_pcie_release_device (struct apple_pcie_port * port ,
702
- struct pci_dev * pdev )
704
+ static void apple_pcie_disable_device (struct pci_host_bridge * bridge , struct pci_dev * pdev )
703
705
{
706
+ struct apple_pcie_port * port ;
704
707
u32 rid = pci_dev_id (pdev );
705
708
int idx ;
706
709
710
+ port = apple_pcie_get_port (pdev );
711
+ if (!port )
712
+ return ;
713
+
707
714
mutex_lock (& port -> pcie -> lock );
708
715
709
716
for_each_set_bit (idx , port -> sid_map , port -> sid_map_sz ) {
@@ -721,45 +728,6 @@ static void apple_pcie_release_device(struct apple_pcie_port *port,
721
728
mutex_unlock (& port -> pcie -> lock );
722
729
}
723
730
724
- static int apple_pcie_bus_notifier (struct notifier_block * nb ,
725
- unsigned long action ,
726
- void * data )
727
- {
728
- struct device * dev = data ;
729
- struct pci_dev * pdev = to_pci_dev (dev );
730
- struct apple_pcie_port * port ;
731
- int err ;
732
-
733
- /*
734
- * This is a bit ugly. We assume that if we get notified for
735
- * any PCI device, we must be in charge of it, and that there
736
- * is no other PCI controller in the whole system. It probably
737
- * holds for now, but who knows for how long?
738
- */
739
- port = apple_pcie_get_port (pdev );
740
- if (!port )
741
- return NOTIFY_DONE ;
742
-
743
- switch (action ) {
744
- case BUS_NOTIFY_ADD_DEVICE :
745
- err = apple_pcie_add_device (port , pdev );
746
- if (err )
747
- return notifier_from_errno (err );
748
- break ;
749
- case BUS_NOTIFY_DEL_DEVICE :
750
- apple_pcie_release_device (port , pdev );
751
- break ;
752
- default :
753
- return NOTIFY_DONE ;
754
- }
755
-
756
- return NOTIFY_OK ;
757
- }
758
-
759
- static struct notifier_block apple_pcie_nb = {
760
- .notifier_call = apple_pcie_bus_notifier ,
761
- };
762
-
763
731
static int apple_pcie_init (struct pci_config_window * cfg )
764
732
{
765
733
struct device * dev = cfg -> parent ;
@@ -799,23 +767,10 @@ static int apple_pcie_init(struct pci_config_window *cfg)
799
767
return 0 ;
800
768
}
801
769
802
- static int apple_pcie_probe (struct platform_device * pdev )
803
- {
804
- int ret ;
805
-
806
- ret = bus_register_notifier (& pci_bus_type , & apple_pcie_nb );
807
- if (ret )
808
- return ret ;
809
-
810
- ret = pci_host_common_probe (pdev );
811
- if (ret )
812
- bus_unregister_notifier (& pci_bus_type , & apple_pcie_nb );
813
-
814
- return ret ;
815
- }
816
-
817
770
static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
818
771
.init = apple_pcie_init ,
772
+ .enable_device = apple_pcie_enable_device ,
773
+ .disable_device = apple_pcie_disable_device ,
819
774
.pci_ops = {
820
775
.map_bus = pci_ecam_map_bus ,
821
776
.read = pci_generic_config_read ,
@@ -830,7 +785,7 @@ static const struct of_device_id apple_pcie_of_match[] = {
830
785
MODULE_DEVICE_TABLE (of , apple_pcie_of_match );
831
786
832
787
static struct platform_driver apple_pcie_driver = {
833
- .probe = apple_pcie_probe ,
788
+ .probe = pci_host_common_probe ,
834
789
.driver = {
835
790
.name = "pcie-apple" ,
836
791
.of_match_table = apple_pcie_of_match ,
0 commit comments