diff options
author | Yijing Wang <wangyijing@huawei.com> | 2012-07-24 05:20:03 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-23 11:40:57 -0400 |
commit | 62f87c0e31d646d5501edf4f7feb07d0ad689d80 (patch) | |
tree | f2aa208c10f6cf8b91634f91efda44efc6f4c25f /drivers/pci/pci.c | |
parent | 786e22885d9959fda0473ace5a61cb11620fba9b (diff) |
PCI: Introduce pci_pcie_type(dev) to replace pci_dev->pcie_type
Introduce an inline function pci_pcie_type(dev) to extract PCIe
device type from pci_dev->pcie_flags_reg field, and prepare for
removing pci_dev->pcie_type.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index f3ea977a5b1b..28eb55b77ee9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -885,7 +885,7 @@ static struct pci_cap_saved_state *pci_find_saved_cap( | |||
885 | 885 | ||
886 | static int pci_save_pcie_state(struct pci_dev *dev) | 886 | static int pci_save_pcie_state(struct pci_dev *dev) |
887 | { | 887 | { |
888 | int pos, i = 0; | 888 | int type, pos, i = 0; |
889 | struct pci_cap_saved_state *save_state; | 889 | struct pci_cap_saved_state *save_state; |
890 | u16 *cap; | 890 | u16 *cap; |
891 | u16 flags; | 891 | u16 flags; |
@@ -903,13 +903,14 @@ static int pci_save_pcie_state(struct pci_dev *dev) | |||
903 | 903 | ||
904 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); | 904 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); |
905 | 905 | ||
906 | if (pcie_cap_has_devctl(dev->pcie_type, flags)) | 906 | type = pci_pcie_type(dev); |
907 | if (pcie_cap_has_devctl(type, flags)) | ||
907 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]); | 908 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]); |
908 | if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) | 909 | if (pcie_cap_has_lnkctl(type, flags)) |
909 | pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); | 910 | pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); |
910 | if (pcie_cap_has_sltctl(dev->pcie_type, flags)) | 911 | if (pcie_cap_has_sltctl(type, flags)) |
911 | pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); | 912 | pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); |
912 | if (pcie_cap_has_rtctl(dev->pcie_type, flags)) | 913 | if (pcie_cap_has_rtctl(type, flags)) |
913 | pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); | 914 | pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); |
914 | 915 | ||
915 | pos = pci_pcie_cap2(dev); | 916 | pos = pci_pcie_cap2(dev); |
@@ -924,7 +925,7 @@ static int pci_save_pcie_state(struct pci_dev *dev) | |||
924 | 925 | ||
925 | static void pci_restore_pcie_state(struct pci_dev *dev) | 926 | static void pci_restore_pcie_state(struct pci_dev *dev) |
926 | { | 927 | { |
927 | int i = 0, pos; | 928 | int i = 0, pos, type; |
928 | struct pci_cap_saved_state *save_state; | 929 | struct pci_cap_saved_state *save_state; |
929 | u16 *cap; | 930 | u16 *cap; |
930 | u16 flags; | 931 | u16 flags; |
@@ -937,13 +938,14 @@ static void pci_restore_pcie_state(struct pci_dev *dev) | |||
937 | 938 | ||
938 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); | 939 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &flags); |
939 | 940 | ||
940 | if (pcie_cap_has_devctl(dev->pcie_type, flags)) | 941 | type = pci_pcie_type(dev); |
942 | if (pcie_cap_has_devctl(type, flags)) | ||
941 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]); | 943 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]); |
942 | if (pcie_cap_has_lnkctl(dev->pcie_type, flags)) | 944 | if (pcie_cap_has_lnkctl(type, flags)) |
943 | pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); | 945 | pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]); |
944 | if (pcie_cap_has_sltctl(dev->pcie_type, flags)) | 946 | if (pcie_cap_has_sltctl(type, flags)) |
945 | pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); | 947 | pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]); |
946 | if (pcie_cap_has_rtctl(dev->pcie_type, flags)) | 948 | if (pcie_cap_has_rtctl(type, flags)) |
947 | pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); | 949 | pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]); |
948 | 950 | ||
949 | pos = pci_pcie_cap2(dev); | 951 | pos = pci_pcie_cap2(dev); |
@@ -2459,8 +2461,8 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) | |||
2459 | acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | | 2461 | acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | |
2460 | PCI_ACS_EC | PCI_ACS_DT); | 2462 | PCI_ACS_EC | PCI_ACS_DT); |
2461 | 2463 | ||
2462 | if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM || | 2464 | if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM || |
2463 | pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || | 2465 | pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT || |
2464 | pdev->multifunction) { | 2466 | pdev->multifunction) { |
2465 | pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); | 2467 | pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ACS); |
2466 | if (!pos) | 2468 | if (!pos) |