Commit 786aeccb authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: iproc: Add local struct device pointers

Use a local "struct device *dev" for brevity and consistency with other
drivers.  No functional change intended.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent bdf53098
...@@ -42,16 +42,17 @@ static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) ...@@ -42,16 +42,17 @@ static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
static int iproc_pcie_bcma_probe(struct bcma_device *bdev) static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
{ {
struct device *dev = &bdev->dev;
struct iproc_pcie *pcie; struct iproc_pcie *pcie;
LIST_HEAD(res); LIST_HEAD(res);
struct resource res_mem; struct resource res_mem;
int ret; int ret;
pcie = devm_kzalloc(&bdev->dev, sizeof(*pcie), GFP_KERNEL); pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie) if (!pcie)
return -ENOMEM; return -ENOMEM;
pcie->dev = &bdev->dev; pcie->dev = dev;
bcma_set_drvdata(bdev, pcie); bcma_set_drvdata(bdev, pcie);
pcie->base = bdev->io_addr; pcie->base = bdev->io_addr;
...@@ -67,7 +68,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) ...@@ -67,7 +68,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
ret = iproc_pcie_setup(pcie, &res); ret = iproc_pcie_setup(pcie, &res);
if (ret) if (ret)
dev_err(pcie->dev, "PCIe controller setup failed\n"); dev_err(dev, "PCIe controller setup failed\n");
pci_free_resource_list(&res); pci_free_resource_list(&res);
......
...@@ -40,35 +40,36 @@ MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); ...@@ -40,35 +40,36 @@ MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table);
static int iproc_pcie_pltfm_probe(struct platform_device *pdev) static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
const struct of_device_id *of_id; const struct of_device_id *of_id;
struct iproc_pcie *pcie; struct iproc_pcie *pcie;
struct device_node *np = pdev->dev.of_node; struct device_node *np = dev->of_node;
struct resource reg; struct resource reg;
resource_size_t iobase = 0; resource_size_t iobase = 0;
LIST_HEAD(res); LIST_HEAD(res);
int ret; int ret;
of_id = of_match_device(iproc_pcie_of_match_table, &pdev->dev); of_id = of_match_device(iproc_pcie_of_match_table, dev);
if (!of_id) if (!of_id)
return -EINVAL; return -EINVAL;
pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie) if (!pcie)
return -ENOMEM; return -ENOMEM;
pcie->dev = &pdev->dev; pcie->dev = dev;
pcie->type = (enum iproc_pcie_type)of_id->data; pcie->type = (enum iproc_pcie_type)of_id->data;
platform_set_drvdata(pdev, pcie); platform_set_drvdata(pdev, pcie);
ret = of_address_to_resource(np, 0, &reg); ret = of_address_to_resource(np, 0, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(pcie->dev, "unable to obtain controller resources\n"); dev_err(dev, "unable to obtain controller resources\n");
return ret; return ret;
} }
pcie->base = devm_ioremap(pcie->dev, reg.start, resource_size(&reg)); pcie->base = devm_ioremap(dev, reg.start, resource_size(&reg));
if (!pcie->base) { if (!pcie->base) {
dev_err(pcie->dev, "unable to map controller registers\n"); dev_err(dev, "unable to map controller registers\n");
return -ENOMEM; return -ENOMEM;
} }
pcie->base_addr = reg.start; pcie->base_addr = reg.start;
...@@ -79,7 +80,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -79,7 +80,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
ret = of_property_read_u32(np, "brcm,pcie-ob-axi-offset", ret = of_property_read_u32(np, "brcm,pcie-ob-axi-offset",
&val); &val);
if (ret) { if (ret) {
dev_err(pcie->dev, dev_err(dev,
"missing brcm,pcie-ob-axi-offset property\n"); "missing brcm,pcie-ob-axi-offset property\n");
return ret; return ret;
} }
...@@ -88,7 +89,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -88,7 +89,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
ret = of_property_read_u32(np, "brcm,pcie-ob-window-size", ret = of_property_read_u32(np, "brcm,pcie-ob-window-size",
&val); &val);
if (ret) { if (ret) {
dev_err(pcie->dev, dev_err(dev,
"missing brcm,pcie-ob-window-size property\n"); "missing brcm,pcie-ob-window-size property\n");
return ret; return ret;
} }
...@@ -101,7 +102,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -101,7 +102,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
} }
/* PHY use is optional */ /* PHY use is optional */
pcie->phy = devm_phy_get(&pdev->dev, "pcie-phy"); pcie->phy = devm_phy_get(dev, "pcie-phy");
if (IS_ERR(pcie->phy)) { if (IS_ERR(pcie->phy)) {
if (PTR_ERR(pcie->phy) == -EPROBE_DEFER) if (PTR_ERR(pcie->phy) == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
...@@ -110,7 +111,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -110,7 +111,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase);
if (ret) { if (ret) {
dev_err(pcie->dev, dev_err(dev,
"unable to get PCI host bridge resources\n"); "unable to get PCI host bridge resources\n");
return ret; return ret;
} }
...@@ -119,7 +120,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) ...@@ -119,7 +120,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
ret = iproc_pcie_setup(pcie, &res); ret = iproc_pcie_setup(pcie, &res);
if (ret) if (ret)
dev_err(pcie->dev, "PCIe controller setup failed\n"); dev_err(dev, "PCIe controller setup failed\n");
pci_free_resource_list(&res); pci_free_resource_list(&res);
......
...@@ -258,6 +258,7 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie) ...@@ -258,6 +258,7 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie)
static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)
{ {
struct device *dev = pcie->dev;
u8 hdr_type; u8 hdr_type;
u32 link_ctrl, class, val; u32 link_ctrl, class, val;
u16 pos, link_status; u16 pos, link_status;
...@@ -272,14 +273,14 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) ...@@ -272,14 +273,14 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)
val = iproc_pcie_read_reg(pcie, IPROC_PCIE_LINK_STATUS); val = iproc_pcie_read_reg(pcie, IPROC_PCIE_LINK_STATUS);
if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) { if (!(val & PCIE_PHYLINKUP) || !(val & PCIE_DL_ACTIVE)) {
dev_err(pcie->dev, "PHY or data link is INACTIVE!\n"); dev_err(dev, "PHY or data link is INACTIVE!\n");
return -ENODEV; return -ENODEV;
} }
/* make sure we are not in EP mode */ /* make sure we are not in EP mode */
pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type); pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type);
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) { if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
dev_err(pcie->dev, "in EP mode, hdr=%#02x\n", hdr_type); dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
return -EFAULT; return -EFAULT;
} }
...@@ -324,7 +325,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) ...@@ -324,7 +325,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)
} }
} }
dev_info(pcie->dev, "link: %s\n", link_is_active ? "UP" : "DOWN"); dev_info(dev, "link: %s\n", link_is_active ? "UP" : "DOWN");
return link_is_active ? 0 : -ENODEV; return link_is_active ? 0 : -ENODEV;
} }
...@@ -349,12 +350,13 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, ...@@ -349,12 +350,13 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,
u64 pci_addr, resource_size_t size) u64 pci_addr, resource_size_t size)
{ {
struct iproc_pcie_ob *ob = &pcie->ob; struct iproc_pcie_ob *ob = &pcie->ob;
struct device *dev = pcie->dev;
unsigned i; unsigned i;
u64 max_size = (u64)ob->window_size * MAX_NUM_OB_WINDOWS; u64 max_size = (u64)ob->window_size * MAX_NUM_OB_WINDOWS;
u64 remainder; u64 remainder;
if (size > max_size) { if (size > max_size) {
dev_err(pcie->dev, dev_err(dev,
"res size %pap exceeds max supported size 0x%llx\n", "res size %pap exceeds max supported size 0x%llx\n",
&size, max_size); &size, max_size);
return -EINVAL; return -EINVAL;
...@@ -362,15 +364,14 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, ...@@ -362,15 +364,14 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,
div64_u64_rem(size, ob->window_size, &remainder); div64_u64_rem(size, ob->window_size, &remainder);
if (remainder) { if (remainder) {
dev_err(pcie->dev, dev_err(dev,
"res size %pap needs to be multiple of window size %pap\n", "res size %pap needs to be multiple of window size %pap\n",
&size, &ob->window_size); &size, &ob->window_size);
return -EINVAL; return -EINVAL;
} }
if (axi_addr < ob->axi_offset) { if (axi_addr < ob->axi_offset) {
dev_err(pcie->dev, dev_err(dev, "axi address %pap less than offset %pap\n",
"axi address %pap less than offset %pap\n",
&axi_addr, &ob->axi_offset); &axi_addr, &ob->axi_offset);
return -EINVAL; return -EINVAL;
} }
...@@ -406,6 +407,7 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr, ...@@ -406,6 +407,7 @@ static int iproc_pcie_setup_ob(struct iproc_pcie *pcie, u64 axi_addr,
static int iproc_pcie_map_ranges(struct iproc_pcie *pcie, static int iproc_pcie_map_ranges(struct iproc_pcie *pcie,
struct list_head *resources) struct list_head *resources)
{ {
struct device *dev = pcie->dev;
struct resource_entry *window; struct resource_entry *window;
int ret; int ret;
...@@ -425,7 +427,7 @@ static int iproc_pcie_map_ranges(struct iproc_pcie *pcie, ...@@ -425,7 +427,7 @@ static int iproc_pcie_map_ranges(struct iproc_pcie *pcie,
return ret; return ret;
break; break;
default: default:
dev_err(pcie->dev, "invalid resource %pR\n", res); dev_err(dev, "invalid resource %pR\n", res);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -455,6 +457,7 @@ static void iproc_pcie_msi_disable(struct iproc_pcie *pcie) ...@@ -455,6 +457,7 @@ static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)
int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
{ {
struct device *dev;
int ret; int ret;
void *sysdata; void *sysdata;
struct pci_bus *bus; struct pci_bus *bus;
...@@ -462,19 +465,20 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -462,19 +465,20 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
if (!pcie || !pcie->dev || !pcie->base) if (!pcie || !pcie->dev || !pcie->base)
return -EINVAL; return -EINVAL;
ret = devm_request_pci_bus_resources(pcie->dev, res); dev = pcie->dev;
ret = devm_request_pci_bus_resources(dev, res);
if (ret) if (ret)
return ret; return ret;
ret = phy_init(pcie->phy); ret = phy_init(pcie->phy);
if (ret) { if (ret) {
dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); dev_err(dev, "unable to initialize PCIe PHY\n");
return ret; return ret;
} }
ret = phy_power_on(pcie->phy); ret = phy_power_on(pcie->phy);
if (ret) { if (ret) {
dev_err(pcie->dev, "unable to power on PCIe PHY\n"); dev_err(dev, "unable to power on PCIe PHY\n");
goto err_exit_phy; goto err_exit_phy;
} }
...@@ -486,7 +490,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -486,7 +490,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
pcie->reg_offsets = iproc_pcie_reg_paxc; pcie->reg_offsets = iproc_pcie_reg_paxc;
break; break;
default: default:
dev_err(pcie->dev, "incompatible iProc PCIe interface\n"); dev_err(dev, "incompatible iProc PCIe interface\n");
ret = -EINVAL; ret = -EINVAL;
goto err_power_off_phy; goto err_power_off_phy;
} }
...@@ -496,7 +500,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -496,7 +500,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
if (pcie->need_ob_cfg) { if (pcie->need_ob_cfg) {
ret = iproc_pcie_map_ranges(pcie, res); ret = iproc_pcie_map_ranges(pcie, res);
if (ret) { if (ret) {
dev_err(pcie->dev, "map failed\n"); dev_err(dev, "map failed\n");
goto err_power_off_phy; goto err_power_off_phy;
} }
} }
...@@ -508,9 +512,9 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -508,9 +512,9 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
sysdata = pcie; sysdata = pcie;
#endif #endif
bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, sysdata, res); bus = pci_create_root_bus(dev, 0, &iproc_pcie_ops, sysdata, res);
if (!bus) { if (!bus) {
dev_err(pcie->dev, "unable to create PCI root bus\n"); dev_err(dev, "unable to create PCI root bus\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_power_off_phy; goto err_power_off_phy;
} }
...@@ -518,7 +522,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -518,7 +522,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
ret = iproc_pcie_check_link(pcie, bus); ret = iproc_pcie_check_link(pcie, bus);
if (ret) { if (ret) {
dev_err(pcie->dev, "no PCIe EP device detected\n"); dev_err(dev, "no PCIe EP device detected\n");
goto err_rm_root_bus; goto err_rm_root_bus;
} }
...@@ -526,7 +530,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) ...@@ -526,7 +530,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
if (IS_ENABLED(CONFIG_PCI_MSI)) if (IS_ENABLED(CONFIG_PCI_MSI))
if (iproc_pcie_msi_enable(pcie)) if (iproc_pcie_msi_enable(pcie))
dev_info(pcie->dev, "not using iProc MSI\n"); dev_info(dev, "not using iProc MSI\n");
pci_scan_child_bus(bus); pci_scan_child_bus(bus);
pci_assign_unassigned_bus_resources(bus); pci_assign_unassigned_bus_resources(bus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment