From patchwork Fri Feb 16 17:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 773402 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 B2696132C0F; Fri, 16 Feb 2024 17:53:28 +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=1708106008; cv=none; b=sWvs/+hFd5CpEQ8GVDM7shKA0Vn+6brP1qLv8Pv32BgB/N+qbEvGzjhH0Vj8qdFdPwITjS/sbtejCpL8R917eHtUkSz4ZOaX/UsnZTsNLgduQRq1H3FoCGw/RQP2GSkOkEumQE5q3uKWddICN36vbWxnY1I8Ml/PYKXiKQ0YwkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708106008; c=relaxed/simple; bh=QrHoWfZbRHMq4P70zGYxGeka18F/ERWgdcsa9lr19q4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ki27AchaSJV+crYd0hZ4aG+O9YCgnPQj+6aCgaTp3KE4R1dFQsUKopl4X9Cign1Cgon8eSUpiLKRC+04B/MW5IcdERdz2SCedCXzZOKWRSMjDWDr3lOxnsx6+67hhsuVBOitQx6cmAw9ki/OvbsqRkntQktSRHEUE8ieNW0gWqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fYKPTIRA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fYKPTIRA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3197C43390; Fri, 16 Feb 2024 17:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708106008; bh=QrHoWfZbRHMq4P70zGYxGeka18F/ERWgdcsa9lr19q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYKPTIRAmh3TjzAwG6dVCT4pk5tWiZLy7NER9iV3LUfsIkFDuaGh+eNz/xIZzjt4G 8OIG978NUzQrQarInv+yX12BssldtO+ZKj1dTyotR0jWDbt9xhl8hKsxSYWZpx84J5 CrcDwi2wpoCuAkujjEHiNGQgFDO336OQw6CtmU4JBZSRE80L4wXErpzuVoP7S/SQXp zOj7+gYJTj64Ji7Q3ymgM/We4v+8FHCsu853xl6ygJvirNtwYpqWDrreTJxliSOKlD Wfiqc740u0SzR1GSi0euIczwSaDkPUdMBQYYoUzJ5GuI7ewnoibMA+O12ls31ir/1V 2+QkWhLDDWlUw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , Daniel Scally , Heikki Krogerus , Sakari Ailus , Julia Lawall Cc: =?utf-8?q?Nuno_S=C3=A1?= , Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Peter Zijlstra , Jonathan Cameron Subject: [PATCH v3 08/15] iio: adc: rzg2l_adc: Use device_for_each_child_node_scoped() Date: Fri, 16 Feb 2024 17:52:14 +0000 Message-ID: <20240216175221.900565-9-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216175221.900565-1-jic23@kernel.org> References: <20240216175221.900565-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Switching to the _scoped() version removes the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. In this case that's all in error paths. Cc: Lad Prabhakar Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rzg2l_adc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 0921ff2d9b3a..cd3a7e46ea53 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -302,7 +302,6 @@ static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id) static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l_adc *adc) { struct iio_chan_spec *chan_array; - struct fwnode_handle *fwnode; struct rzg2l_adc_data *data; unsigned int channel; int num_channels; @@ -330,17 +329,13 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l return -ENOMEM; i = 0; - device_for_each_child_node(&pdev->dev, fwnode) { + device_for_each_child_node_scoped(&pdev->dev, fwnode) { ret = fwnode_property_read_u32(fwnode, "reg", &channel); - if (ret) { - fwnode_handle_put(fwnode); + if (ret) return ret; - } - if (channel >= RZG2L_ADC_MAX_CHANNELS) { - fwnode_handle_put(fwnode); + if (channel >= RZG2L_ADC_MAX_CHANNELS) return -EINVAL; - } chan_array[i].type = IIO_VOLTAGE; chan_array[i].indexed = 1;