iommu/msm: Use platform_register/unregister_drivers()
authorThierry Reding <treding@nvidia.com>
Wed, 2 Dec 2015 16:26:01 +0000 (17:26 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 14 Dec 2015 14:51:21 +0000 (15:51 +0100)
These new helpers simplify implementing multi-driver modules and
properly handle failure to register one driver by unregistering all
previously registered drivers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/msm_iommu_dev.c

index b6d01f97e53713ef06ec1f7689d759773ea467f0..4b09e815accf650c290d5fa53a66c1384ec992ee 100644 (file)
@@ -359,30 +359,19 @@ static struct platform_driver msm_iommu_ctx_driver = {
        .remove         = msm_iommu_ctx_remove,
 };
 
+static struct platform_driver * const drivers[] = {
+       &msm_iommu_driver,
+       &msm_iommu_ctx_driver,
+};
+
 static int __init msm_iommu_driver_init(void)
 {
-       int ret;
-       ret = platform_driver_register(&msm_iommu_driver);
-       if (ret != 0) {
-               pr_err("Failed to register IOMMU driver\n");
-               goto error;
-       }
-
-       ret = platform_driver_register(&msm_iommu_ctx_driver);
-       if (ret != 0) {
-               platform_driver_unregister(&msm_iommu_driver);
-               pr_err("Failed to register IOMMU context driver\n");
-               goto error;
-       }
-
-error:
-       return ret;
+       return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 static void __exit msm_iommu_driver_exit(void)
 {
-       platform_driver_unregister(&msm_iommu_ctx_driver);
-       platform_driver_unregister(&msm_iommu_driver);
+       platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 
 subsys_initcall(msm_iommu_driver_init);