From patchwork Sat Feb 17 16:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13561459 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 5E0CE1CD1F; Sat, 17 Feb 2024 16:43:55 +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=1708188235; cv=none; b=dsUKBRTw6vBfNulz0SNUdGiFjNVzxZ9j1AMLOe6XxSpRATUDraTd+LR2A0Udja5ULUV9xi8Z+c7rWkhZGIqsaAXwI0QIDnyqkUPmYR32FObp9uXUoX+kYya3WgpZeU3Cx1HRuLC8Y/utoitZALwU0+RSq2WgwrVlDG494fpSEDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708188235; c=relaxed/simple; bh=QrHoWfZbRHMq4P70zGYxGeka18F/ERWgdcsa9lr19q4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=id0W8T1r89UkdTG3zFatiDaajbAZu7GUVnuhnmhP6nNtZ89ytg0mHobLCAPeo/e3H9W46dFgSn6R1l+1f461a6hucBNnfPU2xDL3m2oxn6MryogegUzDBianrgG7xS5Okb9dadgArbok8U7e8k07om1UafCxpGsIXSu38s8bBUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KviDyznt; 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="KviDyznt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80CAAC433C7; Sat, 17 Feb 2024 16:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708188235; bh=QrHoWfZbRHMq4P70zGYxGeka18F/ERWgdcsa9lr19q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KviDyzntTMWqfml6AyUnyUImc/FFb8emara+J8z5R45nk5lZBbQMTpOYND+6Sy+lo 9EpVBKpy3/RZ4JcR72Kml1Li365Ny/qACqfcfKkAKDeFt3EyKncfVsq/zCRn3Fw8eW GP9tjE2YoWWROkFBKZIp3j9BFMpD4+HJP7jdl3NZwjleccowCWpbB7IH4RFO9jcbWh aRKGBFQXRdyTy0FJeQcitkNPehrJOHqLBItzfVn15VrvrAd+7AZ5Kdmsu66zc0Av9q BHA9BOGkyT3XuuLzbf/3KxKN8y/7euxZnVj+Sqr0n5iZGg1RqBT55+kXsfEapU5OBl C1ahWFtLd1N5g== 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 v4 08/15] iio: adc: rzg2l_adc: Use device_for_each_child_node_scoped() Date: Sat, 17 Feb 2024 16:42:42 +0000 Message-ID: <20240217164249.921878-9-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240217164249.921878-1-jic23@kernel.org> References: <20240217164249.921878-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@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;