Commit f63fbcee authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Darren Hart

intel_scu_ipc: Fix error path by turning to devm_* / pcim_*

The error handling is broken right now since it leaves resources unfreed.
Convert the code to use managed resources to fix the error handling.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent c4602280
...@@ -563,7 +563,6 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -563,7 +563,6 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
{ {
int err; int err;
struct intel_scu_ipc_pdata_t *pdata; struct intel_scu_ipc_pdata_t *pdata;
resource_size_t base;
if (ipcdev.pdev) /* We support only one SCU */ if (ipcdev.pdev) /* We support only one SCU */
return -EBUSY; return -EBUSY;
...@@ -573,32 +572,26 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -573,32 +572,26 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
ipcdev.pdev = pci_dev_get(dev); ipcdev.pdev = pci_dev_get(dev);
ipcdev.irq_mode = pdata->irq_mode; ipcdev.irq_mode = pdata->irq_mode;
err = pci_enable_device(dev); err = pcim_enable_device(dev);
if (err) if (err)
return err; return err;
err = pci_request_regions(dev, "intel_scu_ipc"); err = pcim_iomap_regions(dev, 1 << 0, pci_name(dev));
if (err) if (err)
return err; return err;
base = pci_resource_start(dev, 0);
if (!base)
return -ENOMEM;
init_completion(&ipcdev.cmd_complete); init_completion(&ipcdev.cmd_complete);
if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) err = devm_request_irq(&dev->dev, dev->irq, ioc, 0, "intel_scu_ipc",
return -EBUSY; &ipcdev);
if (err)
return err;
ipcdev.ipc_base = ioremap_nocache(base, pci_resource_len(dev, 0)); ipcdev.ipc_base = pcim_iomap_table(dev)[0];
if (!ipcdev.ipc_base)
return -ENOMEM;
ipcdev.i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len); ipcdev.i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len);
if (!ipcdev.i2c_base) { if (!ipcdev.i2c_base)
iounmap(ipcdev.ipc_base);
return -ENOMEM; return -ENOMEM;
}
intel_scu_devices_create(); intel_scu_devices_create();
...@@ -617,10 +610,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -617,10 +610,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
*/ */
static void ipc_remove(struct pci_dev *pdev) static void ipc_remove(struct pci_dev *pdev)
{ {
free_irq(pdev->irq, &ipcdev);
pci_release_regions(pdev);
pci_dev_put(ipcdev.pdev); pci_dev_put(ipcdev.pdev);
iounmap(ipcdev.ipc_base);
iounmap(ipcdev.i2c_base); iounmap(ipcdev.i2c_base);
ipcdev.pdev = NULL; ipcdev.pdev = NULL;
intel_scu_devices_destroy(); intel_scu_devices_destroy();
......
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