mirror of https://gitee.com/openkylin/linux.git
PCI: Constify struct pci_ecam_ops
struct pci_ecam_ops is typically DT match table data which is defined to be const. It's also best practice for ops structs to be const. Ideally, we'd make struct pci_ops const as well, but that becomes pretty invasive, so for now we just cast it where needed. Link: https://lore.kernel.org/r/20200409234923.21598-2-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Andrew Murray <amurray@thegoodpenguin.co.uk> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Len Brown <lenb@kernel.org> Cc: Jonathan Chocron <jonnyc@amazon.com> Cc: Zhou Wang <wangzhou1@hisilicon.com> Cc: Robert Richter <rrichter@marvell.com> Cc: Toan Le <toan@os.amperecomputing.com> Cc: Marc Gonzalez <marc.w.gonzalez@free.fr> Cc: Mans Rullgard <mans@mansr.com> Cc: linux-acpi@vger.kernel.org
This commit is contained in:
parent
8f3d9f3542
commit
0b104773b4
|
@ -117,7 +117,7 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
|
|||
struct device *dev = &root->device->dev;
|
||||
struct resource *bus_res = &root->secondary;
|
||||
u16 seg = root->segment;
|
||||
struct pci_ecam_ops *ecam_ops;
|
||||
const struct pci_ecam_ops *ecam_ops;
|
||||
struct resource cfgres;
|
||||
struct acpi_device *adev;
|
||||
struct pci_config_window *cfg;
|
||||
|
@ -185,7 +185,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
|
|||
|
||||
root_ops->release_info = pci_acpi_generic_release_info;
|
||||
root_ops->prepare_resources = pci_acpi_root_prepare_resources;
|
||||
root_ops->pci_ops = &ri->cfg->ops->pci_ops;
|
||||
root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops;
|
||||
bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg);
|
||||
if (!bus)
|
||||
return NULL;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct mcfg_fixup {
|
|||
u32 oem_revision;
|
||||
u16 segment;
|
||||
struct resource bus_range;
|
||||
struct pci_ecam_ops *ops;
|
||||
const struct pci_ecam_ops *ops;
|
||||
struct resource cfgres;
|
||||
};
|
||||
|
||||
|
@ -165,7 +165,7 @@ static int pci_mcfg_quirk_matches(struct mcfg_fixup *f, u16 segment,
|
|||
|
||||
static void pci_mcfg_apply_quirks(struct acpi_pci_root *root,
|
||||
struct resource *cfgres,
|
||||
struct pci_ecam_ops **ecam_ops)
|
||||
const struct pci_ecam_ops **ecam_ops)
|
||||
{
|
||||
#ifdef CONFIG_PCI_QUIRKS
|
||||
u16 segment = root->segment;
|
||||
|
@ -191,9 +191,9 @@ static void pci_mcfg_apply_quirks(struct acpi_pci_root *root,
|
|||
static LIST_HEAD(pci_mcfg_list);
|
||||
|
||||
int pci_mcfg_lookup(struct acpi_pci_root *root, struct resource *cfgres,
|
||||
struct pci_ecam_ops **ecam_ops)
|
||||
const struct pci_ecam_ops **ecam_ops)
|
||||
{
|
||||
struct pci_ecam_ops *ops = &pci_generic_ecam_ops;
|
||||
const struct pci_ecam_ops *ops = &pci_generic_ecam_ops;
|
||||
struct resource *bus_res = &root->secondary;
|
||||
u16 seg = root->segment;
|
||||
struct mcfg_entry *e;
|
||||
|
|
|
@ -80,7 +80,7 @@ static int al_pcie_init(struct pci_config_window *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct pci_ecam_ops al_pcie_ops = {
|
||||
const struct pci_ecam_ops al_pcie_ops = {
|
||||
.bus_shift = 20,
|
||||
.init = al_pcie_init,
|
||||
.pci_ops = {
|
||||
|
|
|
@ -104,7 +104,7 @@ static int hisi_pcie_init(struct pci_config_window *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct pci_ecam_ops hisi_pcie_ops = {
|
||||
const struct pci_ecam_ops hisi_pcie_ops = {
|
||||
.bus_shift = 20,
|
||||
.init = hisi_pcie_init,
|
||||
.pci_ops = {
|
||||
|
@ -362,7 +362,7 @@ static int hisi_pcie_platform_init(struct pci_config_window *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct pci_ecam_ops hisi_pcie_platform_ops = {
|
||||
const struct pci_ecam_ops hisi_pcie_platform_ops = {
|
||||
.bus_shift = 20,
|
||||
.init = hisi_pcie_platform_init,
|
||||
.pci_ops = {
|
||||
|
@ -375,11 +375,11 @@ struct pci_ecam_ops hisi_pcie_platform_ops = {
|
|||
static const struct of_device_id hisi_pcie_almost_ecam_of_match[] = {
|
||||
{
|
||||
.compatible = "hisilicon,hip06-pcie-ecam",
|
||||
.data = (void *) &hisi_pcie_platform_ops,
|
||||
.data = &hisi_pcie_platform_ops,
|
||||
},
|
||||
{
|
||||
.compatible = "hisilicon,hip07-pcie-ecam",
|
||||
.data = (void *) &hisi_pcie_platform_ops,
|
||||
.data = &hisi_pcie_platform_ops,
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ static void gen_pci_unmap_cfg(void *ptr)
|
|||
}
|
||||
|
||||
static struct pci_config_window *gen_pci_init(struct device *dev,
|
||||
struct list_head *resources, struct pci_ecam_ops *ops)
|
||||
struct list_head *resources, const struct pci_ecam_ops *ops)
|
||||
{
|
||||
int err;
|
||||
struct resource cfgres;
|
||||
|
@ -55,7 +55,7 @@ static struct pci_config_window *gen_pci_init(struct device *dev,
|
|||
}
|
||||
|
||||
int pci_host_common_probe(struct platform_device *pdev,
|
||||
struct pci_ecam_ops *ops)
|
||||
const struct pci_ecam_ops *ops)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct pci_host_bridge *bridge;
|
||||
|
@ -82,7 +82,7 @@ int pci_host_common_probe(struct platform_device *pdev,
|
|||
bridge->dev.parent = dev;
|
||||
bridge->sysdata = cfg;
|
||||
bridge->busnr = cfg->busr.start;
|
||||
bridge->ops = &ops->pci_ops;
|
||||
bridge->ops = (struct pci_ops *)&ops->pci_ops;
|
||||
bridge->map_irq = of_irq_parse_and_map_pci;
|
||||
bridge->swizzle_irq = pci_common_swizzle;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <linux/pci-ecam.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
static struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
|
||||
static const struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
|
||||
.bus_shift = 16,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_ecam_map_bus,
|
||||
|
@ -49,7 +49,7 @@ static void __iomem *pci_dw_ecam_map_bus(struct pci_bus *bus,
|
|||
return pci_ecam_map_bus(bus, devfn, where);
|
||||
}
|
||||
|
||||
static struct pci_ecam_ops pci_dw_ecam_bus_ops = {
|
||||
static const struct pci_ecam_ops pci_dw_ecam_bus_ops = {
|
||||
.bus_shift = 20,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_dw_ecam_map_bus,
|
||||
|
|
|
@ -345,7 +345,7 @@ static int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn,
|
|||
return pci_generic_config_write(bus, devfn, where, size, val);
|
||||
}
|
||||
|
||||
struct pci_ecam_ops pci_thunder_ecam_ops = {
|
||||
const struct pci_ecam_ops pci_thunder_ecam_ops = {
|
||||
.bus_shift = 20,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_ecam_map_bus,
|
||||
|
|
|
@ -403,7 +403,7 @@ static int thunder_pem_acpi_init(struct pci_config_window *cfg)
|
|||
return thunder_pem_init(dev, cfg, res_pem);
|
||||
}
|
||||
|
||||
struct pci_ecam_ops thunder_pem_ecam_ops = {
|
||||
const struct pci_ecam_ops thunder_pem_ecam_ops = {
|
||||
.bus_shift = 24,
|
||||
.init = thunder_pem_acpi_init,
|
||||
.pci_ops = {
|
||||
|
@ -440,7 +440,7 @@ static int thunder_pem_platform_init(struct pci_config_window *cfg)
|
|||
return thunder_pem_init(dev, cfg, res_pem);
|
||||
}
|
||||
|
||||
static struct pci_ecam_ops pci_thunder_pem_ops = {
|
||||
static const struct pci_ecam_ops pci_thunder_pem_ops = {
|
||||
.bus_shift = 24,
|
||||
.init = thunder_pem_platform_init,
|
||||
.pci_ops = {
|
||||
|
|
|
@ -256,7 +256,7 @@ static int xgene_v1_pcie_ecam_init(struct pci_config_window *cfg)
|
|||
return xgene_pcie_ecam_init(cfg, XGENE_PCIE_IP_VER_1);
|
||||
}
|
||||
|
||||
struct pci_ecam_ops xgene_v1_pcie_ecam_ops = {
|
||||
const struct pci_ecam_ops xgene_v1_pcie_ecam_ops = {
|
||||
.bus_shift = 16,
|
||||
.init = xgene_v1_pcie_ecam_init,
|
||||
.pci_ops = {
|
||||
|
@ -271,7 +271,7 @@ static int xgene_v2_pcie_ecam_init(struct pci_config_window *cfg)
|
|||
return xgene_pcie_ecam_init(cfg, XGENE_PCIE_IP_VER_2);
|
||||
}
|
||||
|
||||
struct pci_ecam_ops xgene_v2_pcie_ecam_ops = {
|
||||
const struct pci_ecam_ops xgene_v2_pcie_ecam_ops = {
|
||||
.bus_shift = 16,
|
||||
.init = xgene_v2_pcie_ecam_init,
|
||||
.pci_ops = {
|
||||
|
|
|
@ -207,7 +207,7 @@ static int smp8759_config_write(struct pci_bus *bus, unsigned int devfn,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct pci_ecam_ops smp8759_ecam_ops = {
|
||||
static const struct pci_ecam_ops smp8759_ecam_ops = {
|
||||
.bus_shift = 20,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_ecam_map_bus,
|
||||
|
|
|
@ -26,7 +26,7 @@ static const bool per_bus_mapping = !IS_ENABLED(CONFIG_64BIT);
|
|||
*/
|
||||
struct pci_config_window *pci_ecam_create(struct device *dev,
|
||||
struct resource *cfgres, struct resource *busr,
|
||||
struct pci_ecam_ops *ops)
|
||||
const struct pci_ecam_ops *ops)
|
||||
{
|
||||
struct pci_config_window *cfg;
|
||||
unsigned int bus_range, bus_range_max, bsz;
|
||||
|
@ -145,7 +145,7 @@ void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
|
|||
}
|
||||
|
||||
/* ECAM ops */
|
||||
struct pci_ecam_ops pci_generic_ecam_ops = {
|
||||
const struct pci_ecam_ops pci_generic_ecam_ops = {
|
||||
.bus_shift = 20,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_ecam_map_bus,
|
||||
|
@ -156,7 +156,7 @@ struct pci_ecam_ops pci_generic_ecam_ops = {
|
|||
|
||||
#if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
|
||||
/* ECAM ops for 32-bit access only (non-compliant) */
|
||||
struct pci_ecam_ops pci_32b_ops = {
|
||||
const struct pci_ecam_ops pci_32b_ops = {
|
||||
.bus_shift = 20,
|
||||
.pci_ops = {
|
||||
.map_bus = pci_ecam_map_bus,
|
||||
|
|
|
@ -27,7 +27,7 @@ extern phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle);
|
|||
|
||||
struct pci_ecam_ops;
|
||||
extern int pci_mcfg_lookup(struct acpi_pci_root *root, struct resource *cfgres,
|
||||
struct pci_ecam_ops **ecam_ops);
|
||||
const struct pci_ecam_ops **ecam_ops);
|
||||
|
||||
static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ struct pci_config_window {
|
|||
struct resource res;
|
||||
struct resource busr;
|
||||
void *priv;
|
||||
struct pci_ecam_ops *ops;
|
||||
const struct pci_ecam_ops *ops;
|
||||
union {
|
||||
void __iomem *win; /* 64-bit single mapping */
|
||||
void __iomem **winp; /* 32-bit per-bus mapping */
|
||||
|
@ -40,29 +40,29 @@ struct pci_config_window {
|
|||
/* create and free pci_config_window */
|
||||
struct pci_config_window *pci_ecam_create(struct device *dev,
|
||||
struct resource *cfgres, struct resource *busr,
|
||||
struct pci_ecam_ops *ops);
|
||||
const struct pci_ecam_ops *ops);
|
||||
void pci_ecam_free(struct pci_config_window *cfg);
|
||||
|
||||
/* map_bus when ->sysdata is an instance of pci_config_window */
|
||||
void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
|
||||
int where);
|
||||
/* default ECAM ops */
|
||||
extern struct pci_ecam_ops pci_generic_ecam_ops;
|
||||
extern const struct pci_ecam_ops pci_generic_ecam_ops;
|
||||
|
||||
#if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
|
||||
extern struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */
|
||||
extern struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */
|
||||
extern struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */
|
||||
extern struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
|
||||
extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
|
||||
extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
|
||||
extern struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */
|
||||
extern const struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */
|
||||
extern const struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */
|
||||
extern const struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */
|
||||
extern const struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
|
||||
extern const struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
|
||||
extern const struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
|
||||
extern const struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI_HOST_COMMON
|
||||
/* for DT-based PCI controllers that support ECAM */
|
||||
int pci_host_common_probe(struct platform_device *pdev,
|
||||
struct pci_ecam_ops *ops);
|
||||
const struct pci_ecam_ops *ops);
|
||||
int pci_host_common_remove(struct platform_device *pdev);
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue