From patchwork Thu Sep 26 16:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813502 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 B36E2CDE021 for ; Thu, 26 Sep 2024 16:11:33 +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=i5gKs28PIZ9OJchaPijaHDwFlIvvXwx3mdFdZLIkcJU=; b=hnrzbq55a2DkMkDO2sLpoBP0VM Ye4126CmyKXMk8xg5CNX7ZLp0s+Mukpt46NaPj1qS9ED7Z0hyTCaUKoBgFzZriqen52X78hDJUyum +/wfzWveBnZQJO8IunQjF8CuEdvIn9o+vbU3YI+jfY7j2YaFJxnGpDhRh+54J+mltth0uJvBIQMfT /wenStetyVmE5zrTHa1+un1QG+M4Qpi8M0Leqcmp1TXyD+bPnJfCNLzy7q7yoAvVas7kj0SSEI2vU PeKdBLR9Tqy+0MTLDXmZQX28q/ML/7pc/D+uT0gZring8U9GzRnynRE/EI5E8DnFuj5jItRl7g+9V cL78tF2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1str5R-00000008qzc-0vCR; Thu, 26 Sep 2024 16:11:25 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1str2q-00000008qMD-3iX6 for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:46 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-535dc4ec181so1327347e87.3 for ; Thu, 26 Sep 2024 09:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366923; x=1727971723; 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=i5gKs28PIZ9OJchaPijaHDwFlIvvXwx3mdFdZLIkcJU=; b=Ky/yceWf6CI/8Ypt2UFGWLwJ/EL1d+maKh+Kt/cNZ79A9nxHIQP+g8QOweo6Y1a02m otHhMMo+pUUS+rP7UKlDL/YjwSYBCuPmbBcsw823GCPYuatZ1ElfkjCSXQkzi9JcWodi WSYHFixpQ6Z3R9MopkxdgvqwEb8m+TMZbT0DrSh7aHuSQvIFjyC3N5XCaZqaQN1yzfbF FGSiR1VULtbPAawg2PbS/UqHmblEuCKefsGLMN+kEK2FuUWPuRDigZuocJKtc4WPxzwn QFEAoF2n6+MX6hEPmnJp+vcaXakI8iCySDAenePFgUY5JKh1pE2YQB60i9beiyNBENlN p/ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366923; x=1727971723; 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=i5gKs28PIZ9OJchaPijaHDwFlIvvXwx3mdFdZLIkcJU=; b=BrZ7WaPUsc015AYje/IsobARppK8dZe8o5UyZQ8guaJ9fERVTTkkvyTwEYAMLMSkXY HB3Peio1n9Qrv1h2B9OwIFXhThHV8iUdpnU8oMWXSshKGvDFqbfCKfVSddGQYLEcsHF1 4tlP6YP/0syTJLYkvc0vNL1hftwzAn/cwGKq3599S48VepfKZ07pxu+7vayOcR6Z6R/U Zva/96DDmXDV0SMvwKzIiDY9grL0dt5s+VcSxlYog0ATXJ9Cd3oDSWLRtprwWWfwQL0e I0+2UHhLNC1zfU/JwoRaL44owf7TsbWSYvgSe70visDUjxYZgESU6j17m+rSgkV4OrMX 66Pg== X-Forwarded-Encrypted: i=1; AJvYcCV9yuzZBcYukYmSTV5zINkd1uCj3cdbzhLy4u3uEZXkLItfbs9o8rBUSzgXoqqYofW9zwVdcdKsd7xFSDrI4TFj@lists.infradead.org X-Gm-Message-State: AOJu0Yzv9rBAoUlHCYH8M/l2zeDDJ172J28SCffZhW1mps0jfeF+/Caz Tl6GVT+CcPU7JnssuaNDEO+5/Kr99Jh6u1ccjgrZul7oZIj7n7pZ X-Google-Smtp-Source: AGHT+IGLWzwtVsVoERLcNZJXmgDmyiGB9Y0BA8D4DZOrd3E+mXlHlQRe8hXYareII+TVH+5IvvXpAA== X-Received: by 2002:a05:6512:118e:b0:536:a4d8:916d with SMTP id 2adb3069b0e04-5389fc4d0d6mr73847e87.34.1727366922442; Thu, 26 Sep 2024 09:08:42 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:40 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:37 +0200 Subject: [PATCH 1/4] iio: adc: qcom-pm8xxx-xoadc: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-1-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=1388; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=+7rr+FCJ6AKEfSNXljsUP6cpWRBmO490u2jfv3txKV4=; b=sqgXoB41yns5o3RxNgTQxLX7a9d1ns38jgO9CICIOPLIHhpk3IrwcW0xk/EqE/0KHISg3Zupw NRY4WuSZt3QB53sR21L3VYD5YsVriYRanA8iMQlfuAM4Q7yT0YwUlxi 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_090844_963132_68EF0713 X-CRM114-Status: GOOD ( 13.19 ) 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 --- drivers/iio/adc/qcom-pm8xxx-xoadc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c index 9e1112f5acc6..311e9a804ded 100644 --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c @@ -821,7 +821,6 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev, static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc) { - struct fwnode_handle *child; struct pm8xxx_chan_info *ch; int ret; int i; @@ -844,16 +843,15 @@ static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc) return -ENOMEM; i = 0; - device_for_each_child_node(adc->dev, child) { + device_for_each_child_node_scoped(adc->dev, child) { ch = &adc->chans[i]; ret = pm8xxx_xoadc_parse_channel(adc->dev, child, adc->variant->channels, &adc->iio_chans[i], ch); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } + i++; } From patchwork Thu Sep 26 16:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813508 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 3BF92CDE021 for ; Thu, 26 Sep 2024 16:16:37 +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=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=sMzZgejwtplhjcR/10ZTx1waTm vzn+Dik3Z//X2jCLfpK6R4Vu3eZ+c/SBwZNVzIhrmBkmQ9b78CmdVh9U1201ckGPTGrk0PcBssH1a Cja95Ku9zbKw0Dy/u7x5FaIxNeCV2kW848bpMLmDELsmkmeIkcFjY81yGF90KCtwEFfrlvjmj/XKF ImhDNKsPagocNPO83a+0XPBJIUl9V1W4kXRYkOWJOvRIMhbEjJq00/nC0yKPYGSyQUkZSpBR5C4Pl Zy/mfsrC0HRUnWYofZhWWZ0vb2+10MINL36iPD5SgSKEoxEQBxareWM4Got6Tq5uMYvXJpYEuSSdk B5WqG5gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1strAF-00000008rc4-3LDK; Thu, 26 Sep 2024 16:16:23 +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 1str2t-00000008qMp-0XRV for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:48 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a93c1cc74fdso31418466b.3 for ; Thu, 26 Sep 2024 09:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366925; x=1727971725; 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=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=f/oE1hRXusa9DwYT6FK3lNmXXjTdNhVEjFNfmRNSS0BNb+YsmGy/tqBSLuRKhjOfIg T9tz8LEsysX5Ib1+jT36lYoAdv/Z6j+2QNmI7QkGM9RxmmeeLXwIxWlHS/Z5W7MM+sDP 5cwcIi7ByaRoBUWmGoxYUXhCVv1sSTd6+TZmYPtQ3JZbvizgCRSmNi4iL6qayzXa7G6C vTaIxU4SUm8xT485Cf30DPGWQFDpsTk5TVeUp6aJ/1IJ9uStTUNFhZxJ+djNPs2YAGYk J4KFjh6egQx75SrvJybL2BoxXCGRP2SZg9511N8mwOy4ofYa+reaWU0hCXbzI5hXmA+G VJOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366925; x=1727971725; 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=EJWKgDcwHDzRJDVWC4NU1waaLgU2pU4Iy2cHBRbpC9w=; b=Evj/V8seNRoVMstWGH4DanCQ6oJARoRqmZ2yFSb+PGOlYCzziAlIMkSTr+LWaCXvnc NbRWi0FOuhdJ3DiGfo2AicChiUCzRE80PXd7mJbSC5c4Ngup4kWSHs4h1Yxrb3696U2B VG9AL4DWJxomKfJI/Q4GyrnznWxMBQGWMuHJz8ffi0Xgavz5p263PHf0LDF4VIG3dzKb 7U6GJ8coBXOKy40RAVe8DIiKIiYjk60iiCjZZFFQF3OikIdHwbZpX8R5YzJDWZ3K856r dFlzMDPD5dUXkGProX2SG5WysFZXEqTwojWEyuauDU+V606k2jjNeHcJPwwZZiLk16LD Gv5g== X-Forwarded-Encrypted: i=1; AJvYcCWaw1ZvTO/BsNqLumfvXQE4Lsn/dCn5B9CxGsHXUcvYtwNfpJv11zKINX91Zp8ABn9iPKO/WWQc2D4kuJv+RnfA@lists.infradead.org X-Gm-Message-State: AOJu0Yxg5uT+oxSKxqigzjuvZbMDNPR8hHrb5adTjZIvTvt/0R+fomeg hvgwqH5zU1z/u4pEQEWSYBeAzHlLmsQ/KirGSw/RzVbtsGudd094 X-Google-Smtp-Source: AGHT+IHZdg2jhk2e+Cn4R32SMBMGp+lA/vyCWsLnw2owXMmyeWM65kMhdSp1Pkri3UzB+6nV3OV+IQ== X-Received: by 2002:a17:907:8692:b0:a8d:44a5:1c2f with SMTP id a640c23a62f3a-a93c48f089bmr2181666b.6.1727366925244; Thu, 26 Sep 2024 09:08:45 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:43 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:38 +0200 Subject: [PATCH 2/4] iio: adc: qcom-spmi-vadc: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-2-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=1374; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=EJRXbPr61KxXV+wd3zzOVNML9/DOwfwUtS+ORGYy5xE=; b=/f3X+kN5zg9IByr0xsPHywl8fBIPhkGkWyTcEpKXic1JID9p1QUtQZw+Rxv8rHnGNjltXPBXJ CEaXlT1j7D2CSGsPT/HYk1mzjnkj0PWoA3Ziq1lLMmt1Wlmh7WukNL8 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_090847_203896_A4F45860 X-CRM114-Status: GOOD ( 13.16 ) 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 --- drivers/iio/adc/qcom-spmi-vadc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c index f5c6f1f27b2c..00a7f0982025 100644 --- a/drivers/iio/adc/qcom-spmi-vadc.c +++ b/drivers/iio/adc/qcom-spmi-vadc.c @@ -754,7 +754,6 @@ static int vadc_get_fw_data(struct vadc_priv *vadc) const struct vadc_channels *vadc_chan; struct iio_chan_spec *iio_chan; struct vadc_channel_prop prop; - struct fwnode_handle *child; unsigned int index = 0; int ret; @@ -774,12 +773,10 @@ static int vadc_get_fw_data(struct vadc_priv *vadc) iio_chan = vadc->iio_chans; - device_for_each_child_node(vadc->dev, child) { + device_for_each_child_node_scoped(vadc->dev, child) { ret = vadc_get_fw_channel_data(vadc->dev, &prop, child); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } prop.scale_fn_type = vadc_chans[prop.channel].scale_fn_type; vadc->chan_props[index] = prop; 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; From patchwork Thu Sep 26 16:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13813504 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 DC944CDE020 for ; Thu, 26 Sep 2024 16:14:10 +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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=TmhBoBKSHyAaF2Cucjx8PdqEk5 64S6U/zDajksNusUJ/pE6NzilDrgpRgO4VggAA+PKh/I5khyLzktXfi+h9mfAp1B7WHCUvLIwORg4 ZPHcQ+jK17q1hctv9IZRIDfLgvG8220YigrL7Ui3O7eileLXlUl3aVBYeQRYiv+Rz+SKxKq7CKP4i otFdUI/W1UygV2LMBHIjq6r9CCHgGZx50jHg+ghOvQ4kZueVbrlYs+cix1opjjj5eFCFgzgU+nPCt 47bvgCKIJMSYp7xE1f2V12UcTP+DiH0VTj0iWqzJ3hL1Qc+47+qDyHt+9fLVok+E58CqS3avfVgA5 Wh5WAISQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1str7y-00000008rKf-1boe; Thu, 26 Sep 2024 16:14:02 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1str2y-00000008qO9-1hmk for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 16:08:53 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso222569066b.1 for ; Thu, 26 Sep 2024 09:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366930; x=1727971730; 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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=gdewAiYjj4ctAM3PtNId3CdxYJQQtARd3qe3jaU4pqsShF5rgg+k9bph4uMKHg97Pp II+5UErbBzbBhneCmw5Im14LNHL4Hv+ayUyXD2iu8BiHzdJu4reib+fWzqyHYWXIcExT k95EouZ7G/By5eVBWXTu2yCctEfgktMseBHV0Cu8fFiDRyF9O6fzMo3vlXHXUW2SEIf5 Ktq0wI1txDqqKdfOCBCuG15bK3T5Zj5LCGmc4Rq32OYN0dyKK7yOi4XN/sdqPDYs4B7g imbkQzH8FRQEVTeG00DyOFzr91II//wVVQuWdPkg9X+C8xB4/A1LUn7/YZ0xMC0/rN8v lBTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727366930; x=1727971730; 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=GfSfRbf6HpAPUG9dd1ayagyvrPMaeTlKhJpm5dY0lEg=; b=JweEUNrs1HZw3mJQe4Bs09mtGjFqFvFZ6wECHxvV/bVIbfQcC5Pb1YyEAaD30PODcq Uhpy+ZXbcDOiAewdCTuJ4hVjx1pbH+n7Gpsh4QejiMzvegU89b6yeWOwVtqtvkqe6CCk qGnb1mkABVBbAKlmRRptvSU6z6gUBeZWouJexLK9z8cY5gPn++nlR3XCUV8UgIfhmgIb Px2WMXW2Wf88jIISV5oTDEWX9C1Q/DTW/zy++/LRUeSLp6WMx4ZHp2e0u780vriYBq+V yszlT9llLZz6PuZoFnmlW2PknKeAcNvfd0SN+4HebDrwLBCHT8TgoKZ9/FDjabvwXnSr vOkg== X-Forwarded-Encrypted: i=1; AJvYcCUv6V8sRrs/idmgSWYXwOpdhEqFdbrXz0ZJe1GFtcDC6ucqHBKshGwkez8QAR8HP7le6swfQNrGyUTht2hsoH0B@lists.infradead.org X-Gm-Message-State: AOJu0YyJuKQ5kqabeayJuof+bJkCBUuMeXGNC5zEgE7MhDCFo0hdSYbL Eq3xMLsSgSWfOfh53xovaLjZH+D4qzj8OUxXCL+b8f1tNZTnpLCx X-Google-Smtp-Source: AGHT+IEa8ZK99gytPYhlMMIfBCh2WLdWCb9VYkK2bIOBiKcxBkDWAAatz/BvNKwWyUydN132lAq7Sw== X-Received: by 2002:a17:907:d2e5:b0:a8d:5f69:c839 with SMTP id a640c23a62f3a-a93b15f92aamr392676866b.15.1727366930195; Thu, 26 Sep 2024 09:08:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:08:48 -0700 (PDT) From: Javier Carrasco Date: Thu, 26 Sep 2024 18:08:40 +0200 Subject: [PATCH 4/4] iio: adc: ad5755: use scoped device_for_each_child_node() MIME-Version: 1.0 Message-Id: <20240926-iio_device_for_each_child_node_scoped-v1-4-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=1682; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=xTmIMKWrAEJ2sxUaBzK8+gdHqeGN97Vi3rD2yxlm2m8=; b=PgLKXJGq2MweGHIGTLRvljlOM7oxtbS7Y8PJM25aEBf0vmjeCKYh8ES4/Km4e2w0Irtx2nvj1 ddQdkAH4KPBDo3JfVnrEyLrV2hVMi0/5mNJUuT+Hf4ES1FMXY9K209/ 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_090852_483053_84B8BD8B X-CRM114-Status: GOOD ( 14.24 ) 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, in this particular case dropping the jump to error_out as well. This prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/iio/dac/ad5755.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 0b24cb19ac9d..05e80b6ae2cc 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -699,7 +699,6 @@ static const struct ad5755_platform_data ad5755_default_pdata = { static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) { - struct fwnode_handle *pp; struct ad5755_platform_data *pdata; unsigned int tmp; unsigned int tmparray[3]; @@ -746,11 +745,12 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) } devnr = 0; - device_for_each_child_node(dev, pp) { + device_for_each_child_node_scoped(dev, pp) { if (devnr >= AD5755_NUM_CHANNELS) { dev_err(dev, "There are too many channels defined in DT\n"); - goto error_out; + devm_kfree(dev, pdata); + return NULL; } pdata->dac[devnr].mode = AD5755_MODE_CURRENT_4mA_20mA; @@ -800,11 +800,6 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) } return pdata; - - error_out: - fwnode_handle_put(pp); - devm_kfree(dev, pdata); - return NULL; } static int ad5755_probe(struct spi_device *spi)