From patchwork Thu Sep 26 16:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5694CDE022 for ; Thu, 26 Sep 2024 16:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w5foGMs+KnPV1j1E6JrJyJnRmk35vw0P+oTGPUMwklc=; b=ZJnd0PNGyXZ5o3Tv2SlyygteYH NlzZF76Vnt2rOG5rB/J2/0vRh5R9mrXkUIIL430kLkqnWUiIYUco3erBtTZ6x/HwM5jf7KM0L+09O TiI/plLATXJs0YPEZAheaH1EELHW8zTAaBk6+cVRWcu2GhftBEIdbIC8kqsNXbAJmTd/Ptd59IdPm rQWfBRwE/W5uHDORDDLTg/JwsQ/vdYd7ha9tlrR2SO5UAqGNO42Rpc/1egEKb8Wb+xDC0dtx+FmCC nD2cHqdhCFpUi9lr6BcKi4VVWHEsNRn1/oBmxzkzegYn7BDHDVWt02TyaSA2HA7cLIlRY0Phh6ELN gmHlmCow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1str6p-00000008rBe-3Qtc; Thu, 26 Sep 2024 16:12:51 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1str2v-00000008qNW-0FHq for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:50 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a8d446adf6eso162026766b.2 for ; Thu, 26 Sep 2024 09:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366928; x=1727971728; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=w5foGMs+KnPV1j1E6JrJyJnRmk35vw0P+oTGPUMwklc=; b=YeM41+hDui2wsZ8Vk+td0HziUoveMI74C8N4HFQIZeRISWXRt8hY0xH7uEO2FsZt3Z nyebQDDAFLcqDuqj2IZyMzNxlqqbg2RjOnUdfPtium49PopyFYps246zLYGg/5XgBpUB xtIJIJHAU26AciH2rJhQ8oL8HzwQcu/EPd6cDhUlCSZIcudBGS51Nfh8aAoUf4TeHJRR 2d1pzw1+PkGzJTMlzIDwm9sUQbYRCKUuTzPqacKc0qVAjTx38gYm611EPlmkzugnLedw /YjdjwPRHlsjTsYb4Zak+IzXU0RzhnzO/ee5NMhcc6IWoZYeNyW1cc5yWxF6hfOWU2fq 6c8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366928; x=1727971728; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w5foGMs+KnPV1j1E6JrJyJnRmk35vw0P+oTGPUMwklc=; b=UhNYs0H1S579uwnSx/CYkm1FzEXNxJa+AxTe93c9DC72Z7zsgJODGCm0+QVFwg5L18 oylCYLP5apep8jTfQfooF/kjzdb0lcdF+IpsB5/+yqSoRqR5+/Ru3q/MdMOtDjl1IyuA 7baV4z2zhzAzqDKuiowpXX5IOLHmHpECUQdMPpTceSr7UC7Jab6gy3N+ofwGknSOcmfK 6ZlTaDUyyPjYs0Zupmug/tQkyuIRpJJlgbNEW6fauqSptOVZ3S550WZyRnZLYRa0MaCe OjbLNOq7ZIxSEwJ/hUaU5M8I/VuqvLYkCPyEXy2srTZ6AM508fU54Z5vEZ6TeWGhG8E2 otgA== X-Forwarded-Encrypted: i=1; AJvYcCU70PuN8rNjbI5BKgj6lu5fRjuf/pSOtbMn8Oy41L9Pv8Tr1cGMmocgS0zMVb/71StmtbVwEDN1Qp81c3OwE92H@lists.infradead.org X-Gm-Message-State: AOJu0Yxh42WaWZhpUef2cqTPO+LCHDerp1KY2NTPo+2IZwa/J0TVoLqb 53zALl4/HEyzjr7f6aL0Ftz69Ly4E/CoEOsrsi/WlxT/YrWNzVyY X-Google-Smtp-Source: AGHT+IG8rSfCQ1OjrEgIGoq/mqJNnCJSIS953PFQJ/ktEiwAsnotpjZqlq72ENG7UQlOBtBc3cSxAQ== X-Received: by 2002:a17:907:3fa6:b0:a8d:3085:a7b1 with SMTP id a640c23a62f3a-a93c492abdfmr1068966b.38.1727366927568; Thu, 26 Sep 2024 09:08:47 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-6d88-4cd9-a9d4-f267.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:6d88:4cd9:a9d4:f267]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27c70d3sm13947966b.78.2024.09.26.09.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:46 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:39 +0200 Subject: [PATCH 3/4] iio: adc: sun20i-gpadc: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-3-64ca8a424578@gmail.com> References: <20240926-iio_device_for_each_child_node_scoped-v1-0-64ca8a424578@gmail.com> In-Reply-To: <20240926-iio_device_for_each_child_node_scoped-v1-0-64ca8a424578@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Michael Hennerich Cc: linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727366918; l=1419; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=TlZo/sfYlYA7rfrWUOIFpqQSC+0+ci/zValTOgfTA5M=; b=osh0N4BGJ8X6iPBsv2lwnI+w/XSuQcRZonFjjaGdfwgJtIr0AXEz6v13uyuHef+dxe3n5rN+z f8Z7K/XNIOHCJeKtha/xtrGWD/+0tKPLs29XzedI9TTKVHHjK9RDI5r X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_090849_135509_0A93B4C2 X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error path. This prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco Reviewed-by: Chen-Yu Tsai --- drivers/iio/adc/sun20i-gpadc-iio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c index 6a893d484cf7..136b8d9c294f 100644 --- a/drivers/iio/adc/sun20i-gpadc-iio.c +++ b/drivers/iio/adc/sun20i-gpadc-iio.c @@ -155,7 +155,6 @@ static int sun20i_gpadc_alloc_channels(struct iio_dev *indio_dev, unsigned int channel; int num_channels, i, ret; struct iio_chan_spec *channels; - struct fwnode_handle *node; num_channels = device_get_child_node_count(dev); if (num_channels == 0) @@ -167,12 +166,10 @@ static int sun20i_gpadc_alloc_channels(struct iio_dev *indio_dev, return -ENOMEM; i = 0; - device_for_each_child_node(dev, node) { + device_for_each_child_node_scoped(dev, node) { ret = fwnode_property_read_u32(node, "reg", &channel); - if (ret) { - fwnode_handle_put(node); + if (ret) return dev_err_probe(dev, ret, "invalid channel number\n"); - } channels[i].type = IIO_VOLTAGE; channels[i].indexed = 1;