forked from Minki/linux
usb: isp1760: Use the managed devm_ioremap_resource() API
This simplifies error and remove code paths. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
4942e00e55
commit
10feee1446
@ -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);
|
||||
if (IS_ERR(priv->rst_gpio)) {
|
||||
ret = PTR_ERR(priv->rst_gpio);
|
||||
goto err_put;
|
||||
goto error;
|
||||
}
|
||||
|
||||
init_memory(priv);
|
||||
hcd->regs = ioremap(mem->start, resource_size(mem));
|
||||
if (!hcd->regs) {
|
||||
ret = -EIO;
|
||||
goto err_put;
|
||||
hcd->regs = devm_ioremap_resource(dev, mem);
|
||||
if (IS_ERR(hcd->regs)) {
|
||||
ret = PTR_ERR(hcd->regs);
|
||||
goto error;
|
||||
}
|
||||
|
||||
hcd->irq = irq;
|
||||
@ -2250,19 +2250,15 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
|
||||
|
||||
ret = usb_add_hcd(hcd, irq, irqflags);
|
||||
if (ret)
|
||||
goto err_unmap;
|
||||
goto error;
|
||||
device_wakeup_enable(hcd->self.controller);
|
||||
|
||||
dev_set_drvdata(dev, hcd);
|
||||
|
||||
return 0;
|
||||
|
||||
err_unmap:
|
||||
iounmap(hcd->regs);
|
||||
|
||||
err_put:
|
||||
error:
|
||||
usb_put_hcd(hcd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2271,8 +2267,6 @@ void isp1760_unregister(struct device *dev)
|
||||
struct usb_hcd *hcd = dev_get_drvdata(dev);
|
||||
|
||||
usb_remove_hcd(hcd);
|
||||
iounmap(hcd->regs);
|
||||
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
|
||||
usb_put_hcd(hcd);
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,9 @@ static int isp1761_pci_probe(struct pci_dev *dev,
|
||||
chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
|
||||
if (!chip_addr) {
|
||||
printk(KERN_ERR "Error ioremap failed\n");
|
||||
release_mem_region(pci_mem_phy0, memlength);
|
||||
ret_status = -ENOMEM;
|
||||
goto cleanup3;
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
/* bad pci latencies can contribute to overruns */
|
||||
@ -114,6 +115,7 @@ static int isp1761_pci_probe(struct pci_dev *dev,
|
||||
}
|
||||
|
||||
iounmap(chip_addr);
|
||||
release_mem_region(pci_mem_phy0, memlength);
|
||||
|
||||
/* Host Controller presence is detected by writing to scratch register
|
||||
* and reading back and checking the contents are same or not
|
||||
@ -121,7 +123,7 @@ static int isp1761_pci_probe(struct pci_dev *dev,
|
||||
if (reg_data != 0xFACE) {
|
||||
dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
|
||||
ret_status = -ENOMEM;
|
||||
goto cleanup3;
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
pci_set_master(dev);
|
||||
@ -132,20 +134,14 @@ static int isp1761_pci_probe(struct pci_dev *dev,
|
||||
reg_data |= 0x900;
|
||||
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 */
|
||||
iounmap(iobase);
|
||||
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:
|
||||
iounmap(iobase);
|
||||
cleanup1:
|
||||
@ -193,25 +189,14 @@ static int isp1760_plat_probe(struct platform_device *pdev)
|
||||
unsigned int devflags = 0;
|
||||
struct resource *mem_res;
|
||||
struct resource *irq_res;
|
||||
resource_size_t mem_size;
|
||||
int ret;
|
||||
|
||||
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);
|
||||
if (!irq_res) {
|
||||
pr_warning("isp1760: IRQ resource not available\n");
|
||||
ret = -ENODEV;
|
||||
goto cleanup;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
|
||||
@ -260,14 +245,10 @@ static int isp1760_plat_probe(struct platform_device *pdev)
|
||||
ret = isp1760_register(mem_res, irq_res->start, irqflags, &pdev->dev,
|
||||
devflags);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
return ret;
|
||||
|
||||
pr_info("ISP1760 USB device initialised\n");
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
release_mem_region(mem_res->start, mem_size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isp1760_plat_remove(struct platform_device *pdev)
|
||||
|
Loading…
Reference in New Issue
Block a user