Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp768487rdb; Sun, 28 Jan 2024 08:07:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGynomA5Ozt1XjlSM7wSxr99bU+JfGNASiNBbXTKYmPgtkgCP4kSi0PzLAV1+SiPtJ81Buo X-Received: by 2002:a05:620a:1998:b0:783:e74f:66e5 with SMTP id bm24-20020a05620a199800b00783e74f66e5mr4107011qkb.30.1706458045823; Sun, 28 Jan 2024 08:07:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706458045; cv=pass; d=google.com; s=arc-20160816; b=suGoUTIvg+MMyUR9li1pXWbZpKnc8n/XkwlK3IKAfcfraao8Gffp3o8ZjdGWix0B90 35vfshAmVdbiqKy5JfXIKhbCuZKpyewoZPfCjQMhEk8eqvJPvym3f/tQgYM5BNYyoP/L OCaQrWTPhRkOKwzwJuVVRaZq9wonzn9o0I1IrNlFt2bTF4vBdfQQ6dZsVg/AOXbXzUbF qmU5PKJPwhPMnp++A4Xx6kFlNDjgALZd3Z90MBYXA+Lt6r26kD5Bt46hB1iMa/CHvSw9 u+mX3wvenG35te+kR7HuXucNaqS+oTDrJZmTmDkl+Pj6K0HRg6xiPTkeclXIOl/4ht6Q 8rXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kjqy2pCflIm0S8IGtDul0MA0Ia7I+RjJ1rdQiVPX/E0=; fh=QZniyVMMS+qc7OJnE11H0+VIi5BgZHbLL5e39gUA1jg=; b=yDbQS469fbeGN0WJ9NwytuINLGUkmCT1XwzNp1sWVUeWxzhEjSJniuJp5JwowSpDsa +D7xJ3t4iS+vPfJwWFHzMeS1hy2TrwVvdL6cY6AuPSK4lIp273ITZxr/7Te2S7QHLXpp DHv4WkqG6lII+UlWQ1q3rSgo0Crelw1PypqKuXvp4mnoVIyYHg2IfMHxoqc6W9TVa12P dGZqJJCvFG243jR2vkJb5s7kTvink+iF3zEoEFI10RGzrrJ9sFJSFihBSWKyARdt4oII hoMSksLd+NgLTAHFxHB7NnKpY0XfRJCdNANWbVXLxFhCKdzO0vUuadtgPHDSKo2db2gn Nb4g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GoKDwMYn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41680-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q28-20020a05620a039c00b007833a463479si5577812qkm.479.2024.01.28.08.07.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:07:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GoKDwMYn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41680-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 93A7B1C2185E for ; Sun, 28 Jan 2024 16:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AADD28DD7; Sun, 28 Jan 2024 16:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GoKDwMYn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9EA473309E; Sun, 28 Jan 2024 16:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706457980; cv=none; b=AAkQVW+YHTF/0zMMX71ZlH0FPEvJD3JXxePoFHVENFtEEW/sHiSTnJsUK9pdzv/RTSB1VXGuZboyci+pCvDZnuZnRhDA/5w5Zvr2PSqIewvBUi20vMQzjSLYHiphKjvk2tCKGK1DtFPs3mkncCkxdcN05f3LSZzxHNR86u+DvvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706457980; c=relaxed/simple; bh=3Y2fe3v8fv82hwf99UNXqMFEmGi13fJAOCRcMqRzjNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WobBNEGHV1IOr+g4gwaul/8IBQdZJoylYCvkIZy4IohsgZzUZTRRpHKfmU76nmKj4IG9bfEwwdV8B8dq5dPkePQ0XrfipblAGJEo0syNbVmgJFyhreId6JUFf4m+Q/SrbCou6H81+7k80h1zef8XWwPKW6c0KNXmZUs5SpfbZsE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GoKDwMYn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8E4BC433C7; Sun, 28 Jan 2024 16:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706457980; bh=3Y2fe3v8fv82hwf99UNXqMFEmGi13fJAOCRcMqRzjNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoKDwMYnAXOfasnL3LeIKIDEOWP6iyLwq8T9d/vWS6mJbW9e0+clKEKjA5ABmYH69 77eaTotsqCzTnCeYZi+Xw1prbYTMHefffIafgAldZebhIP+UJKhIS8/4OY+Ujc5bzS dy304O/kjet2Jo7yGKkV4bR74zCHfIw/shk/fsoJefmcY6NJwpNw0oz3JhwFOEDdwr 956TCOy7YdIWLpVWYMx3x3rrXsy7PNfo0pSuOCcyikmh0K6N5GAtzo66JNsF+IS1h7 5n0ms4sVAqt34SGwjHuDlm1brtUYDrAhRCob1k87BkSLnI+SfWVYX0ocKhMmvjJ+ua JtCt8FTdUGfVA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org Cc: Julia Lawall , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron Subject: [RFC PATCH 4/5] iio: adc: fsl-imx25-gcq: Use for_each_child_node_scoped() Date: Sun, 28 Jan 2024 16:05:41 +0000 Message-ID: <20240128160542.178315-5-jic23@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128160542.178315-1-jic23@kernel.org> References: <20240128160542.178315-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonathan Cameron Using automated cleanup reduces chance of an reference count leak and simplfies the code. Signed-off-by: Jonathan Cameron --- Chances since v1: Use new for_each_child_node_scoped() --- drivers/iio/adc/fsl-imx25-gcq.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c index 68c813de0605..a32b5f68768e 100644 --- a/drivers/iio/adc/fsl-imx25-gcq.c +++ b/drivers/iio/adc/fsl-imx25-gcq.c @@ -199,7 +199,6 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, struct mx25_gcq_priv *priv) { struct device_node *np = pdev->dev.of_node; - struct device_node *child; struct device *dev = &pdev->dev; int ret, i; @@ -216,7 +215,7 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, MX25_ADCQ_CFG_IN(i) | MX25_ADCQ_CFG_REFN_NGND2); - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { u32 reg; u32 refp = MX25_ADCQ_CFG_REFP_INT; u32 refn = MX25_ADCQ_CFG_REFN_NGND2; @@ -224,14 +223,12 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, ret = of_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to get reg property\n"); - of_node_put(child); return ret; } if (reg >= MX25_NUM_CFGS) { dev_err(dev, "reg value is greater than the number of available configuration registers\n"); - of_node_put(child); return -EINVAL; } @@ -243,10 +240,9 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, case MX25_ADC_REFP_XP: case MX25_ADC_REFP_YP: ret = mx25_gcq_ext_regulator_setup(&pdev->dev, priv, refp); - if (ret) { - of_node_put(child); + if (ret) return ret; - } + priv->channel_vref_mv[reg] = regulator_get_voltage(priv->vref[refp]); /* Conversion from uV to mV */ @@ -257,7 +253,6 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, break; default: dev_err(dev, "Invalid positive reference %d\n", refp); - of_node_put(child); return -EINVAL; } @@ -270,12 +265,10 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev, if ((refp & MX25_ADCQ_CFG_REFP_MASK) != refp) { dev_err(dev, "Invalid fsl,adc-refp property value\n"); - of_node_put(child); return -EINVAL; } if ((refn & MX25_ADCQ_CFG_REFN_MASK) != refn) { dev_err(dev, "Invalid fsl,adc-refn property value\n"); - of_node_put(child); return -EINVAL; } -- 2.43.0