Skip to content

Commit 62565a7

Browse files
Uwe Kleine-Königjoergroedel
authored andcommitted
iommu/arm-smmu: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230321084125.337021-5-u.kleine-koenig@pengutronix.de Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 66c7076 commit 62565a7

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,16 +2211,14 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev)
22112211
clk_bulk_unprepare(smmu->num_clks, smmu->clks);
22122212
}
22132213

2214-
static int arm_smmu_device_remove(struct platform_device *pdev)
2214+
static void arm_smmu_device_remove(struct platform_device *pdev)
22152215
{
22162216
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
22172217

22182218
iommu_device_unregister(&smmu->iommu);
22192219
iommu_device_sysfs_remove(&smmu->iommu);
22202220

22212221
arm_smmu_device_shutdown(pdev);
2222-
2223-
return 0;
22242222
}
22252223

22262224
static int __maybe_unused arm_smmu_runtime_resume(struct device *dev)
@@ -2296,7 +2294,7 @@ static struct platform_driver arm_smmu_driver = {
22962294
.suppress_bind_attrs = true,
22972295
},
22982296
.probe = arm_smmu_device_probe,
2299-
.remove = arm_smmu_device_remove,
2297+
.remove_new = arm_smmu_device_remove,
23002298
.shutdown = arm_smmu_device_shutdown,
23012299
};
23022300
module_platform_driver(arm_smmu_driver);

drivers/iommu/arm/arm-smmu/qcom_iommu.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,16 +682,14 @@ static int qcom_iommu_ctx_probe(struct platform_device *pdev)
682682
return 0;
683683
}
684684

685-
static int qcom_iommu_ctx_remove(struct platform_device *pdev)
685+
static void qcom_iommu_ctx_remove(struct platform_device *pdev)
686686
{
687687
struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(pdev->dev.parent);
688688
struct qcom_iommu_ctx *ctx = platform_get_drvdata(pdev);
689689

690690
platform_set_drvdata(pdev, NULL);
691691

692692
qcom_iommu->ctxs[ctx->asid - 1] = NULL;
693-
694-
return 0;
695693
}
696694

697695
static const struct of_device_id ctx_of_match[] = {
@@ -706,7 +704,7 @@ static struct platform_driver qcom_iommu_ctx_driver = {
706704
.of_match_table = ctx_of_match,
707705
},
708706
.probe = qcom_iommu_ctx_probe,
709-
.remove = qcom_iommu_ctx_remove,
707+
.remove_new = qcom_iommu_ctx_remove,
710708
};
711709

712710
static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu)
@@ -824,16 +822,14 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
824822
return ret;
825823
}
826824

827-
static int qcom_iommu_device_remove(struct platform_device *pdev)
825+
static void qcom_iommu_device_remove(struct platform_device *pdev)
828826
{
829827
struct qcom_iommu_dev *qcom_iommu = platform_get_drvdata(pdev);
830828

831829
pm_runtime_force_suspend(&pdev->dev);
832830
platform_set_drvdata(pdev, NULL);
833831
iommu_device_sysfs_remove(&qcom_iommu->iommu);
834832
iommu_device_unregister(&qcom_iommu->iommu);
835-
836-
return 0;
837833
}
838834

839835
static int __maybe_unused qcom_iommu_resume(struct device *dev)
@@ -870,7 +866,7 @@ static struct platform_driver qcom_iommu_driver = {
870866
.pm = &qcom_iommu_pm_ops,
871867
},
872868
.probe = qcom_iommu_device_probe,
873-
.remove = qcom_iommu_device_remove,
869+
.remove_new = qcom_iommu_device_remove,
874870
};
875871

876872
static int __init qcom_iommu_init(void)

0 commit comments

Comments
 (0)