Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3544879rwb; Tue, 20 Sep 2022 00:53:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pk3zl1Jz/TRdh/ewjotSNV7gyutpqyBUjHG81bozMVV5D0AOt0mApJOmLGBRIaLEt3mo9 X-Received: by 2002:a17:90b:4a89:b0:202:b1b7:7ae with SMTP id lp9-20020a17090b4a8900b00202b1b707aemr2522658pjb.149.1663660380602; Tue, 20 Sep 2022 00:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663660380; cv=none; d=google.com; s=arc-20160816; b=B45h93BZQLQWItO8mHWnlBott521+H0dEJxl1NL0JP5mAFR+dsO4Etu0sVzybgwC4s sgHH3vObwVnjgKDw2pNgK6+7sn3BLHBdjW5Brmb6SyCtJwzTOkvDU9MamHErysPmQFSE XhYLeTsfIFGXmtrGutd9/1oKtSSctiFlC4zR8IguX6x9tQ4H7LLj6xog8lCstrgRH532 yKmTCvC2F4mXQz5g65fifx4G+34QUi+vnOut/3yO/k+qmUrX2jbCjV2ZNSVaKMZpDqOe mhTr+15KmLXy+FiEJDh2HhxdyK6Xmb4nqwzcNNr9o4/MIiEZ0qttOo/XhH/umFE5+x6a IU9w== 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=+d4jKSNorOrSdNx1irjAD8lZNito2qK6mpLIlUMmD4M=; b=xwRnEGGVWOj3JZhDfFKqJQbPJBy3SWtENHLJicGSvZ5JOb/NHK2d7D01kcovCa9vGU g+QXjsIYUsaVPCSKXbMe1+hQh0Ts3BdVlJUZhgwCHMTJ8BhshOn2jsU3EQJd7xPDL0jV XYvFPdBK7383CRCHWRMZzH3td1eYrBdv14NAh9rnsjBcRANZJKtvmq0/aVas2rhEhoXc TzuAJzz86CrVpXan0QLfhz6fdj5p7BdO2hh0Jrq1NtLPNF5ic4oJf55L+3t2GuJx6Eri exKWGu2vUpTlE6+CNoFSTgJUbFDVNqsw3ZaDDddcYIrdXVj/VziKvWEGW9SavWhiarys 7xPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=bBnEjqf7; 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 u18-20020a056a00125200b0053ff65e3958si1137588pfi.136.2022.09.20.00.52.48; Tue, 20 Sep 2022 00:53:00 -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=bBnEjqf7; 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 S230142AbiITGkB (ORCPT + 99 others); Tue, 20 Sep 2022 02:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbiITGjR (ORCPT ); Tue, 20 Sep 2022 02:39:17 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0906D5F12F for ; Mon, 19 Sep 2022 23:38:29 -0700 (PDT) X-UUID: 12fe5c67f7744b229617add401d30787-20220920 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=+d4jKSNorOrSdNx1irjAD8lZNito2qK6mpLIlUMmD4M=; b=bBnEjqf738ppwvbPfCpGDchyrqAFcHU0ZrF8varHkrtz3GeI5DtX9kHsW/Ll/729t6JysgmbuXJkEizywumB7uTWh1hKF3QTq9z2dxHJAPEhwPJEj+9DFGPdO44jnjMyHNyd1GSWka+FQLcgkVDEsaHdfJhVvxGHnFKp7C7no/c=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:7c40caca-b50b-48f8-b655-d27b6b9d3bfc,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.11,REQID:7c40caca-b50b-48f8-b655-d27b6b9d3bfc,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:39a5ff1,CLOUDID:57496170-dafa-4a42-b716-cf2cd4845592,B ulkID:220920143810HUNC1YJZ,BulkQuantity:0,Recheck:0,SF:28|17|19|48|823|824 ,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL :0 X-UUID: 12fe5c67f7744b229617add401d30787-20220920 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 900821920; Tue, 20 Sep 2022 14:38:08 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Tue, 20 Sep 2022 14:38:06 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 20 Sep 2022 14:38:05 +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 v6 2/6] iommu/mediatek: Use component_match_add Date: Tue, 20 Sep 2022 14:37:29 +0800 Message-ID: <20220920063733.21770-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220920063733.21770-1-yong.wu@mediatek.com> References: <20220920063733.21770-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.0 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,UNPARSEABLE_RELAY,URIBL_CSS 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 Reviewed-by: AngeloGioacchino Del Regno --- 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 21a8ce503a0e..83b279432406 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