PCI: replace cfg space size (256/4096) by macros.
This is a cleanup that changes all PCI configuration space size representations to the macros (PCI_CFG_SPACE_SIZE and PCI_CFG_SPACE_EXP_SIZE). And the macros are also moved from drivers/pci/probe.c to drivers/pci/pci.h. Signed-off-by: Yu Zhao <yu.zhao@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
022edd86d7
commit
557848c3c0
@ -715,7 +715,7 @@ static struct bin_attribute pci_config_attr = {
|
|||||||
.name = "config",
|
.name = "config",
|
||||||
.mode = S_IRUGO | S_IWUSR,
|
.mode = S_IRUGO | S_IWUSR,
|
||||||
},
|
},
|
||||||
.size = 256,
|
.size = PCI_CFG_SPACE_SIZE,
|
||||||
.read = pci_read_config,
|
.read = pci_read_config,
|
||||||
.write = pci_write_config,
|
.write = pci_write_config,
|
||||||
};
|
};
|
||||||
@ -725,7 +725,7 @@ static struct bin_attribute pcie_config_attr = {
|
|||||||
.name = "config",
|
.name = "config",
|
||||||
.mode = S_IRUGO | S_IWUSR,
|
.mode = S_IRUGO | S_IWUSR,
|
||||||
},
|
},
|
||||||
.size = 4096,
|
.size = PCI_CFG_SPACE_EXP_SIZE,
|
||||||
.read = pci_read_config,
|
.read = pci_read_config,
|
||||||
.write = pci_write_config,
|
.write = pci_write_config,
|
||||||
};
|
};
|
||||||
@ -743,7 +743,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
|
|||||||
if (!sysfs_initialized)
|
if (!sysfs_initialized)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
if (pdev->cfg_size < 4096)
|
if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
|
||||||
retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
||||||
else
|
else
|
||||||
retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
||||||
@ -814,7 +814,7 @@ err_vpd:
|
|||||||
kfree(pdev->vpd->attr);
|
kfree(pdev->vpd->attr);
|
||||||
}
|
}
|
||||||
err_config_file:
|
err_config_file:
|
||||||
if (pdev->cfg_size < 4096)
|
if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
|
||||||
sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
||||||
else
|
else
|
||||||
sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
||||||
@ -839,7 +839,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
|
|||||||
sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr);
|
sysfs_remove_bin_file(&pdev->dev.kobj, pdev->vpd->attr);
|
||||||
kfree(pdev->vpd->attr);
|
kfree(pdev->vpd->attr);
|
||||||
}
|
}
|
||||||
if (pdev->cfg_size < 4096)
|
if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE)
|
||||||
sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
|
||||||
else
|
else
|
||||||
sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
|
||||||
|
@ -213,10 +213,13 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
|
|||||||
int pci_find_ext_capability(struct pci_dev *dev, int cap)
|
int pci_find_ext_capability(struct pci_dev *dev, int cap)
|
||||||
{
|
{
|
||||||
u32 header;
|
u32 header;
|
||||||
int ttl = 480; /* 3840 bytes, minimum 8 bytes per capability */
|
int ttl;
|
||||||
int pos = 0x100;
|
int pos = PCI_CFG_SPACE_SIZE;
|
||||||
|
|
||||||
if (dev->cfg_size <= 256)
|
/* minimum 8 bytes per capability */
|
||||||
|
ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8;
|
||||||
|
|
||||||
|
if (dev->cfg_size <= PCI_CFG_SPACE_SIZE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
|
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)
|
|||||||
return pos;
|
return pos;
|
||||||
|
|
||||||
pos = PCI_EXT_CAP_NEXT(header);
|
pos = PCI_EXT_CAP_NEXT(header);
|
||||||
if (pos < 0x100)
|
if (pos < PCI_CFG_SPACE_SIZE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
|
if (pci_read_config_dword(dev, pos, &header) != PCIBIOS_SUCCESSFUL)
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
#ifndef DRIVERS_PCI_H
|
||||||
|
#define DRIVERS_PCI_H
|
||||||
|
|
||||||
|
#define PCI_CFG_SPACE_SIZE 256
|
||||||
|
#define PCI_CFG_SPACE_EXP_SIZE 4096
|
||||||
|
|
||||||
/* Functions internal to the PCI core code */
|
/* Functions internal to the PCI core code */
|
||||||
|
|
||||||
extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
|
extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
|
||||||
@ -145,3 +151,4 @@ struct pci_slot_attribute {
|
|||||||
};
|
};
|
||||||
#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr)
|
#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr)
|
||||||
|
|
||||||
|
#endif /* DRIVERS_PCI_H */
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
|
#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
|
||||||
#define CARDBUS_RESERVE_BUSNR 3
|
#define CARDBUS_RESERVE_BUSNR 3
|
||||||
#define PCI_CFG_SPACE_SIZE 256
|
|
||||||
#define PCI_CFG_SPACE_EXP_SIZE 4096
|
|
||||||
|
|
||||||
/* Ugh. Need to stop exporting this to modules. */
|
/* Ugh. Need to stop exporting this to modules. */
|
||||||
LIST_HEAD(pci_root_buses);
|
LIST_HEAD(pci_root_buses);
|
||||||
@ -887,8 +885,9 @@ static void set_pcie_port_type(struct pci_dev *pdev)
|
|||||||
int pci_cfg_space_size_ext(struct pci_dev *dev)
|
int pci_cfg_space_size_ext(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
u32 status;
|
u32 status;
|
||||||
|
int pos = PCI_CFG_SPACE_SIZE;
|
||||||
|
|
||||||
if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
|
if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (status == 0xffffffff)
|
if (status == 0xffffffff)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
Reference in New Issue
Block a user