From nobody Fri Dec 19 15:18:34 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABF04168BE for ; Tue, 27 Aug 2024 02:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724727370; cv=none; b=Yab1NB/pAyjsX6rivcfvHTa/II1dTTuc/9SRBXtLaiSFpdIAZxwHHix6Ey5FMeA0v3bXb3ExHAmgpk93lu5A6OEhw1ZZcz4o6blEn8mnuRIA6ILAgS7gnRsG30QdiNbMnNbYIfM9PUeUeeL0gC0WHEtdx9PzVBPWY/GTFCJ2SaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724727370; c=relaxed/simple; bh=00F+qtLVs64QnDBC9O6mqnCINo2jn2ZRF3WxYn/xSGo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VScaaPZDgYIIgeGqsZnaV3Zs4bJ4AhhTfbLDYSiFcTrtgA38GwAQYNVHjliLlc1FLzrUTxrxycrJC+JHD1RqA+RDxxNgNcyCgX+BusHa9hSho6VVeTo1GQ7LMo3UIZ801KMhyRZuR3yUFIdgFA41TCyTpqtA95z/louS/GimcbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WtBx23VytzyQT3; Tue, 27 Aug 2024 10:55:18 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 32148140257; Tue, 27 Aug 2024 10:56:05 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Aug 2024 10:56:04 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , CC: Subject: [PATCH -next v2 1/3] drm/rockchip: Use for_each_child_of_node_scoped() Date: Tue, 27 Aug 2024 11:03:55 +0800 Message-ID: <20240827030357.1006220-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827030357.1006220-1-ruanjinjie@huawei.com> References: <20240827030357.1006220-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemh500013.china.huawei.com (7.202.181.146) Content-Type: text/plain; charset="utf-8" Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan --- drivers/gpu/drm/rockchip/rockchip_lvds.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/roc= kchip/rockchip_lvds.c index 9a01aa450741..f5b3f18794dd 100644 --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c @@ -548,7 +548,7 @@ static int rockchip_lvds_bind(struct device *dev, struc= t device *master, struct drm_encoder *encoder; struct drm_connector *connector; struct device_node *remote =3D NULL; - struct device_node *port, *endpoint; + struct device_node *port; int ret =3D 0, child_count =3D 0; const char *name; u32 endpoint_id =3D 0; @@ -560,15 +560,13 @@ static int rockchip_lvds_bind(struct device *dev, str= uct device *master, "can't found port point, please init lvds panel port!\n"); return -EINVAL; } - for_each_child_of_node(port, endpoint) { + for_each_child_of_node_scoped(port, endpoint) { child_count++; of_property_read_u32(endpoint, "reg", &endpoint_id); ret =3D drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id, &lvds->panel, &lvds->bridge); - if (!ret) { - of_node_put(endpoint); + if (!ret) break; - } } if (!child_count) { DRM_DEV_ERROR(dev, "lvds port does not have any children\n"); --=20 2.34.1