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: 13813491 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DAA015A4B0; Thu, 26 Sep 2024 16:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366927; cv=none; b=D4NlYVpFUqdrlUAPud2aWnC/OLMG8dYoTvlds9c5u9pUJIyUYOgJMsVupYGgPyM2ycOJM6sXmFVoVpWwACR34eay/k5GQbCCMoUUbCduGmFKzXsGESDvYwpJfHMbuCkyUH9lPaYhfvsJxKxIGgDp0+cmSmZMqcn8X6B7xlVSO4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366927; c=relaxed/simple; bh=+7rr+FCJ6AKEfSNXljsUP6cpWRBmO490u2jfv3txKV4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fhuKVQvbDTNr8hWk20RmoxzyzAUcfCuNUayMySlLhNvKm+vssm4pA85vtIXlOwNuUs76Gz67JzxpgPBYqQXTdRmROr7ePpoMVkHnyYSXYX7XAHciJNR4Wrrdik7J+912Lh13cRxzv2wGbDYGzIJZyNwCmqx299md5D+Z2Iw+jMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RBRa3QKr; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RBRa3QKr" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5365cf5de24so1613069e87.1; Thu, 26 Sep 2024 09:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366923; x=1727971723; darn=vger.kernel.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=RBRa3QKrr0EtWmL+Sm5KynmP3zeh1Bg/WzoMVSod3Gdvkj328GlK8x26gfLHTSsmHP rnyko5bJyd1m4SlBqMo47tRuFeLu0HYsMbXY37lO1egOa/XnoeAGZRWgqMwTdyRF+qvZ SLhl6war8Pv4O75A+UJc4LvamHp080egXojuaNzVfIZgnYYwjPcRMAHZW1/iCjp+omza ucCoymERp9TI/zTOxiW5Bc6/IsISHT6Q01QqnlXYT0Y/hA+/cXQ1c20qgfT0TzbM5TrP hItiU+r0GNI7RhMMRNzGh6zS+gjS7P2HdMGqzWVKViwVHBd3k0B1zKpcYPWtimwu8T6B NzCg== 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=wsD1Y0EO4IPximPOuyDSvQhlymUCWgxUBk+3OJ0+GyWrWjtl46biH2Y309wdaNbRYR vxE+ErlXQiiEDdFPp/Ri9INZGCYgeVEqKJpoW/R84VTED7rdkm2zmWBI7CjlwFQTpQuS spgrr77WgbHq0bab+TqFKFUS+nwoIsKF8/AmjJuPdkvzEDkN+ml5Ks55/7m+hCKhX2m9 2vBAqhMemSbn8NfAirBbMshQG/G2Vp0+WaSTr1Dubaz/dnBFIFYbqvc+10WQsTr9lfJY w6eQ9Pe5nSEeJcXB1ptAAqlwm4OUCqZA/D+C1WukCEabUw3Fn85HnOntsqP8GgEJAGBv xz8w== X-Forwarded-Encrypted: i=1; AJvYcCUjH8D4mdOuJsY3ZPAUgYW8767Li4L/Stm1yEhtpwCWXGLArTJJmwWfFEj+bakO0jAiiBvmfXwB/iS5Nd0J@vger.kernel.org, AJvYcCXB1MjqWpmJQKXsXoHFUrhEjfDYeKTS4zrnS7ejOk/dx3HHIglI9BstYPDdjnhvtSUn1JVLijBf7ME=@vger.kernel.org X-Gm-Message-State: AOJu0YzckzXwstsAVz5VnRWNuuj+clqV9K7DSootay88n2bzVHiu+tFx 0dXsvOPj+apf9xRDneqxVc2y+RZFxVZSPsFHlwN7B8RZPatO8Usj0iH4Bafk 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() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13813492 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13FCF15B55D; Thu, 26 Sep 2024 16:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366929; cv=none; b=BaCYryURFpdJsg+pC5MQLXn1ZrSUJ72S1wBJ8e3mdXqmDdUNh9pfYwoN0dGY6ta46I3Ce45iBTSUu0IpUt5Ri8V/UjYQnEdxf2tOk/CwiGyz4CLzteS/vPvaNHwdN3kXHSnJiJW8ptin9/JeG8C3BZ8LiiwdMFMZQa8UKK+VFY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366929; c=relaxed/simple; bh=EJRXbPr61KxXV+wd3zzOVNML9/DOwfwUtS+ORGYy5xE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pbOeRsdsZ4AKS7iRXY0dndbgBu2ImwslnJGQL0WHUHbc2SFZvQNC7VWe+/WG/q00QGa/NOncoughrbCvf81zPs7ElsoDgZr0NeevSRueEBgn6godKFsCNAdT6WLn/bdKxJd9jUdZUFE8VERB8KdDN3P0hi3dE05nchrsR1JfTF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DP8Gal21; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DP8Gal21" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a7a843bef98so148365566b.2; Thu, 26 Sep 2024 09:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366925; x=1727971725; darn=vger.kernel.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=DP8Gal21TJtIUTGR3anmmJl1DXVk0I6aqhKdiDgP6M4ds2JZsK/hX6JUevnuY4a2vi v/JSvOCwVl+BhZ8DyEwVyFMYMDQYq7g4GdP9MLu9f23PuJdn6t/P/jjV0MGSF14vgv5u i86HEAP5A2OMqVfamlxcQDlmTYNwFMbtobWTZtGhWbvEYBaMRYTiXOucp1V8uqjG6Rla bQq0RPzootkhYzJHW990dKNYFP8D5mTPgyY8TY68WWZxthyHV5GJVFAGhc1OO3WIiA4N K6s+5DrGlSBMds1FhcejgeMibZea4knAEypyduZ1cOKF4zQQ9nFWv+PHPQQQviXCLJEN XjGQ== 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=DaBJHwl8ExuxishStMIhUQPMvFVHc/J8WAx8HtvkormmedSPa05Y4K2it1X6VAfBAw OJ6B2TLEka7bAwPekV9vpXbKRXB6aH6aQjbSwVEs7G3JKkf0fQDtY/C/MTR89KWqsL5i HKw5XLdUqCkc02N2IQH6OJ7bVgzBDoL8NmyBDbOyyURZAW7qH7o0Zd+QJ+DjokTLCSic SV0zr/nmzNLBuYSQ90W00q/Z7K8TNh67PjMGofBd5Qfozxp6pmuGZtREab4gveUdqNH5 TgJZVFDX9lm/8eAcv58Jg1Z0I9j8m750JiCZe9hE4GEU6ZTOzrrM6fr2t7ut8nSl6tx2 Z3JA== X-Forwarded-Encrypted: i=1; AJvYcCUCRXykq+Xu6reWwsoD0zYKdv+YzIrKnXhividRze63NWtI7GTHCI3aB5R7+UQlqT4VvX2XxaPDNRk=@vger.kernel.org, AJvYcCUQM4k1wZUIeBepo632g1nAfLhJuahWLeAfta4WrSfmPWyQYx0tcVg2ugzo9+6sl9o7ZrQ3wk1fF1hkVJ1Z@vger.kernel.org X-Gm-Message-State: AOJu0YxyVAfkYPDwCVlXaCT1RjLvtayIkuY4ePRbTNRgX4WYhMjBR8W7 GKnTeYf8/x5+ckd4b5pxpIIQmYKKYVLdXU4zwlbVtzaKdLG3m/AFyLUr+yQ+ 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() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13813493 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DB9615CD60; Thu, 26 Sep 2024 16:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366931; cv=none; b=dlmtddafcLAFmF/lopHaSm7f0k5fEgLTpRf3YCJOGDPvbr3ZZ9Y190t2n3vbt/1JFNiUJvE9xYb+Vfy72r1JI1h4Lqk58IXtwqkzW94lZ4L5SjvoniEPo9ZAg1DzhbvMUsjqpFZwrkglm5wqMKygHxh+XfzkOhvFujKWzmK7aAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366931; c=relaxed/simple; bh=TlZo/sfYlYA7rfrWUOIFpqQSC+0+ci/zValTOgfTA5M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JA3/0DN7kusrGy7GSoMp0eyf9XS7awPmfOIAzbM+XBJDLIma7Po+r/hxtTUJrppFQw9cuNe+5ccnjrMb1oS9n+d+yuhFJx7pvcoD3tJsaAVuxKh/20GC1izJCvxoqQtbzFIkkXkdkB+SaJ4YXr1WDlNTws6lGmh+C/qqEoT5HE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xg96h4Br; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xg96h4Br" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a8d24f98215so160952166b.1; Thu, 26 Sep 2024 09:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366928; x=1727971728; darn=vger.kernel.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=Xg96h4BrnX9WYXERIDSB53vO9sLKmt3TO9zL+vAtGksCEJfuIgHnU0lbPpl5f13iZy Hp1yCWgOpoIXKqIHjwC2CCF63r+qGixA6r7PO7dc4AWn9/kI24XkNd0PBjYI8oVG4MpM eh7ESHW162KPG9lrO2kNYnWX/6lD2hhRur4XfeKibrODJ+TNN7SK3alxrWCfmjr7tdoJ tzskqs2Z2PMXoNPpfZdSFGqpe0yPjPFuBUR22IqEyC/Yv34c6mdpS8FLui07heLXycDV keKd+wJ4n5X3Tr3HJVjMOCu5IrAVuROLScs5b8ljH53RS/lyMqhuvKLNVxKYwZ4SSZy9 URqQ== 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=ibWD4VkVcOb6stU5pzluK7GIAlMTa/gbXQQOkA5QRmKsAo6TDZ9dYyohQBqI1geOX2 NrNXtNdhJ9vwBegHmXpOLFPJMk5Qt+1K9heuUCXoxr1cmXJFCnZAPhvMiyrkc+p2fuSf LL/yvdlmctWdZ3bQHQCQyrAkP0tVzgvnv/J5f3PR4T6Da8C3XXNtcuXP/5CDNX5VMRRn mNBaQrdiRIyAb3BQCTJzAa5RQohYjeE/9zHLVwlZd10kbYyCsLXlEkmBs83qbsTtGM+8 xn7qxdqZVlSNfN14LMYAIt3pNakr4nEXNw6gWwn5dyTPLNV6oXyz1c2vTaMLH/uIoQJk V9aA== X-Forwarded-Encrypted: i=1; AJvYcCX2mI5zLhj9zxIJU9S72OypVcXZV5dLr/9qSOn+cZghFvKelUC4Oaxh27SzSyaEEtblDqxFX/Yx67l5+CCe@vger.kernel.org, AJvYcCXctRj9axRQZlqXuHre+KFNMr9uTuBsZAmt8gNzB4NBlwvIElAxIuTw9qo+l1yy1rMqIL/LRnl5010=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp5hiCajuIMoSzEYMUViaUJJCM24XMX6Xb25FU7I0cdWMWdvpf OGxRw11IDtzG4zhNeTSogK6Rt34IGvV9ugEFupohGwE1s/NVuzrIC2QiZ4CA 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() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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: 13813494 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88EC816190B; Thu, 26 Sep 2024 16:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366934; cv=none; b=HHcz0z84n8BD1xt0NM4iWYjX2gUYDQbLfDLfLElyCkVEfsh9Zbdrf+42Xu1UyeICEOhbtPtvcygB3D1Rt1sP+OvYS8NzSfKmqTXcd3beFA2Pf36eUNGmeXhz62kggqvkvFiXZ5yp5LjAjh0nJsY5d4qfzexaFk0qdDEAN9CfnGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727366934; c=relaxed/simple; bh=xTmIMKWrAEJ2sxUaBzK8+gdHqeGN97Vi3rD2yxlm2m8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rs2YCicFOtH8Z5YDhkn2NbFQqW1ooxSJ7ZJLu2CpPUOuuBWxQ4Ee+++Qrp1jxgp718V1V6gtIQTqsiN/EFVKkMFPRywVU0aIytFpZyVvjdkvHpehUN+1AkJmupyN+zzxV5eqyFz3XLTt+RCBm9H1Ka8LNQZ0Hqu5B1cLZVAwJFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cKIwQDM5; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cKIwQDM5" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso222571566b.1; Thu, 26 Sep 2024 09:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727366930; x=1727971730; darn=vger.kernel.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=cKIwQDM5E+9h2I+F3Ky3eZc5N0t8dut6FSPH3OnBIkHDPQ7lGpdbsYC+SAUhadFibF NPtMrvIRGWFsWECBIh3FSITSOCtfyYmzfRzuXdQagfMTyvO9zpGnO1DM2d5X/MFxIx01 zoaddBVtFqoR0O/zSxLyLyGD3hpa52pU5deiQeOk6AFKPWInJPFsAikCyPp+sKOJqD/s 87IGq8N93q2euazXZQ/pGbLQTI0gmJdu2F3+LKrQ3rE+CRpAQZd0blVdGTbzV/G4Q/bS zNbus6AVsqPEaXfEJSajE6TqcqV9nQXO1F8kc+Mj4E9rB7xj98KiLmSOxHB6kOKj6934 FSHQ== 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=fIKmH0rbAnTT74ZylZt76QhGsf8SlngjZWIxPlafw0kv+ZIJ9J6doBuydu2AB7ToBf /Y4tE8/QPz//NXjDSVCNvAME0kaUnfMIjU2YX1Q5LC4IYQFaLxbqBe2JNyYFsV5wM8wo 2WuSR0NEHylZXmz5IZ3GZd3X7FX1113B5CgJl/pdVgJVO3RdTyzXOMhkjnyQAaKR88Xv Rqs0V82Xj04s1c+p4/AuIpaPXcluQR9xGx1KmNnkTxfgPYvgW7OhEihkkNVXk0B6HpvS FqE5EziiOjoe/2rwNFZHUIGOaPJwk5T0Hsu0pyPWDPUJrrse3io8AatdzpBLx1dEiOwm U+UA== X-Forwarded-Encrypted: i=1; AJvYcCUP+h7TLA6Pj0z033X8aY2aaoDEWbHjIO4/LPvCnqDCVZlBjfKfu6FN2nVBNhQ2+uWjBtpLLCX4Om/+UoNO@vger.kernel.org, AJvYcCWxxmdtri3siODNkXTHhaSL2gNbNoVzA2FBHdaYdeVKXxn1YRVTQx/76tUYqPLWtc09C1uGxPezahU=@vger.kernel.org X-Gm-Message-State: AOJu0YzqziQ3eCpNAWghKu/AKBof7GGcZOaBpkwi7r6CD1rL6DSFAeY5 dsi5ikx6pwAKdgF0tZcCGxQOE2MvkvEHzo9lVP8JkRU/u7yU84uDe7NhZG1a 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() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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= 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)