Commit a549e3aa authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

driver core: platform: Refactor error path in a couple places

The usual pattern is to bail out on the error case. Besides that
one of the labels is redundant as we may return directly. Refactor
platform_device_add() and platform_dma_configure() accordingly.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231003142122.3072824-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aab8aa0d
...@@ -678,7 +678,7 @@ int platform_device_add(struct platform_device *pdev) ...@@ -678,7 +678,7 @@ int platform_device_add(struct platform_device *pdev)
*/ */
ret = ida_alloc(&platform_devid_ida, GFP_KERNEL); ret = ida_alloc(&platform_devid_ida, GFP_KERNEL);
if (ret < 0) if (ret < 0)
goto err_out; return ret;
pdev->id = ret; pdev->id = ret;
pdev->id_auto = true; pdev->id_auto = true;
dev_set_name(&pdev->dev, "%s.%d.auto", pdev->name, pdev->id); dev_set_name(&pdev->dev, "%s.%d.auto", pdev->name, pdev->id);
...@@ -712,8 +712,10 @@ int platform_device_add(struct platform_device *pdev) ...@@ -712,8 +712,10 @@ int platform_device_add(struct platform_device *pdev)
dev_name(&pdev->dev), dev_name(pdev->dev.parent)); dev_name(&pdev->dev), dev_name(pdev->dev.parent));
ret = device_add(&pdev->dev); ret = device_add(&pdev->dev);
if (ret == 0) if (ret)
return ret; goto failed;
return 0;
failed: failed:
if (pdev->id_auto) { if (pdev->id_auto) {
...@@ -727,7 +729,6 @@ int platform_device_add(struct platform_device *pdev) ...@@ -727,7 +729,6 @@ int platform_device_add(struct platform_device *pdev)
release_resource(r); release_resource(r);
} }
err_out:
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(platform_device_add); EXPORT_SYMBOL_GPL(platform_device_add);
...@@ -1453,12 +1454,12 @@ static int platform_dma_configure(struct device *dev) ...@@ -1453,12 +1454,12 @@ static int platform_dma_configure(struct device *dev)
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
ret = acpi_dma_configure(dev, attr); ret = acpi_dma_configure(dev, attr);
} }
if (ret || drv->driver_managed_dma)
return ret;
if (!ret && !drv->driver_managed_dma) { ret = iommu_device_use_default_domain(dev);
ret = iommu_device_use_default_domain(dev); if (ret)
if (ret) arch_teardown_dma_ops(dev);
arch_teardown_dma_ops(dev);
}
return ret; return ret;
} }
......
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