staging: mt7621-pci: convert to use 'devm_platform_ioremap_resource'

Instead of getting resources parsing from DT first and remaping
afterwards, this can be done in one step using the kernel function
'devm_platform_ioremap_resource'. Hence, update to use it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20201123093637.8300-7-sergio.paracuellos@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Sergio Paracuellos 2020-11-23 10:36:36 +01:00 committed by Greg Kroah-Hartman
parent 2fc0898bf3
commit 108b2f2a97

View file

@ -337,28 +337,18 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct pci_host_bridge *host)
} }
static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
struct device_node *node,
int slot) int slot)
{ {
struct mt7621_pcie_port *port; struct mt7621_pcie_port *port;
struct device *dev = pcie->dev; struct device *dev = pcie->dev;
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct device_node *pnode = dev->of_node;
struct resource regs;
char name[10]; char name[10];
int err;
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;
err = of_address_to_resource(pnode, slot + 1, &regs); port->base = devm_platform_ioremap_resource(pdev, slot + 1);
if (err) {
dev_err(dev, "missing \"reg\" property\n");
return err;
}
port->base = devm_ioremap_resource(dev, &regs);
if (IS_ERR(port->base)) if (IS_ERR(port->base))
return PTR_ERR(port->base); return PTR_ERR(port->base);
@ -399,17 +389,11 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,
static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
{ {
struct device *dev = pcie->dev; struct device *dev = pcie->dev;
struct platform_device *pdev = to_platform_device(dev);
struct device_node *node = dev->of_node, *child; struct device_node *node = dev->of_node, *child;
struct resource regs;
int err; int err;
err = of_address_to_resource(node, 0, &regs); pcie->base = devm_platform_ioremap_resource(pdev, 0);
if (err) {
dev_err(dev, "missing \"reg\" property\n");
return err;
}
pcie->base = devm_ioremap_resource(dev, &regs);
if (IS_ERR(pcie->base)) if (IS_ERR(pcie->base))
return PTR_ERR(pcie->base); return PTR_ERR(pcie->base);
@ -425,7 +409,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
slot = PCI_SLOT(err); slot = PCI_SLOT(err);
err = mt7621_pcie_parse_port(pcie, child, slot); err = mt7621_pcie_parse_port(pcie, slot);
if (err) { if (err) {
of_node_put(child); of_node_put(child);
return err; return err;