Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2067612rdb; Sun, 11 Feb 2024 09:44:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBl54tP146hZZwMXtzC64chzh1ne70lI9W4LgnLHoYRr+z03VgC0IusHUdb0Q5ghs0P8sp X-Received: by 2002:a05:6a21:2d85:b0:19e:b95e:16f2 with SMTP id ty5-20020a056a212d8500b0019eb95e16f2mr4256905pzb.25.1707673465175; Sun, 11 Feb 2024 09:44:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673465; cv=pass; d=google.com; s=arc-20160816; b=MX73PZ6Jjf0m89+3GJ9Wm75O8jdva9aJbBAEy1DgF6+gr4jUV72EL8oAWgN+9hz5uk 5ce8uJos/ukZYAVFGVzIVb5Cx1luPsLYSoyt6X2Ok/akVo6J/FwweLkquAZsz0KIfeOi sYMesR7uWMQgkXu0sTJ3lxCf1MSAhenCj78eGuPDF6mQZkZtaXpMUDSQBGV6lx7rFeUM kdt235tV5K74DgSkCBnAtz6jAune4D2xC5MzD+CvuKMh3asUuOalIqHg++p/mytlDSWE pGboKnDWGpw0pmA16mRsS99SWqwf7Y2Qk7Qw5TiVtE4gmrKQ88DnlJ4ZlQZEOhlHhl6e L4VQ== 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=fnJQE2QkMcRVzQA2BeqNJ/Uh0gWKXCfBgW79oWutut8=; fh=COHzsPiFt4KvKCVAv6BCxasT+YyWKxaRqH960zvD5RI=; b=YnmYLDlt1Ir5QOEFWcUNxR0eWThA/XHDJCdZz3yEp6GpFDWibrawUARfWNnNhWK+ge 6tY5caDRHF8MKdQKv+NZCUUq8LrmBPP4o32Eg5jH30hnKspgLnLptU+2Mwnrl+PhQm11 kBmYI7byWQRiD7EqO3MFd/4AsVXugXCEHzHuZrwbO7cj4Gdg6HPtcWR2+ZXMkUaZOw7G GbxIIvdGo3MaUb4YLsxzsWFnFspznqZaxRhz1l5W0rnzRl+raUYJgSMnUc+177R8JSWg gZh50SbIlPuNSEAOPCUX0SrzApB7tLOYjQ/rHm0BUrlwxeWdqnLVLgVH27bOBiNLbToH ekng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dVMFXNzn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUDL5MuyOcTpn46CgGbbbXa3gu8l0J3doBxlIR14WcLC9OL981k1BIBwy5DKCxmKBNmvLpFTthQySCLDSyUVvAb2K71E2OavlCbTLaNtA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bg10-20020a17090b0d8a00b00290f750dc65si5035470pjb.140.2024.02.11.09.44.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:44:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dVMFXNzn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60889-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 69ED8283152 for ; Sun, 11 Feb 2024 17:44:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 503D55DF31; Sun, 11 Feb 2024 17:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dVMFXNzn" 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 7242F5D46A; Sun, 11 Feb 2024 17:43:25 +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=1707673405; cv=none; b=KDg2Z//QDY9/TO/8MfFjPSNCG53TkVw2wQbmk9SSyp+sR0MoA5+NlZ49gRPl+9zziHjDhbZEJCyYkbZHIM8oWgYpVlQI+NQSVUTQQs+C52r1/SgHZyq3RXjYYloEyHYVBO6zjt1ODzWLR9OKRj0QakuEg0b8d4G1lgHJy49u6Ls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673405; c=relaxed/simple; bh=pMJBOa3z0fl/XMAEMYjuMhiH5HgtDAMqKqBYE15+9TQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pr7xTiG4sskfa2pVOdr5vshDbUlGNstzw3AT4WQVk1YAlnoGbyiR8PTR6TDpNW3WiGfcaKI1Vy/WLmQ/zxKD8oIQg5DVkRWEfhRmA2Y1gfnK90E1bTPhejdj3aHsFZWVdf4HoCD2yFEjQXimsEbek0pLfRI9LK0bCSZMno2NJ6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dVMFXNzn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE471C43394; Sun, 11 Feb 2024 17:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673404; bh=pMJBOa3z0fl/XMAEMYjuMhiH5HgtDAMqKqBYE15+9TQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVMFXNznnTMFwhRkqT2qf1PAHTM0xymZuhBNMzxG50a6LSNU/8qZMwh0uKttmsAej ulkNw5NStu0yHp6UD8qfDxR0TF2pDiMeeq150NRPiCebFtoZFsvwf8y3SDVbmp8OFE sxvV/Ey5nkJWgDwyUq5h+gAtCUQPt18CNQwCLNKFYeE2Pxku8IF3XHYW50Catv3wId W0DeF8+yQ4eC6/a02Pi9HZGSe4eVZKrpmTjr5/P7tAwTe5YemVUm6xbYreb8JHWAUK xmbclT2ZETYfk5vFKZ8cC9hzofKN6FI1BrR0ghAW9nG3Ig8aYxsIilKrA9AqvBT6nW lnmvi8Cw5QsAg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , 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: [PATCH 4/8] iio: adc: fsl-imx25-gcq: Use for_each_available_child_node_scoped() Date: Sun, 11 Feb 2024 17:42:32 +0000 Message-ID: <20240211174237.182947-5-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211174237.182947-1-jic23@kernel.org> References: <20240211174237.182947-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. Child nodes should only ever have been considered if they were available (either status is okay, or it is not defined). Signed-off-by: Jonathan Cameron --- 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..1b0003230306 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_available_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.1