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: 1977259 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=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3483-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (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 4WtQXX0271z1yXd for ; Tue, 27 Aug 2024 21:38:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 907B7B233C2 for ; Tue, 27 Aug 2024 11:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 114191A0732; Tue, 27 Aug 2024 11:38:18 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 49CAB1A01B4; Tue, 27 Aug 2024 11:38:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758697; cv=none; b=hy5oTXrS84jIxtnLkshxKj5fMYYlRg6HbGcenh4jiLiPIAJCU3wBJ1kQsHm1i3bR4rr3xFZiONPm/TwVajo7ktoU18FObvDkdXeyFRMPgP4qrF9ufePFwBExTbMh4xUCgn3Oij4pw+rW7r1z963sybaYfAslQiZYwz4YBbOqHTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758697; c=relaxed/simple; bh=E82EEo1RXaB/IvSNxJ2EOBRliN4y/HoIl73diV6vg7Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VCMu3gZqfQnse/vgAyn+ZqXTO4XMBuqVqh1gcXBt2tUqap9sC7uo/GVQWXPqJjBaNq+PMPM46ZHNKkjvHHoKNH8lWFn+bCrLMWkg9rkp87JWmMyprGPXljaU4RzOh8ftIzwrEONHgWcIm61oqadM7l75NFCm+CoC3RBmjl5JbNw= 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.190 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977260 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=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3484-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (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 4WtQXX4Qpfz1yXd for ; Tue, 27 Aug 2024 21:38:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5C726B23422 for ; Tue, 27 Aug 2024 11:38:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD1801A08CE; Tue, 27 Aug 2024 11:38:18 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 53A7C19DF82; Tue, 27 Aug 2024 11:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758698; cv=none; b=bPekWRpG4UNrSq94JOgQkF6+XC5M4PmKQcLBW+W3e5b1bOX48f1mI2/vgXz/UN8jz7Nn0+bz3qt0ik5TntxoErm71MxuXq3V3joXh/F8d7J2X9RzRYVJnKjdAQV0c0T3aPAVess3VjxV1MkLeVlfM1S+M5Sj/ynkxWjE+ydbqFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758698; c=relaxed/simple; bh=YfnrL1Siqgw0CQKyY622ppIkfkCAloYHq1Xj86/hUPY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tMWxhqhDc1R+2rOSoZdYBMQ6nBWggus4gKLAaGZ9oMXq2xEOulN/obO6pYrQ2Hf9FvuO2LSjXXbuE2PCvlsN/Z69ZnwFdO5lQbDlDgcFGne7qnJnNpHFgUaN1SSEWJDnTeWq9kQASuOY+oAPzDXO6BySQd/XEMuAfgCJ6s2fBQc= 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.35 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977261 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=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3485-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (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 4WtQXY1Hglz1yXd for ; Tue, 27 Aug 2024 21:38:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B25FB282DD3 for ; Tue, 27 Aug 2024 11:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D10EC1A0AE1; Tue, 27 Aug 2024 11:38:18 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 934191A01CB; Tue, 27 Aug 2024 11:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758698; cv=none; b=R8Ylgstd7oeMSELamooc0GyPQX1Y/MseFLaarVM5IWpO3fceOf4BB1ndz8S7R41OCZxntKD6tteLY1x9dTD5Ne2iwKmTFG2bU4q9clr69b3cMAnfvkJlN7KH3DFT9NVAGajtp49DEPDfebOcdCuw2pvvOZobVERtvj3DeVqloLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758698; c=relaxed/simple; bh=0OsIjZBiIDPwp42ZSvEs5x8nOcpXmg1GP8c8AxGaHiQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GDf3cYVL1Gr2EWO4zK1CBDzaTi1CWbm1slFTg9c+VON+BcqCaS91vzromXy7JDBu/ddN61mceoJapEK8Tagcy7vsGvNjPP7K9mybxPj7t72wrSJ6Y73EA0nJQR//MxvfPxolMDgsiXJqIaCHd/UdGMY6qyflQcOyvK70ohZ4PsM= 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.190 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977266 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=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3488-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (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 4WtQXd103wz1yXd for ; Tue, 27 Aug 2024 21:38:25 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AE0EB1F23DA1 for ; Tue, 27 Aug 2024 11:38:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A3FF1A00C9; Tue, 27 Aug 2024 11:38:20 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB631A08B9; Tue, 27 Aug 2024 11:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758700; cv=none; b=iWw20sp4pSnvEmLKlVCQCjD/UDWJuoiUI1BKrPfnn55fiTXiVODwgExJzN6zwHeyjwlOxHSUiBTPAMl++6hNGAN5QzWrtCUTO8ZlJqOh2VKRF63DI5kdfT3MMtW4O/WI9C/9KmuimJgb8VHQxPllxHRlmzgEeShPWthsqXvFMm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758700; c=relaxed/simple; bh=00ok9dQw9q2pYIzlqcHuRqe4lAgkdqOEzuqY0nZkYjY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XzxtxXnSnAz+q94GehFPsKN9MJHh6kO6dLhcYiTEpwWtiD0OtN2t65/daJL+fUhIbJXcVz3gKvj+EG6SyKCsOqfVs3ZGcHbgu3cmtt2fWlab8rbotcr8OdlP2Gk+o1zsRkk9XuouH9W/S8ayzSABuYPlHoeOVaH2McJXgF3j4ag= 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.189 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977262 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=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3486-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (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 4WtQXY5fNCz1yh3 for ; Tue, 27 Aug 2024 21:38:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 863B5B22CFB for ; Tue, 27 Aug 2024 11:38:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F7E41A0B15; Tue, 27 Aug 2024 11:38:19 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 69F4F1A0710; Tue, 27 Aug 2024 11:38:17 +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=1724758699; cv=none; b=Bghqw9dX11JPeC8IapD+S324Ysk1aMujPADU5oWDf5LpQLb3yY2J8pIqx8oezmAyWH6LKCZl8zt9+YUwJ5JL1D0JtabKfnP5GiDJeuOY83HQOE/1qgNwbD3XprwJG0/1941RLg8XfpbVbjmBN2tYWQ3FzioIi8w9o3xuSSoJ2rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758699; c=relaxed/simple; bh=51D4MVbrbie62zBZ4PBe0caLTe04rtIHKvrD3K2vD1g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bA170kwW48IYrbJITVndLhFJP23DpI+0gqaqdiD6916015cx+tV6VLJwUncxNe/YihjWOgqjQVvuLsaySISb49ZTP/8PxNP5MfovzidHxkwl4f+a4n5dbVSUw68khdUO1wX7X3Fk2bLKWYGgxRLEIpsHqOqQQgL1adEeWzIZ8wg= 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977263 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=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3487-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (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 4WtQXZ1mhKz1yXd for ; Tue, 27 Aug 2024 21:38:22 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 02D60B23271 for ; Tue, 27 Aug 2024 11:38:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 771831A2C0F; Tue, 27 Aug 2024 11:38:20 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E23D1A08BB; Tue, 27 Aug 2024 11:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758700; cv=none; b=V8eRFhPWMRvS64d/cIzAdvrDJxLRRAW6vmr4VUgcv+xbdhfAiUVy7rdLl4NJEY33o8/4uQl0hGX5LfBTA06UXeJjiq3g63O+xDu3X7gqgJsc7Cb2jiDD3vekywBN8qEoDSuwVh9cWXzldUNVFTZt0kkrkbWlv4DmcQ6Au78ZCNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758700; c=relaxed/simple; bh=AzNUIafzH+8sYR1mWnVz5793pPJ3NWiNtwEnj9Iyclo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iwzXSKROzisyucInWGaZftp91jEEni6yO0KqUg+v3C+BazHN8rEUk5t/eQCukNdJQY/yLZUt79meUWxWAOMgTVbz8RYA8yfpir/JzW1UxRPctyfAhT6teTG0OmNJrFs8kkFW/J1GcA0fMK6jsSj8S3m33cQOG2LrmJAK2pMin3w= 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.189 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977264 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=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3489-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (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 4WtQXb5MJFz1yXd for ; Tue, 27 Aug 2024 21:38:23 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6996EB234AD for ; Tue, 27 Aug 2024 11:38:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CCF11A38CF; Tue, 27 Aug 2024 11:38:21 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 27F211A0B06; Tue, 27 Aug 2024 11:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758701; cv=none; b=jKW3mr+nVm6p8+g9z8lPqWiej7RRQ3JlK4XdlQvXVS3RAj57ChU1SJ8o7s6iIFVUmJbT29oseQoNv5PXJP65BNsu0GPsMupJn/cI6mCPW9t7tf9+NmoWRTJd6B5fAbmNv8v8SgBr+MyQgHZDRC6L0oQJXZbViYNhn13jeaN3q+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758701; c=relaxed/simple; bh=6T2kzFjrqJ2pB9Lcw9tN+yUCT9Pmdj7Kk9oVwNRcnS8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b6rTEJJaJRzm6aHT/R3ILaDDlicFHRqAiFk1SCczWI2SgZzLad2mfw/m5TjCIHhDG8NWjmNQhWJc90rHTNstIy/gc5dLeErjJMUl1kQSgBVwTZbCdrGAOUPAp1bflIZGDmOG9zeECFmh9+5tCrbPdV67C/KISNrOc61v36KWhDg= 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.255 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 1977265 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=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-tegra+bounces-3490-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (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 4WtQXc1Tg5z1yXd for ; Tue, 27 Aug 2024 21:38:24 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CBB5B283519 for ; Tue, 27 Aug 2024 11:38:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFA081A38F3; Tue, 27 Aug 2024 11:38:21 +0000 (UTC) X-Original-To: linux-tegra@vger.kernel.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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D7661A2555; Tue, 27 Aug 2024 11:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758701; cv=none; b=AmBMyLdCuhGWan0bFBMEfkkDT46/Pq3coDIqI+sZlwS4Gjp4aUlJTlFjr83jOCIC3itMHdwgYMnq4AmpQ5eOyeNM9nEenL52SNIlyHagk4YeUUy34lr9hsbloznDxEwEIO6P7QTdPo1IYb2Gs8549jEQpOPgZbF0lXlHsGZErE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724758701; c=relaxed/simple; bh=1h1JbHSB4nat3IP75xhbkJxU9Sy9WszaXRLMmsy1xYM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gZXlfMG8/m5cY+OWVnjDoBvSBLMOyHo3OOVw4BqEHVhsomm/WLwqK1seuYuuxo4K6a2SVIvmadWgogonA39X/NJH0kH+LkQrKgQSWdIm7guliMqYXHozs50+lDs8B5KGLp9wg+yYaZz/w4O78w/lPDgMh9rxsIDISR+Gre8dB2M= 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.189 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.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> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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)) {