Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp256290rwe; Tue, 23 Aug 2022 23:45:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR70U09dX5pWSB4Q1996vS/Jthe2MibAUb5Wkpr+0WlmdiHEA4nUaGvbH7ViK+z6YnDPiCmS X-Received: by 2002:a63:564f:0:b0:425:f2cd:d0ce with SMTP id g15-20020a63564f000000b00425f2cdd0cemr22851189pgm.143.1661323551266; Tue, 23 Aug 2022 23:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661323551; cv=none; d=google.com; s=arc-20160816; b=ajwSyq7L5pSWzsTQE+xGKXVIA4a0eXkvK24zex+Jad4RBmHK+xwlgLBXSKo3ZV9/Y7 +p23bal6zMpXk5Ou/sImhJz0n+D7zj7qrgJTv9X+xacQRCV1ryBE5YB+n0T1xPRjIjKR s/nLWHRqRGBV1jWp4FqLXkSVBK1CBZEbMUMTMrO9MVeEWTHdd2QMc8nk7hhNLkqNBOoZ DXQrDe9gqDvHkOcvX3bR8BtHwaVF7inGZDWDXt5+FGnLzYjGJ1chT7i9+tbhD59Yfmz5 egTz4Z9gAi/W2wbFgiGpDalj4O4/8Ye/ysXifglapHPfCc/Xodme0mCfEnasZDdkj/mA 0vZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ImPKbcBfFtxcW/PmArBWSknFSFRwD2ALu+R1AKF/ecw=; b=sG8dl0DUt8C3pqSZRrYBLxb62MYN80040YtdrBLi4+DM2DSExDoAS9cXzCJqBCkhUb f6PNrW/KxgzGwdIAm27E9Sfq/ZaPGpiJI8/iCtMrdxpy8gugW8k7f8RwoPg0VwWa+yg8 0+gXQX0y8JCTusNiCvw3fydv8LaRxg3OIdfP5QxSVbnQfK5uoWdPgIkd88AGoh+qNzI9 NxwGKFM9z0zT4HByXJN5VBrTHyFwmim4AkrBiKCTQBFVLmt09cMN/6Cfe9OaNVxZcJ3s t0fLTO9ZntdV1b3TZYnexzA2uStUnsc05iJLdxS1tAc5n10GB1wSYDAa524qonWtuocV VTiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=k4uI9w1t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j189-20020a6380c6000000b0042b19761809si1165017pgd.445.2022.08.23.23.45.40; Tue, 23 Aug 2022 23:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=k4uI9w1t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbiHXGnr (ORCPT + 99 others); Wed, 24 Aug 2022 02:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234824AbiHXGnp (ORCPT ); Wed, 24 Aug 2022 02:43:45 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D85E485FC4 for ; Tue, 23 Aug 2022 23:43:44 -0700 (PDT) X-UUID: 068c5b5bfc6742c4a3e4b15638c1dca6-20220824 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ImPKbcBfFtxcW/PmArBWSknFSFRwD2ALu+R1AKF/ecw=; b=k4uI9w1teasmcmKBmmf4c1KqaAj1JxHiperD3Y0bPTv9pUJFIqEG1HO6SDvaPxiQX6oSALo6eOODfvxUhOBXaFVQjpunu+x6h34P16Ct7AFMEuvdcKdwZgfvSzJp7uv9xfLBivT2WhxWrUQPPU0PTsKgKRViIBmGmLgEMIqee0U=; X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:962b12c7-46be-4e09-9482-c381fd9be482,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Relea se_Ham,ACTION:release,TS:95 X-CID-INFO: VERSION:1.1.10,REQID:962b12c7-46be-4e09-9482-c381fd9be482,OB:0,LOB :0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS 981B3D,ACTION:quarantine,TS:95 X-CID-META: VersionHash:84eae18,CLOUDID:f71672cf-20bd-4e5e-ace8-00692b7ab380,C OID:10680e21d0a4,Recheck:0,SF:28|16|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 068c5b5bfc6742c4a3e4b15638c1dca6-20220824 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1143684742; Wed, 24 Aug 2022 14:43:39 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 24 Aug 2022 14:43:38 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 24 Aug 2022 14:43:37 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Will Deacon CC: Robin Murphy , , , , , , "Yong Wu" , AngeloGioacchino Del Regno , , , , , , , , Guenter Roeck , "Dan Carpenter" Subject: [PATCH v4 2/6] iommu/mediatek: Use component_match_add Date: Wed, 24 Aug 2022 14:43:02 +0800 Message-ID: <20220824064306.21495-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220824064306.21495-1-yong.wu@mediatek.com> References: <20220824064306.21495-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to simplify the error patch(avoid call of_node_put), Use component_match_add instead component_match_add_release since we are only interested in the "device" here. Then we could always call of_node_put in normal path. Strictly this is not a fixes patch, but it is a prepare for adding the error path, thus I add a Fixes tag too. Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM TYPE") Suggested-by: Robin Murphy Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index f2560ce72b6c..9c5902207bef 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1066,19 +1066,17 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m id = i; plarbdev = of_find_device_by_node(larbnode); - if (!plarbdev) { - of_node_put(larbnode); + of_node_put(larbnode); + if (!plarbdev) return -ENODEV; - } + if (!plarbdev->dev.driver) { - of_node_put(larbnode); platform_device_put(plarbdev); return -EPROBE_DEFER; } data->larb_imu[id].dev = &plarbdev->dev; - component_match_add_release(dev, match, component_release_of, - component_compare_of, larbnode); + component_match_add(dev, match, component_compare_dev, &plarbdev->dev); platform_device_put(plarbdev); } -- 2.18.0