From patchwork Sat Mar 30 19:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13611661 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 581613FB81 for ; Sat, 30 Mar 2024 19:09:13 +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=1711825753; cv=none; b=t1rTdvlYsdYz7CZHGMWNYubHmOJjvWAGwwsYdyD4F6Z82Xl5xzR7SOwcvkaILtYqBlA9fnlF+LMgvRNiUXnHO4GC8CRKHAnpgAvLZRzTSpYCvouJQ9MGcmHQ3hZvEowsKHnzy+njn8cRbkBmxD2RGHOCecXgbFdp5QfLsMDJsEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711825753; c=relaxed/simple; bh=h99Hg6GwiZm8R1GlrKNeI5fpGvHJAFB/VxgKTYEkcv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IKHVwkQxSeGmG2VOe85s3h4PooaRsgmknDjhXCsJfdNp0FTf4KWKLyzpOx8Rpfmk9q7IgTe22HOXxI3y7YWsDWJmrLnZUe9G+QYhnneCrQ/OQt0BZNR8Pvm2Y0dm/D9hceiiq58L1226iotqngAM2Djn9PKXHImnZu3rGgEjOqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FRpJiceW; 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="FRpJiceW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CEC9C433C7; Sat, 30 Mar 2024 19:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711825753; bh=h99Hg6GwiZm8R1GlrKNeI5fpGvHJAFB/VxgKTYEkcv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FRpJiceW1XGm2YqdtGTNtljHaFJJ9jb62S+zeBw5A7ltpoedID3TC5XwYI6ZpyrnM J576PkJspHS7Cet1oxpEGDY/oxfK5LOXiMRtjpMnS5cj9htSnk4QHkTEQmcj6o99M4 3YJt10DXijarQ9qgQv5WTEaitbIpNMfTiAtZpWQ/W4HAKYSStpItSq+zN/NfX0BjZD nVaGX4zw0XgLoEj7BqRvYhukGZASzpAnvqDmCiMF9qgaugrM3wPWuvvMfxiYH0w+a9 5WH72WLiDLW65ZsOrWV6PBoj5d3Y2fiV8pbvO0FQ9FPvzpFIQYDKEUQBEpsDreKw3D i1v+OF22au2VQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Marius Cristea , Mihail Chindris , Marcelo Schmitt , Kim Seer Paller , Dumitru Ceclan , Cosmin Tanislav , Nuno Sa , Linus Walleij , Jonathan Cameron Subject: [PATCH 3/8] iio: adc: ab8500-gpadc: Use device_for_each_child_node_scoped() to simplify erorr paths. Date: Sat, 30 Mar 2024 19:08:44 +0000 Message-ID: <20240330190849.1321065-4-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240330190849.1321065-1-jic23@kernel.org> References: <20240330190849.1321065-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 This new loop definition automatically releases the handle on early exit reducing the chance of bugs that cause resource leaks. Cc: Linus Walleij Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij --- drivers/iio/adc/ab8500-gpadc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c index 0bc1550c7f11..59f66e9cb0e8 100644 --- a/drivers/iio/adc/ab8500-gpadc.c +++ b/drivers/iio/adc/ab8500-gpadc.c @@ -1028,7 +1028,6 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc, struct iio_chan_spec **chans_parsed, unsigned int *nchans_parsed) { - struct fwnode_handle *child; struct ab8500_gpadc_chan_info *ch; struct iio_chan_spec *iio_chans; unsigned int nchans; @@ -1052,7 +1051,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc, return -ENOMEM; i = 0; - device_for_each_child_node(gpadc->dev, child) { + device_for_each_child_node_scoped(gpadc->dev, child) { struct iio_chan_spec *iio_chan; int ret; @@ -1062,7 +1061,6 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc, ret = ab8500_gpadc_parse_channel(gpadc->dev, child, ch, iio_chan); if (ret) { - fwnode_handle_put(child); return ret; } i++;