Commit 10feee14 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Felipe Balbi

usb: isp1760: Use the managed devm_ioremap_resource() API

This simplifies error and remove code paths.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 4942e00e
...@@ -2234,14 +2234,14 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, ...@@ -2234,14 +2234,14 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
if (IS_ERR(priv->rst_gpio)) { if (IS_ERR(priv->rst_gpio)) {
ret = PTR_ERR(priv->rst_gpio); ret = PTR_ERR(priv->rst_gpio);
goto err_put; goto error;
} }
init_memory(priv); init_memory(priv);
hcd->regs = ioremap(mem->start, resource_size(mem)); hcd->regs = devm_ioremap_resource(dev, mem);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
ret = -EIO; ret = PTR_ERR(hcd->regs);
goto err_put; goto error;
} }
hcd->irq = irq; hcd->irq = irq;
...@@ -2250,19 +2250,15 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, ...@@ -2250,19 +2250,15 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
ret = usb_add_hcd(hcd, irq, irqflags); ret = usb_add_hcd(hcd, irq, irqflags);
if (ret) if (ret)
goto err_unmap; goto error;
device_wakeup_enable(hcd->self.controller); device_wakeup_enable(hcd->self.controller);
dev_set_drvdata(dev, hcd); dev_set_drvdata(dev, hcd);
return 0; return 0;
err_unmap: error:
iounmap(hcd->regs);
err_put:
usb_put_hcd(hcd); usb_put_hcd(hcd);
return ret; return ret;
} }
...@@ -2271,8 +2267,6 @@ void isp1760_unregister(struct device *dev) ...@@ -2271,8 +2267,6 @@ void isp1760_unregister(struct device *dev)
struct usb_hcd *hcd = dev_get_drvdata(dev); struct usb_hcd *hcd = dev_get_drvdata(dev);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
} }
......
...@@ -85,8 +85,9 @@ static int isp1761_pci_probe(struct pci_dev *dev, ...@@ -85,8 +85,9 @@ static int isp1761_pci_probe(struct pci_dev *dev,
chip_addr = ioremap_nocache(pci_mem_phy0,memlength); chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
if (!chip_addr) { if (!chip_addr) {
printk(KERN_ERR "Error ioremap failed\n"); printk(KERN_ERR "Error ioremap failed\n");
release_mem_region(pci_mem_phy0, memlength);
ret_status = -ENOMEM; ret_status = -ENOMEM;
goto cleanup3; goto cleanup2;
} }
/* bad pci latencies can contribute to overruns */ /* bad pci latencies can contribute to overruns */
...@@ -114,6 +115,7 @@ static int isp1761_pci_probe(struct pci_dev *dev, ...@@ -114,6 +115,7 @@ static int isp1761_pci_probe(struct pci_dev *dev,
} }
iounmap(chip_addr); iounmap(chip_addr);
release_mem_region(pci_mem_phy0, memlength);
/* Host Controller presence is detected by writing to scratch register /* Host Controller presence is detected by writing to scratch register
* and reading back and checking the contents are same or not * and reading back and checking the contents are same or not
...@@ -121,7 +123,7 @@ static int isp1761_pci_probe(struct pci_dev *dev, ...@@ -121,7 +123,7 @@ static int isp1761_pci_probe(struct pci_dev *dev,
if (reg_data != 0xFACE) { if (reg_data != 0xFACE) {
dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data); dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
ret_status = -ENOMEM; ret_status = -ENOMEM;
goto cleanup3; goto cleanup2;
} }
pci_set_master(dev); pci_set_master(dev);
...@@ -132,20 +134,14 @@ static int isp1761_pci_probe(struct pci_dev *dev, ...@@ -132,20 +134,14 @@ static int isp1761_pci_probe(struct pci_dev *dev,
reg_data |= 0x900; reg_data |= 0x900;
writel(reg_data, iobase + PLX_INT_CSR_REG); writel(reg_data, iobase + PLX_INT_CSR_REG);
dev->dev.dma_mask = NULL;
ret_status = isp1760_register(&dev->resource[3], dev->irq, IRQF_SHARED,
&dev->dev, devflags);
if (ret_status < 0)
goto cleanup3;
/* done with PLX IO access */ /* done with PLX IO access */
iounmap(iobase); iounmap(iobase);
release_mem_region(nxp_pci_io_base, iolength); release_mem_region(nxp_pci_io_base, iolength);
return 0; dev->dev.dma_mask = NULL;
return isp1760_register(&dev->resource[3], dev->irq, IRQF_SHARED,
&dev->dev, devflags);
cleanup3:
release_mem_region(pci_mem_phy0, memlength);
cleanup2: cleanup2:
iounmap(iobase); iounmap(iobase);
cleanup1: cleanup1:
...@@ -193,25 +189,14 @@ static int isp1760_plat_probe(struct platform_device *pdev) ...@@ -193,25 +189,14 @@ static int isp1760_plat_probe(struct platform_device *pdev)
unsigned int devflags = 0; unsigned int devflags = 0;
struct resource *mem_res; struct resource *mem_res;
struct resource *irq_res; struct resource *irq_res;
resource_size_t mem_size;
int ret; int ret;
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem_res) {
pr_warning("isp1760: Memory resource not available\n");
return -ENODEV;
}
mem_size = resource_size(mem_res);
if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
pr_warning("isp1760: Cannot reserve the memory resource\n");
return -EBUSY;
}
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq_res) { if (!irq_res) {
pr_warning("isp1760: IRQ resource not available\n"); pr_warning("isp1760: IRQ resource not available\n");
ret = -ENODEV; return -ENODEV;
goto cleanup;
} }
irqflags |= irq_res->flags & IRQF_TRIGGER_MASK; irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
...@@ -260,14 +245,10 @@ static int isp1760_plat_probe(struct platform_device *pdev) ...@@ -260,14 +245,10 @@ static int isp1760_plat_probe(struct platform_device *pdev)
ret = isp1760_register(mem_res, irq_res->start, irqflags, &pdev->dev, ret = isp1760_register(mem_res, irq_res->start, irqflags, &pdev->dev,
devflags); devflags);
if (ret < 0) if (ret < 0)
goto cleanup; return ret;
pr_info("ISP1760 USB device initialised\n"); pr_info("ISP1760 USB device initialised\n");
return 0; return 0;
cleanup:
release_mem_region(mem_res->start, mem_size);
return ret;
} }
static int isp1760_plat_remove(struct platform_device *pdev) static int isp1760_plat_remove(struct platform_device *pdev)
......
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