aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-sysfs.c10
-rw-r--r--drivers/pci/pci.c11
-rw-r--r--drivers/pci/pci.h7
-rw-r--r--drivers/pci/probe.c5
4 files changed, 21 insertions, 12 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 77baff022f71..00a9947cb7cc 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -715,7 +715,7 @@ static struct bin_attribute pci_config_attr = {
715 .name = "config", 715 .name = "config",
716 .mode = S_IRUGO | S_IWUSR, 716 .mode = S_IRUGO | S_IWUSR,
717 }, 717 },
718 .size = 256, 718 .size = PCI_CFG_SPACE_SIZE,
719 .read = pci_read_config, 719 .read = pci_read_config,
720 .write = pci_write_config, 720 .write = pci_write_config,
721}; 721};
@@ -725,7 +725,7 @@ static struct bin_attribute pcie_config_attr = {
725 .name = "config", 725 .name = "config",
726 .mode = S_IRUGO | S_IWUSR, 726 .mode = S_IRUGO | S_IWUSR,
727 }, 727 },
728 .size = 4096, 728 .size = PCI_CFG_SPACE_EXP_SIZE,
729 .read = pci_read_config, 729 .read = pci_read_config,
730 .write = pci_write_config, 730 .write = pci_write_config,
731}; 731};
@@ -743,7 +743,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
743 if (!sysfs_initialized) 743 if (!sysfs_initialized)
744 return -EACCES; 744 return -EACCES;
745 745
746 if (pdev->cfg_size < 4096) 746 if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
747 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); 747 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
748 else 748 else
749 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); 749 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
@@ -814,7 +814,7 @@ err_vpd:
814 kfree(pdev->vpd->attr); 814 kfree(pdev->vpd->attr);
815 } 815 }
816err_config_file: 816err_config_file:
817 if (pdev->cfg_size < 4096) 817 if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
818 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 818 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
819 else 819 else
820 sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); 820 sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
@@ -839,7 +839,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
839 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr); 839 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr);
840 kfree(pdev->vpd->attr); 840 kfree(pdev->vpd->attr);
841 } 841 }
842 if (pdev->cfg_size < 4096) 842 if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
843 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 843 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
844 else 844 else
845 sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); 845 sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 09dc893c81db..553ca6657955 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -213,10 +213,13 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
213int pci_find_ext_capability(struct pci_dev *dev, int cap) 213int pci_find_ext_capability(struct pci_dev *dev, int cap)
214{ 214{
215 u32 header; 215 u32 header;
216 int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */ 216 int ttl;
217 int pos = 0x100; 217 int pos = PCI_CFG_SPACE_SIZE;
218 218
219 if (dev->cfg_size <= 256) 219 /* minimum 8 bytes per capability */
220 ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8;
221
222 if (dev->cfg_size <= PCI_CFG_SPACE_SIZE)
220 return 0; 223 return 0;
221 224
222 if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 225 if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
@@ -234,7 +237,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
234 return pos; 237 return pos;
235 238
236 pos = PCI_EXT_CAP_NEXT(header); 239 pos = PCI_EXT_CAP_NEXT(header);
237 if (pos < 0x100) 240 if (pos < PCI_CFG_SPACE_SIZE)
238 break; 241 break;
239 242
240 if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL) 243 if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 4723b12fb39a..601abdc8dd9f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,3 +1,9 @@
1#ifndef DRIVERS_PCI_H
2#define DRIVERS_PCI_H
3
4#define PCI_CFG_SPACE_SIZE 256
5#define PCI_CFG_SPACE_EXP_SIZE 4096
6
1/* Functions internal to the PCI core code */ 7/* Functions internal to the PCI core code */
2 8
3extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env); 9extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
@@ -145,3 +151,4 @@ struct pci_slot_attribute {
145}; 151};
146#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr) 152#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr)
147 153
154#endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7aa71636dd3c..f6754e87f046 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -14,8 +14,6 @@
14 14
15#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 15#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
16#define CARDBUS_RESERVE_BUSNR 3 16#define CARDBUS_RESERVE_BUSNR 3
17#define PCI_CFG_SPACE_SIZE 256
18#define PCI_CFG_SPACE_EXP_SIZE 4096
19 17
20/* Ugh. Need to stop exporting this to modules. */ 18/* Ugh. Need to stop exporting this to modules. */
21LIST_HEAD(pci_root_buses); 19LIST_HEAD(pci_root_buses);
@@ -887,8 +885,9 @@ static void set_pcie_port_type(struct pci_dev *pdev)
887int pci_cfg_space_size_ext(struct pci_dev *dev) 885int pci_cfg_space_size_ext(struct pci_dev *dev)
888{ 886{
889 u32 status; 887 u32 status;
888 int pos = PCI_CFG_SPACE_SIZE;
890 889
891 if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) 890 if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
892 goto fail; 891 goto fail;
893 if (status == 0xffffffff) 892 if (status == 0xffffffff)
894 goto fail; 893 goto fail;