.. | .. |
---|
618 | 618 | ret = iommu_device_sysfs_add(&data->iommu, &pdev->dev, NULL, |
---|
619 | 619 | dev_name(&pdev->dev)); |
---|
620 | 620 | if (ret) |
---|
621 | | - return ret; |
---|
| 621 | + goto out_clk_unprepare; |
---|
622 | 622 | |
---|
623 | 623 | iommu_device_set_ops(&data->iommu, &mtk_iommu_ops); |
---|
624 | 624 | |
---|
625 | 625 | ret = iommu_device_register(&data->iommu); |
---|
626 | 626 | if (ret) |
---|
627 | | - return ret; |
---|
| 627 | + goto out_sysfs_remove; |
---|
628 | 628 | |
---|
629 | | - if (!iommu_present(&platform_bus_type)) |
---|
630 | | - bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); |
---|
| 629 | + if (!iommu_present(&platform_bus_type)) { |
---|
| 630 | + ret = bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); |
---|
| 631 | + if (ret) |
---|
| 632 | + goto out_dev_unreg; |
---|
| 633 | + } |
---|
631 | 634 | |
---|
632 | | - return component_master_add_with_match(dev, &mtk_iommu_com_ops, match); |
---|
| 635 | + ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match); |
---|
| 636 | + if (ret) |
---|
| 637 | + goto out_bus_set_null; |
---|
| 638 | + return ret; |
---|
| 639 | + |
---|
| 640 | +out_bus_set_null: |
---|
| 641 | + bus_set_iommu(&platform_bus_type, NULL); |
---|
| 642 | +out_dev_unreg: |
---|
| 643 | + iommu_device_unregister(&data->iommu); |
---|
| 644 | +out_sysfs_remove: |
---|
| 645 | + iommu_device_sysfs_remove(&data->iommu); |
---|
| 646 | +out_clk_unprepare: |
---|
| 647 | + clk_disable_unprepare(data->bclk); |
---|
| 648 | + return ret; |
---|
633 | 649 | } |
---|
634 | 650 | |
---|
635 | 651 | static int mtk_iommu_remove(struct platform_device *pdev) |
---|