From patchwork Tue Aug 27 11:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977273 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-605-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQYQ4hzYz1yXd for ; Tue, 27 Aug 2024 21:39:06 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXc2M2Sz2yQG; Tue, 27 Aug 2024 21:38:24 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758704; cv=none; b=F+YUVtFekXihD5RSadeCBQ4EUMqxDt0Jc3E1cvVxnegaqY2a/APsyMtL/hu0a2mU0szaZGIToOdzIQwlCizfpDhBQx2urGDZSVkGLy9x9YaAf3FJ4eD5sIUsflYvcXhmFczWUFySe/q/zZt5RrDHDKpWZ6Q07dCunO8Gth4swcQRmOV5lfDlK6pkidSTSvC8UFMawi5zjKYx2O10rH19Hqw9n7kSQAXRxgQ8ULkF4eNXQjGutR2kcNnRn3alBY1XrkXz0kuvA8fOVqfaoHAy/H3ZjeGkkVqHpaKlobjL0qic/EspgWJOuaSjlmTl7QjHCLOh1NRz4M8gCgUWchhPpg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758704; c=relaxed/relaxed; bh=jkEOqyUxcBoPPL5BncIqsc96Qi8FOwtCEEq+nb0MFfA=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=oMdwn+CcmL907EcO+Aha+TS6C4Im5NA6uLA3DMs9zZHCNE1RNdJXQAezSN6NHgW4/5UGAk/ogKNRHNPncNF2soteCenK0XHypaAnVK+htuFakdKtTSPObkocwVoWl2sElpCZjGCt1NNPrUOBhZFPayC/dLaPIu2jFPrfB9GYO9odfWP2VfR7qGwFd7901zdKOFDNGdXsfQWsvvsoM38LOA0W8E21z83u7lx+Y5WBSg8H/h43o6FFlRggtIFtkmoRn65UscNGnYC+VrFwoerhgpPSnVVt6q9DGnLRHEqXdsEyV9mF3ANhWOr6tpThGqF933DBvGHXhkjiwHIeEEJ8+Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.190; helo=szxga04-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.190; helo=szxga04-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXb3T2Fz2yYJ for ; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtQQr3KRVz20mN6; Tue, 27 Aug 2024 19:33:24 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id B66FB180019; Tue, 27 Aug 2024 19:38:12 +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 19:38:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 1/8] soc: fsl: cpm1: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:00 +0800 Message-ID: <20240827114607.4019972-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_available_child_of_node_scoped when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/tsa.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c index 6c5741cf5e9d..7fa399b7a47c 100644 --- a/drivers/soc/fsl/qe/tsa.c +++ b/drivers/soc/fsl/qe/tsa.c @@ -441,7 +441,6 @@ static inline int tsa_of_parse_tdm_tx_route(struct tsa *tsa, static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) { - struct device_node *tdm_np; struct tsa_tdm *tdm; struct clk *clk; u32 tdm_id, val; @@ -452,11 +451,10 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) tsa->tdm[0].is_enable = false; tsa->tdm[1].is_enable = false; - for_each_available_child_of_node(np, tdm_np) { + for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); if (ret) { dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - of_node_put(tdm_np); return ret; } switch (tdm_id) { @@ -469,16 +467,14 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) default: dev_err(tsa->dev, "%pOF: Invalid tdm_id (%u)\n", tdm_np, tdm_id); - of_node_put(tdm_np); return -EINVAL; } } - for_each_available_child_of_node(np, tdm_np) { + for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); if (ret) { dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - of_node_put(tdm_np); return ret; } @@ -492,14 +488,12 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) dev_err(tsa->dev, "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", tdm_np); - of_node_put(tdm_np); return ret; } if (val > 3) { dev_err(tsa->dev, "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", tdm_np, val); - of_node_put(tdm_np); return -EINVAL; } tdm->simode_tdm |= TSA_SIMODE_TDM_RFSD(val); @@ -511,14 +505,12 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) dev_err(tsa->dev, "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", tdm_np); - of_node_put(tdm_np); return ret; } if (val > 3) { dev_err(tsa->dev, "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", tdm_np, val); - of_node_put(tdm_np); return -EINVAL; } tdm->simode_tdm |= TSA_SIMODE_TDM_TFSD(val); @@ -538,13 +530,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1rsync"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1rsync_clk = clk; @@ -552,13 +542,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1rclk"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1rclk_clk = clk; @@ -567,13 +555,11 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1tsync"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1tsync_clk = clk; @@ -581,29 +567,23 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) clk = of_clk_get_by_name(tdm_np, "l1tclk"); if (IS_ERR(clk)) { ret = PTR_ERR(clk); - of_node_put(tdm_np); goto err; } ret = clk_prepare_enable(clk); if (ret) { clk_put(clk); - of_node_put(tdm_np); goto err; } tdm->l1tclk_clk = clk; } ret = tsa_of_parse_tdm_rx_route(tsa, tdm_np, tsa->tdms, tdm_id); - if (ret) { - of_node_put(tdm_np); + if (ret) goto err; - } ret = tsa_of_parse_tdm_tx_route(tsa, tdm_np, tsa->tdms, tdm_id); - if (ret) { - of_node_put(tdm_np); + if (ret) goto err; - } tdm->is_enable = true; } From patchwork Tue Aug 27 11:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977271 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-603-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQY23dgMz1yXd for ; Tue, 27 Aug 2024 21:38:46 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXb4yWbz2yYq; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; cv=none; b=h9Czw1rRAYUQF7F77HJrpQxdWEu9K1HI2JiBbY4kBl6zkNYWFyb95jP2HGpBMOKBb1lW8t+RS0J817ek+imNr5su+QO1fT6q3D4ahrKwGkptt1jC//zJONiOFdIvsgZdcKG5TEvRriVYBTO85dLOBKheMUPo9c3hjN+AU7KkckLrtT9sYWKvhmZF02ix+cJOT8jRDutxUE7iMbwEpkDUcnpznJA+KgIkKo6ZYgYJWRVZjMsZEHAoTFGz43XQGEngnMM8h1slmB+ausbUTrp6vtZgbS/nvxgU8p9iw/XRJcY0RlRWZNMNpSEdJJ2R5icXjaaDxp05Avl+MXiFgQsuSw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; c=relaxed/relaxed; bh=kvhSsusYdwfy/ugnFE7LONSgtEPXGqWCQprP7oySnDk=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=cZmOkd6m3tdp3Mk/gy+6OEY4Xc/+eJlVfrCx8ckWbkOZE+n+sq1pv1bEczE0K/BtZNOxnzQxU66hO2A9YYEvtDn6yr8e4Q1ztO0mn2/5vbkTfAhX10wxZ8+OTLVLBJ8EUP+d2pBEgjtEBddg4TlbL4pIr5Az+NdEmdCff0rfn2oBPdIxkTfPVABF904QH21RupHZMp/CFSI9UL00cfiWevMeRnwr5UWDYa8n7IQW+GdWHZYKEsF7SiJQXzF3Qu32CScTE6UvUDtbxSJczGvuoXHLKH4hS19SSg6oG3TjHz338LoBk+EJ4wLxVWMo6/cmZHzDqLS2Hp6OMjYHBEGuOg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.35; helo=szxga07-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.35; helo=szxga07-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXZ4D7Yz2yTy for ; Tue, 27 Aug 2024 21:38:22 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WtQXB5Y2sz1S8sD; Tue, 27 Aug 2024 19:38:02 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 69D4C1A0188; Tue, 27 Aug 2024 19:38:13 +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 19:38:12 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 2/8] soc: fsl: cpm1: Simplify with dev_err_probe() Date: Tue, 27 Aug 2024 19:46:01 +0800 Message-ID: <20240827114607.4019972-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/tsa.c | 62 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c index 7fa399b7a47c..fc37d23b746d 100644 --- a/drivers/soc/fsl/qe/tsa.c +++ b/drivers/soc/fsl/qe/tsa.c @@ -453,10 +453,8 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); - if (ret) { - dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - return ret; - } + if (ret) + return dev_err_probe(tsa->dev, ret, "%pOF: failed to read reg\n", tdm_np); switch (tdm_id) { case 0: tsa->tdms |= BIT(TSA_TDMA); @@ -465,18 +463,15 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) tsa->tdms |= BIT(TSA_TDMB); break; default: - dev_err(tsa->dev, "%pOF: Invalid tdm_id (%u)\n", tdm_np, - tdm_id); - return -EINVAL; + return dev_err_probe(tsa->dev, -EINVAL, "%pOF: Invalid tdm_id (%u)\n", + tdm_np, tdm_id); } } for_each_available_child_of_node_scoped(np, tdm_np) { ret = of_property_read_u32(tdm_np, "reg", &tdm_id); - if (ret) { - dev_err(tsa->dev, "%pOF: failed to read reg\n", tdm_np); - return ret; - } + if (ret) + return dev_err_probe(tsa->dev, ret, "%pOF: failed to read reg\n", tdm_np); tdm = &tsa->tdm[tdm_id]; tdm->simode_tdm = TSA_SIMODE_TDM_SDM_NORM; @@ -484,35 +479,26 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) val = 0; ret = of_property_read_u32(tdm_np, "fsl,rx-frame-sync-delay-bits", &val); - if (ret && ret != -EINVAL) { - dev_err(tsa->dev, - "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", - tdm_np); - return ret; - } - if (val > 3) { - dev_err(tsa->dev, - "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", - tdm_np, val); - return -EINVAL; - } + if (ret && ret != -EINVAL) + return dev_err_probe(tsa->dev, ret, + "%pOF: failed to read fsl,rx-frame-sync-delay-bits\n", + tdm_np); + if (val > 3) + return dev_err_probe(tsa->dev, -EINVAL, + "%pOF: Invalid fsl,rx-frame-sync-delay-bits (%u)\n", + tdm_np, val); tdm->simode_tdm |= TSA_SIMODE_TDM_RFSD(val); val = 0; ret = of_property_read_u32(tdm_np, "fsl,tx-frame-sync-delay-bits", &val); - if (ret && ret != -EINVAL) { - dev_err(tsa->dev, - "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", - tdm_np); - return ret; - } - if (val > 3) { - dev_err(tsa->dev, - "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", - tdm_np, val); - return -EINVAL; - } + if (ret && ret != -EINVAL) + return dev_err_probe(tsa->dev, ret, + "%pOF: failed to read fsl,tx-frame-sync-delay-bits\n", tdm_np); + if (val > 3) + return dev_err_probe(tsa->dev, -EINVAL, + "%pOF: Invalid fsl,tx-frame-sync-delay-bits (%u)\n", + tdm_np, val); tdm->simode_tdm |= TSA_SIMODE_TDM_TFSD(val); if (of_property_read_bool(tdm_np, "fsl,common-rxtx-pins")) @@ -645,10 +631,8 @@ static int tsa_probe(struct platform_device *pdev) return PTR_ERR(tsa->si_regs); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "si_ram"); - if (!res) { - dev_err(tsa->dev, "si_ram resource missing\n"); - return -EINVAL; - } + if (!res) + return dev_err_probe(tsa->dev, -EINVAL, "si_ram resource missing\n"); tsa->si_ram_sz = resource_size(res); tsa->si_ram = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(tsa->si_ram)) From patchwork Tue Aug 27 11:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977268 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-600-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQXg4rLKz1yXd for ; Tue, 27 Aug 2024 21:38:27 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXb0Qtbz2yVZ; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; cv=none; b=iddCKy0awih6ZQymocJ4V0smPBk5+7VD9cBZqDgbX8HGbl4ECxC7rrokbr2mk0Bn+fXgVGJVqoR7UWTrChmwnykCJKlpEaPh2ywJP3b8k7ziDJuqlxZAF4QzFLjTWJ7YhQkr4yT6hqL1Yp1YCYWQ8FT/ECz0BrrpHlrGgrREX7r6zv2hwAJ9Mag5UEyDud84u9YsDyJy8vIRHS5SR/t0VX0GFypTzsQnlRJkAURtXNRFRc7EuD5kCkSbaxdAl6gHwn9hBNdLgAySnyLjuO4N2r8SzjBmp7PRonBt77YWIMRAI8iNr0wkw7q665ukEpX6IGZ1wtdnvFA8gt0iKCDDlg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; c=relaxed/relaxed; bh=4X6/RxMpsbE97p+Qhg9yQOSsLMtRv4l/pqbipQn/Ulk=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=dZVrFV4pncIDKzt9SIRhPYAgiG9Mlypk+0MGT0+qYuUDk2RLbTebhVKadYClsjroWJdCHj9i6Cjb50ti4jjLk2SxqB4KHdudd8ZulPg3F1jHe8tgMZL2yQ1RrrVKFAT2y+S1nW7Rjqwse0zwBFxa3JC80IvAhwCRgjg8JTbVOTCNBfIGecPg4Px8LmIzDyVq5aPY6gOjfwb1irBmcnm41kOFjK4CWY112k3m9uOmz4YmPbIuh+ji+qKDC4HOr8qjVkiR38PGPXOhri1I8DwZslel8O3SNtDIw481GsvlubvMNHa8BynYnI+p4F9Pdysh+NEVqDuHL0a2lYXxSwFPQw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.190; helo=szxga04-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.190; helo=szxga04-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXZ1Wmsz2yQL for ; Tue, 27 Aug 2024 21:38:19 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtQXD0CCYz2Cnkc; Tue, 27 Aug 2024 19:38:04 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 16C9A180019; Tue, 27 Aug 2024 19:38:14 +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 19:38:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 3/8] soc: fsl: cpm1: qmc: Simplify with scoped for each OF child Date: Tue, 27 Aug 2024 19:46:02 +0800 Message-ID: <20240827114607.4019972-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/qmc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index 76bb496305a0..d5937b5b5f15 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -1174,31 +1174,26 @@ static unsigned int qmc_nb_chans(struct qmc *qmc) static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) { - struct device_node *chan_np; struct qmc_chan *chan; const char *mode; u32 chan_id; u64 ts_mask; int ret; - for_each_available_child_of_node(np, chan_np) { + for_each_available_child_of_node_scoped(np, chan_np) { ret = of_property_read_u32(chan_np, "reg", &chan_id); if (ret) { dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np); - of_node_put(chan_np); return ret; } if (chan_id > 63) { dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np); - of_node_put(chan_np); return -EINVAL; } chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL); - if (!chan) { - of_node_put(chan_np); + if (!chan) return -ENOMEM; - } chan->id = chan_id; spin_lock_init(&chan->ts_lock); @@ -1209,7 +1204,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret) { dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n", chan_np); - of_node_put(chan_np); return ret; } chan->tx_ts_mask_avail = ts_mask; @@ -1219,7 +1213,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret) { dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n", chan_np); - of_node_put(chan_np); return ret; } chan->rx_ts_mask_avail = ts_mask; @@ -1230,7 +1223,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) if (ret && ret != -EINVAL) { dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n", chan_np); - of_node_put(chan_np); return ret; } if (!strcmp(mode, "transparent")) { @@ -1240,7 +1232,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) } else { dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n", chan_np, mode); - of_node_put(chan_np); return -EINVAL; } From patchwork Tue Aug 27 11:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977272 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-604-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQYD549Bz1yXd for ; Tue, 27 Aug 2024 21:38:56 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXb5KP7z2yZ0; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; cv=none; b=VvkBJcvn47zOrT6IbUVM155gTRfYq12+d3C5tg8eqtzuVE29VHRy8DlH2JJcaq297q5XMjFBkFNjKlpBpjVNK5jxqZKANBCfkhF9H1f0YpTq829Flkvm+ot2s2yG/IMRisp2DMsf14D0UlpXx+b/DfozB3650mZhY7Gy+9wK+F40hJ60MNb24DJ3vtTRpFq8bhDW6ZF42ouBcOKvi7+EudQikGV+HcgW3nrZKEXPJTQ4dITnyQ1G9y8QqoVRqDI1VKkV9M18bjVs2vTqnMIlMzyVOFTSGMRjEeJBVZZZSl6jPpjZUVfeDdKZU7o+GzIjcp1ztfDfdvxcNunvAzQGEQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; c=relaxed/relaxed; bh=B9a4Nu39qZmPOTpSWwgCGmcdd//9iD0eebXMV4pjG1I=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=RRut5uo04OX/MILO5sYBuumOOjwtheSxYlrYwJYGfRJXwSo7ag5C4333bStdkoTX9i592oEJSxPUHPgg4E3viHXB2CSQhF/DGhHLuOT5qXWgAvMQP2AeHJGcF3TR8kesjmZ1A2XpZFSC+VUMu2V1giPXy7nVXpTSLXhKR4s8qTKuwNBGpZoL2JR1R9JNj5M4o0Ign7YeoCC23eowAbCRK4R50kbD/DQe8+diFg8aq8g6tKYDptkDzliow8bG5JUggKldz3BjvBbN9gC8EyCmya3/+beckmedWZ0KMag9gRuT9z+Eb6GlS+qoF+965yolRoJGXiS8EuYb7IbC/Z3v2A== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXY700Kz2yLT for ; Tue, 27 Aug 2024 21:38:19 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQt453RzQqgb; Tue, 27 Aug 2024 19:33:26 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 41C0D140202; Tue, 27 Aug 2024 19:38:15 +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 19:38:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 4/8] soc: fsl: cpm1: qmc: Simplify with dev_err_probe() Date: Tue, 27 Aug 2024 19:46:03 +0800 Message-ID: <20240827114607.4019972-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/fsl/qe/qmc.c | 53 ++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index d5937b5b5f15..4315af115b8e 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -1182,14 +1182,10 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) for_each_available_child_of_node_scoped(np, chan_np) { ret = of_property_read_u32(chan_np, "reg", &chan_id); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np); - return ret; - } - if (chan_id > 63) { - dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np); - return -EINVAL; - } + if (ret) + return dev_err_probe(qmc->dev, ret, "%pOF: failed to read reg\n", chan_np); + if (chan_id > 63) + return dev_err_probe(qmc->dev, -EINVAL, "%pOF: Invalid chan_id\n", chan_np); chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL); if (!chan) @@ -1201,39 +1197,34 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) spin_lock_init(&chan->tx_lock); ret = of_property_read_u64(chan_np, "fsl,tx-ts-mask", &ts_mask); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n", - chan_np); - return ret; - } + if (ret) + return dev_err_probe(qmc->dev, ret, + "%pOF: failed to read fsl,tx-ts-mask\n", + chan_np); chan->tx_ts_mask_avail = ts_mask; chan->tx_ts_mask = chan->tx_ts_mask_avail; ret = of_property_read_u64(chan_np, "fsl,rx-ts-mask", &ts_mask); - if (ret) { - dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n", - chan_np); - return ret; - } + if (ret) + dev_err_probe(qmc->dev, ret, "%pOF: failed to read fsl,rx-ts-mask\n", + chan_np); chan->rx_ts_mask_avail = ts_mask; chan->rx_ts_mask = chan->rx_ts_mask_avail; mode = "transparent"; ret = of_property_read_string(chan_np, "fsl,operational-mode", &mode); - if (ret && ret != -EINVAL) { - dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n", - chan_np); - return ret; - } + if (ret && ret != -EINVAL) + return dev_err_probe(qmc->dev, ret, + "%pOF: failed to read fsl,operational-mode\n", + chan_np); if (!strcmp(mode, "transparent")) { chan->mode = QMC_TRANSPARENT; } else if (!strcmp(mode, "hdlc")) { chan->mode = QMC_HDLC; - } else { - dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n", - chan_np, mode); - return -EINVAL; - } + } else + return dev_err_probe(qmc->dev, -EINVAL, + "%pOF: Invalid fsl,operational-mode (%s)\n", + chan_np, mode); chan->is_reverse_data = of_property_read_bool(chan_np, "fsl,reverse-data"); @@ -1590,10 +1581,8 @@ static int qmc_probe(struct platform_device *pdev) /* Connect the serial (SCC) to TSA */ ret = tsa_serial_connect(qmc->tsa_serial); - if (ret) { - dev_err(qmc->dev, "Failed to connect TSA serial\n"); - return ret; - } + if (ret) + return dev_err_probe(qmc->dev, ret, "Failed to connect TSA serial\n"); /* Parse channels informationss */ ret = qmc_of_parse_chans(qmc, np); From patchwork Tue Aug 27 11:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977275 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-607-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQYl5NRdz1yXd for ; Tue, 27 Aug 2024 21:39:23 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQY771Gsz2yk8; Tue, 27 Aug 2024 21:38:51 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758731; cv=none; b=TNA/n6HmCCTzSRqiImKzPq6waCsoh6fxY8f2eai3DRngQCV4JPohRTbcH5v1M2Eu21rTxdhF0WcIOT+35YmMxNNprOaUfKFIgKH0ZXpiItjBA4dJUZ1dOwMSc+uA2hQ35Yz1cmIzDJfb4p0+tHi+4M3YokTW/qysaH9zK6UFVx9GnL3VJqRxPZOS/EOVBDrwkvQG8Ru1I+JsmLEZDGDU+kkDhJujrfruIuPHxU3R6Nc6MqeSEPWWCucWcevwlEyd6PpeHvPa8oqtLKnnqUd/hPvgsm/+ntwDwElc+LLepSoM0WDHuONVVImVClxdkH5XxU8DuNhrrcqNoJ7FHSexUg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758731; c=relaxed/relaxed; bh=Bh5x8cN6b49le4kLR1yloaUU6CqIls1aVKtyGmnM5Q8=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=AxTnKvu4HzlIKNPHx8cElrPoSV/Xp2/oGZd3DxEtrKaF0zUyNHo4H6FokGLUZWZtbOhAJHJI4ZdvoZw3Kv6GFGnlIZ/pZF/yHoxUsd8cloBV6RfMxvS9fyU4GvbtsLDNyN8QeD7KmIKo9LYUhcSq6jR/4naWbCcS1E3e5N9dPtSy8krODLMcl+vnS/JGJvwrl1X1XlShEaJNhyMLLiUhZRAorxKXlZY5qLUxNJ6z0PpnY7gH0XkR2D1lXTLxCMKg/BW8KOg2fgiLScSJHcJ0xbVhK5Hdx/St0lMP72G6VfkbIwPmD+LcJC6ruAHwVMRYffWW4+V3QMWr8IuiMMFanQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.187; helo=szxga01-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.187; helo=szxga01-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) 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 lists.ozlabs.org (Postfix) with ESMTPS id 4WtQY73zwMz2yYJ for ; Tue, 27 Aug 2024 21:38:51 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WtQWX139WzyQZW; Tue, 27 Aug 2024 19:37:28 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 51D4B1402DE; Tue, 27 Aug 2024 19:38:15 +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 19:38:14 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 5/8] soc/tegra: pmc: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:04 +0800 Message-ID: <20240827114607.4019972-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/tegra/pmc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 6c37d6eb8b49..a08c377933c5 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -1438,7 +1438,7 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, struct device_node *parent) { struct of_phandle_args child_args, parent_args; - struct device_node *np, *child; + struct device_node *np; int err = 0; /* @@ -1457,12 +1457,10 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, if (!np) return 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { err = tegra_powergate_add(pmc, child); - if (err < 0) { - of_node_put(child); + if (err < 0) break; - } if (of_parse_phandle_with_args(child, "power-domains", "#power-domain-cells", @@ -1474,10 +1472,8 @@ static int tegra_powergate_init(struct tegra_pmc *pmc, err = of_genpd_add_subdomain(&parent_args, &child_args); of_node_put(parent_args.np); - if (err) { - of_node_put(child); + if (err) break; - } } of_node_put(np); From patchwork Tue Aug 27 11:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977270 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-602-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQXy5j34z1yXd for ; Tue, 27 Aug 2024 21:38:42 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXb3jQmz2yYY; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; cv=none; b=MpXk7Q9BXtsbQ689CutjjQmsvR0RjT5M/kr/3SVRJECJ+qv+Zjo3oxbpsJppLg2jl8tdWuoQlINSk1Tp+iL1LX3MC56R61wb3w1szePYZeqlNFdNTfu3jcli3Cy28X7RJ6djcphljenEbL+F8LW+pwo/1EMLww8MVKb9YZxeCPKzPNNwhtQPLWpwgrrxsuE6vC43rmjrwpZLV/1YB1Ukn3yY1t1052j2Iz4YFH56V/SwCInhxr0UunNQn24naVD8CLDr/p0dpFvRlJPVD4bOtmWZLVGc3UUCAWnofIoB+bcMtErxchK8K2smOaBGAjLs9UjJFGqxOJIdi1cBIEO57w== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; c=relaxed/relaxed; bh=1fCgKQIkz/+gi9fV1OrbsnV3X9mQtRzZv7rrrwMCDd8=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=ckltt0+xfXAMlm1QYQVv8MYry33cXTe8ZS8hv9D2yEJ9d4MmRP5Yh6vxmbHs0vCxqbk4DbXX08Gv/UG165SHy+h/2InOdS5Qd7ZUl5kf2sJFvrVgyNIhqBcssMW7gHA3gOeidXMKvGhet86mR507RGh4h/iunnQO+cbJf56y+biNiZ4FkI5qE8fxgB3HS0N2x35c4npqBwgqweJpbT9TCWfeWpnspAVHfKcn5stK5hdzTVFMbVYUAeG9v4MBZy9/ebFLFQbJaeZX2gPE2374pru88UG6hemWR68E8ih9F43qPpNE9YLN7F3xrvsuZWqaIvFkqpkZDgBCe/Qn2jicpA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXZ0dM4z2yQG for ; Tue, 27 Aug 2024 21:38:22 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQv39T5zQqgc; Tue, 27 Aug 2024 19:33:27 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 26A9B18010B; Tue, 27 Aug 2024 19:38:16 +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 19:38:15 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 6/8] soc: dove: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:05 +0800 Message-ID: <20240827114607.4019972-7-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan --- drivers/soc/dove/pmu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c index 6202dbcd20a8..75f5fc3cb2c6 100644 --- a/drivers/soc/dove/pmu.c +++ b/drivers/soc/dove/pmu.c @@ -372,7 +372,7 @@ int __init dove_init_pmu_legacy(const struct dove_pmu_initdata *initdata) */ int __init dove_init_pmu(void) { - struct device_node *np_pmu, *domains_node, *np; + struct device_node *np_pmu, *domains_node; struct pmu_data *pmu; int ret, parent_irq; @@ -405,21 +405,18 @@ int __init dove_init_pmu(void) pmu_reset_init(pmu); - for_each_available_child_of_node(domains_node, np) { + for_each_available_child_of_node_scoped(domains_node, np) { struct of_phandle_args args; struct pmu_domain *domain; domain = kzalloc(sizeof(*domain), GFP_KERNEL); - if (!domain) { - of_node_put(np); + if (!domain) break; - } domain->pmu = pmu; domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np); if (!domain->base.name) { kfree(domain); - of_node_put(np); break; } From patchwork Tue Aug 27 11:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977267 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-599-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQXf0qkLz1yh3 for ; Tue, 27 Aug 2024 21:38:25 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXZ6QlGz2yVD; Tue, 27 Aug 2024 21:38:22 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758702; cv=none; b=R1ordicBDWRaE3GVGORwQ1wcDl/7lFCePtL0wAQskrjTCggUAvO1rV5kvRkefEIDbheLud4eWLcuGWKDecgEH8gWJJTehdkY0RLWaxJ7dVgpmzLAVkPIk8WB3kgfp5+/FtT0HA+HexabNek1F5+iGYgBbnYx2sWnwUxyqzss3bgnTIIV8m1WlRrrp4TGfvJ+B/dS76FePvO+6iiT3uIBTmAqpmuaOYnucTXVkMpZ+6M7qCUJ9UGBt6xnzGL9JD6n2o90leT5IpfUao1muQ89ma5szZdNwaJC0+7k13YhB7YlekQAV9tYWTKkZ9A1207qFS/6ygwbfn5dYgm5adlAUQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758702; c=relaxed/relaxed; bh=3yiIX9LDkrPDh7GRPqepNE1yKgPXfYii7nzLUNDEKOo=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=YcOa4I1MI/c6RuwKa630JT95ItSGzbioHwa/6/GzQMz/VnQxnRVOHZz3853e7AO1RX+BdyD4Xryvih/9I/TvgG7WpoObCSP/XiTireW74uU5DoxbKm5+L+hBXxoFHCQKR54duJa406mRq5TtjIOBy999Ms9w37vwXvgGmx+YyhE9Ib/H1VZs0FV3iHUqeD9t/8Jm89qKGpBdEZQ5GZFmOHHTFf+JiUrXS4vsnPG0ngtO1qRmMhJP7qRm3w6Xh22yEmJ7ah4w0LijfIiZPULuYQgqJbgCdqY6xSJNbo+a6AiHwLsbs0BjLs2hMErwnfeag5UN/Y3YA7QZzKsUqGnZ5Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.255; helo=szxga08-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.255; helo=szxga08-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXY71v4z2yLY for ; Tue, 27 Aug 2024 21:38:21 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WtQWY6Vpgz14GKW; Tue, 27 Aug 2024 19:37:29 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id C5510140202; Tue, 27 Aug 2024 19:38:16 +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 19:38:15 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 7/8] soc: ti: knav_dma: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:06 +0800 Message-ID: <20240827114607.4019972-8-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. And use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/ti/knav_dma.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c index fb0746d8caad..eeec422a46f0 100644 --- a/drivers/soc/ti/knav_dma.c +++ b/drivers/soc/ti/knav_dma.c @@ -706,20 +706,15 @@ static int knav_dma_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; - struct device_node *child; int ret = 0; - if (!node) { - dev_err(&pdev->dev, "could not find device info\n"); - return -EINVAL; - } + if (!node) + return dev_err_probe(&pdev->dev, -EINVAL, "could not find device info\n"); kdev = devm_kzalloc(dev, sizeof(struct knav_dma_pool_device), GFP_KERNEL); - if (!kdev) { - dev_err(dev, "could not allocate driver mem\n"); - return -ENOMEM; - } + if (!kdev) + return dev_err_probe(dev, -ENOMEM, "could not allocate driver mem\n"); kdev->dev = dev; INIT_LIST_HEAD(&kdev->list); @@ -732,10 +727,9 @@ static int knav_dma_probe(struct platform_device *pdev) } /* Initialise all packet dmas */ - for_each_child_of_node(node, child) { + for_each_child_of_node_scoped(node, child) { ret = dma_init(node, child); if (ret) { - of_node_put(child); dev_err(&pdev->dev, "init failed with %d\n", ret); break; } From patchwork Tue Aug 27 11:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 1977269 X-Patchwork-Delegate: christophe.leroy@c-s.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-601-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtQXl2vkLz1yXd for ; Tue, 27 Aug 2024 21:38:31 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WtQXb1YtDz2yWy; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; cv=none; b=lFL3OC/7pE4IPktkXQF5q7fFSGk9BkCAEb2pRlgX+lX1h+TCM/W2j5Px0bJxOEl54PW+YgRjyKYc/Q0TVxOv4xXxyChU8tdNKiNODsqzMoKJPRLaO4HXCvhdBk2dscL2trMtf+5ZS+dScgi5XjMzQEYenIZTZFV1KqMsQne1vLktDm4WkB6YVlxeL1m/Z38U0bDZENjsvI/9pD4/T+pTRvnjsUkpYJi8oCgpFKodd8kpIyhZ4rvK303T+Pom9oxdUarioJ2ZmJ4j1BY5lAxxL1EfmdTSQRO2PTHmSbfA123+ja+30N6L0OFdtzlU8UD39VX/+0cBO3GGJSx923gakA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724758703; c=relaxed/relaxed; bh=VZGxZGVFQf1lRfodKCfNYUIb199fuQqzsvjfLECwEQE=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=n1ErDO5R8o2LGIOZhIZmqZgEywih3PokKffyfxLORX1IoWaK80mtNsyDDddXk8qVBWrNFRo4Zu9EZ5SSbtqtLp3vRcCVmLnEamZ0BXEVVS7fx8Rxz3FsyA2+UcjMOPgr0xxIqte7sOLWSQz8tpby6DkMP6TRz9pvnxkB6kJYxmz9TWsUrn4uCDkoSPt5qJa2fk11rEf6222SXVXh+CZBBVcl4LGbWYqnc+nqXmUqvWO6TB9HnyenQdjlSiNH7lcMeN5j+yMgq9FTwJP89+DnKXdQ8CwCoYNWAsBGd1yRDeQoeJ7lfdRV7creRKI2pfqWnfCYX/KafJrB5Lo/Qb/PvA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=45.249.212.189; helo=szxga03-in.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WtQXZ02vNz2yPq for ; Tue, 27 Aug 2024 21:38:21 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WtQQw5RZxzQqtk; Tue, 27 Aug 2024 19:33:28 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 7504F18007C; Tue, 27 Aug 2024 19:38:17 +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 19:38:16 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 8/8] soc: ti: knav_qmss_queue: Simplify with scoped for each OF child loop Date: Tue, 27 Aug 2024 19:46:07 +0800 Message-ID: <20240827114607.4019972-9-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240827114607.4019972-1-ruanjinjie@huawei.com> References: <20240827114607.4019972-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemh500013.china.huawei.com (7.202.181.146) Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. And use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when EDEFER is returned and useless error is printed. Signed-off-by: Jinjie Ruan --- drivers/soc/ti/knav_qmss_queue.c | 57 ++++++++++---------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index a15eaa1900ab..5126863ed647 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -1080,17 +1080,13 @@ static int knav_queue_setup_regions(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_region *region; - struct device_node *child; u32 temp[2]; int ret; - for_each_child_of_node(regions, child) { + for_each_child_of_node_scoped(regions, child) { region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL); - if (!region) { - of_node_put(child); - dev_err(dev, "out of memory allocating region\n"); - return -ENOMEM; - } + if (!region) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating region\n"); region->name = knav_queue_find_name(child); of_property_read_u32(child, "id", ®ion->id); @@ -1116,10 +1112,8 @@ static int knav_queue_setup_regions(struct knav_device *kdev, INIT_LIST_HEAD(®ion->pools); list_add_tail(®ion->list, &kdev->regions); } - if (list_empty(&kdev->regions)) { - dev_err(dev, "no valid region information found\n"); - return -ENODEV; - } + if (list_empty(&kdev->regions)) + return dev_err_probe(dev, -ENODEV, "no valid region information found\n"); /* Next, we run through the regions and set things up */ for_each_region(kdev, region) @@ -1313,10 +1307,8 @@ static int knav_setup_queue_pools(struct knav_device *kdev, } /* ... and barf if they all failed! */ - if (list_empty(&kdev->queue_ranges)) { - dev_err(kdev->dev, "no valid queue range found\n"); - return -ENODEV; - } + if (list_empty(&kdev->queue_ranges)) + return dev_err_probe(kdev->dev, -ENODEV, "no valid queue range found\n"); return 0; } @@ -1388,17 +1380,13 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_qmgr_info *qmgr; - struct device_node *child; u32 temp[2]; int ret; - for_each_child_of_node(qmgrs, child) { + for_each_child_of_node_scoped(qmgrs, child) { qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL); - if (!qmgr) { - of_node_put(child); - dev_err(dev, "out of memory allocating qmgr\n"); - return -ENOMEM; - } + if (!qmgr) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating qmgr\n"); ret = of_property_read_u32_array(child, "managed-queues", temp, 2); @@ -1490,15 +1478,11 @@ static int knav_queue_init_pdsps(struct knav_device *kdev, { struct device *dev = kdev->dev; struct knav_pdsp_info *pdsp; - struct device_node *child; - for_each_child_of_node(pdsps, child) { + for_each_child_of_node_scoped(pdsps, child) { pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL); - if (!pdsp) { - of_node_put(child); - dev_err(dev, "out of memory allocating pdsp\n"); - return -ENOMEM; - } + if (!pdsp) + return dev_err_probe(dev, -ENOMEM, "out of memory allocating pdsp\n"); pdsp->name = knav_queue_find_name(child); pdsp->iram = knav_queue_map_reg(kdev, child, @@ -1755,16 +1739,12 @@ static int knav_queue_probe(struct platform_device *pdev) u32 temp[2]; int ret; - if (!node) { - dev_err(dev, "device tree info unavailable\n"); - return -ENODEV; - } + if (!node) + return dev_err_probe(dev, -ENODEV, "device tree info unavailable\n"); kdev = devm_kzalloc(dev, sizeof(struct knav_device), GFP_KERNEL); - if (!kdev) { - dev_err(dev, "memory allocation failed\n"); - return -ENOMEM; - } + if (!kdev) + return dev_err_probe(dev, -ENOMEM, "memory allocation failed\n"); if (device_get_match_data(dev)) kdev->version = QMSS_66AK2G; @@ -1781,8 +1761,7 @@ static int knav_queue_probe(struct platform_device *pdev) ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { pm_runtime_disable(&pdev->dev); - dev_err(dev, "Failed to enable QMSS\n"); - return ret; + return dev_err_probe(dev, ret, "Failed to enable QMSS\n"); } if (of_property_read_u32_array(node, "queue-range", temp, 2)) {