Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbeAPN2f (ORCPT + 1 other); Tue, 16 Jan 2018 08:28:35 -0500 Received: from regular1.263xmail.com ([211.150.99.131]:54127 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbeAPN0o (ORCPT ); Tue, 16 Jan 2018 08:26:44 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, robin.murphy@arm.com, xxm@rock-chips.com, tfiga@chromium.org, Jeffy Chen , Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 05/13] iommu/rockchip: Fix error handling in init Date: Tue, 16 Jan 2018 21:25:32 +0800 Message-Id: <20180116132540.18939-6-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116132540.18939-1-jeffy.chen@rock-chips.com> References: <20180116132540.18939-1-jeffy.chen@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: It's hard to undo bus_set_iommu() in the error path, so move it to the end of rk_iommu_probe(). Signed-off-by: Jeffy Chen --- Changes in v2: Move bus_set_iommu() to rk_iommu_probe(). drivers/iommu/rockchip-iommu.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index bd8b32dc0db6..d2a0b0daf40d 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1187,6 +1187,8 @@ static int rk_iommu_probe(struct platform_device *pdev) return err; } + bus_set_iommu(&platform_bus_type, &rk_iommu_ops); + return 0; } @@ -1218,27 +1220,19 @@ static struct platform_driver rk_iommu_driver = { static int __init rk_iommu_init(void) { - struct device_node *np; int ret; - np = of_find_matching_node(NULL, rk_iommu_dt_ids); - if (!np) - return 0; - - of_node_put(np); - - ret = bus_set_iommu(&platform_bus_type, &rk_iommu_ops); - if (ret) - return ret; - ret = platform_driver_register(&rk_iommu_domain_driver); if (ret) return ret; ret = platform_driver_register(&rk_iommu_driver); - if (ret) + if (ret) { platform_driver_unregister(&rk_iommu_domain_driver); - return ret; + return ret; + } + + return 0; } static void __exit rk_iommu_exit(void) { -- 2.11.0