From patchwork Thu Apr 4 11:13:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13617591 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.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 9C13D811E2; Thu, 4 Apr 2024 11:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229231; cv=none; b=k8iQ3Chvttf3NJP5cllWLmL577uZ09ScUxwiVyNd7AMkHyVjDfHBkgS3bmp4DUKJzHiHXWcEpasD3SVyHFVQ5Exw74k1H/FAKDJbwFVv1QyPVPVNdo5832gkMJ3dJmu1pYnRowX/MqP3TR9yoaqrLtNCTYZmfYf3EVtc9vaGrZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229231; c=relaxed/simple; bh=mdB/is+bhkTf8zf9+ZpFgDdhd5sBFtX+UWQ+XXvoQFE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ynnl2ZpKChNDqjeO8xcsi6tyTj3TBLRogG/lUPHZ88qL+x7PhAOPggPatBcAjPas8SS64KWKIscwilnZ62NCDikmEIzUZAenvqcFBhcn22wB7UF5jOtgRCthcg3TzwAg+ROAbzY/ZJEPLi/h9cZjQBrTWrWo+1eA34gWeaPuKJk= 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=VyLasYlp; arc=none smtp.client-ip=209.85.167.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="VyLasYlp" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516be63af88so923269e87.0; Thu, 04 Apr 2024 04:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712229228; x=1712834028; 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=XIEXAxQtbL/E7hyKdaP1dvGA88Z/fpv13jCLw6PaM6A=; b=VyLasYlppGJJh8/y7prViGV57Ugr0TpteEyKMpY4isj5pS3oBW9224tFoe0zr09TzC 0y5a2M4zv7AJPCs7uh6vLHnjV5GxI5WZA18HAe4URTkuTVXK5dqpy6U4/qIsDRwH9Eg2 8QRkPe9z9SmuUrSlw8vqnrGSrRi6wdKblRskLl399toyt/OFWpLuTgYFqoHAnB5urZn4 s42wHTNEApyG3JmeDud91jIaioEYNsmn9ycjlYDEzvtgkflE36DXMS/VzmhMYp/fPyco u8cdKKHlGbyXDrkEpViuliFQ0id3i1AuKA4xcLYlmWBReDTQSNFS+H7YdRBQ7BR/Kum3 Z5Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712229228; x=1712834028; 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=XIEXAxQtbL/E7hyKdaP1dvGA88Z/fpv13jCLw6PaM6A=; b=TbLzHdzFyrAquZU0DtGrC6UInXILFpnqWByNXlIv9pKRoqxYy4zwf0aNqZxL3xetMD FrGoGAiNEIiD/yILOLZST1mTmHPVySwrRY4GqMa9m/X8phN2plC6KUym9ECR08/LUz9m IprjJtIBpBq1E3063I9FUrpigM8sNmrojzgsuhXEPZJfq+B+jplb4ZqFM0FDfjfvCev6 haOtSNoJyoyqjQJZFDMZffe3RSjRWSEYP70Fxn3TkLPlzg2rnaN8rEpHP5rIX6GQ5s2n szYEYfWIu35wrZzvQYzfbT2+Yh52coHwOOnsQE1sMa4uiAvQLCMXAofAwAUZ/mHoWRnv ESrw== X-Forwarded-Encrypted: i=1; AJvYcCUij7LGQUlgsl6Ke1h0R533C1VOoWSJfYRAekdK3bj1EUz+BlTF8hNoM87xTd7tLE4/DVkTurQHdwDoIowEm6DkGN1DQe3XPcUQctoV X-Gm-Message-State: AOJu0YyCp9TjBKx8Guh7ecQSh2EewLkm7mx+tIM83/kcWctcaxR+NwpE neGxp9AKJwCT2ev+ApDuK/HEZ8dQ33x4tvC1rb2CdEDTI/YOiqzn X-Google-Smtp-Source: AGHT+IEAY2SACGYBonENoL3giQbqYb/IFCw4VBRZlAdA+PsuXCQvF8ilnrM4wAdwEfvzA7Sp77hp2Q== X-Received: by 2002:a19:3857:0:b0:515:bee6:5e8c with SMTP id d23-20020a193857000000b00515bee65e8cmr1469779lfj.40.1712229227549; Thu, 04 Apr 2024 04:13:47 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-64.cable.dynamic.surfer.at. [84.115.213.64]) by smtp.gmail.com with ESMTPSA id qf4-20020a1709077f0400b00a5195edf8e8sm104659ejc.62.2024.04.04.04.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:13:46 -0700 (PDT) From: Javier Carrasco Date: Thu, 04 Apr 2024 13:13:27 +0200 Subject: [PATCH 1/2] hwmon: (ltc2991) use device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240404-hwmon_device_for_each_child_node_scoped-v1-1-53997abde43c@gmail.com> References: <20240404-hwmon_device_for_each_child_node_scoped-v1-0-53997abde43c@gmail.com> In-Reply-To: <20240404-hwmon_device_for_each_child_node_scoped-v1-0-53997abde43c@gmail.com> To: Antoniu Miclaus , Jean Delvare , Guenter Roeck , Tim Harvey Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1712229225; l=1469; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=mdB/is+bhkTf8zf9+ZpFgDdhd5sBFtX+UWQ+XXvoQFE=; b=871oLthXyBWNsgAKIRYx4v/+xlOm0QoNkNg2s7AEOUvUZA5f5RYFc8RZwfgDHADRlyAoXaKX3 hGG7EWgv87uDWq+43pC9tHgMhuUrG4z8c8EphXe0HKZ4Iwxyjp+w3ah X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to the _scoped() version introduced in commit 365130fd47af ("device property: Introduce device_for_each_child_node_scoped()") to remove the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. Signed-off-by: Javier Carrasco --- drivers/hwmon/ltc2991.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/ltc2991.c b/drivers/hwmon/ltc2991.c index 80a6e391f266..3286775de6e8 100644 --- a/drivers/hwmon/ltc2991.c +++ b/drivers/hwmon/ltc2991.c @@ -284,7 +284,6 @@ static const struct regmap_config ltc2991_regmap_config = { static int ltc2991_init(struct ltc2991_state *st, struct device *dev) { - struct fwnode_handle *child; int ret; u32 val, addr; u8 v5_v8_reg_data = 0, v1_v4_reg_data = 0; @@ -294,17 +293,13 @@ static int ltc2991_init(struct ltc2991_state *st, struct device *dev) return dev_err_probe(dev, ret, "failed to enable regulator\n"); - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { ret = fwnode_property_read_u32(child, "reg", &addr); - if (ret < 0) { - fwnode_handle_put(child); + if (ret < 0) return ret; - } - if (addr > 3) { - fwnode_handle_put(child); + if (addr > 3) return -EINVAL; - } ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", From patchwork Thu Apr 4 11:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13617592 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 84C80823D1; Thu, 4 Apr 2024 11:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229232; cv=none; b=OTK8naV9esfgZdvOG1NWLXu8Py9cbLbWnwuZic6ej2bHy1s6sWg5pFmH4Hu1oBkxKflunLMObL62nlIu9DuySFM4Sz/m5TsZFenAgpO6jSrq9AdjS3CIXI21oWgmHQAD87e1mpMVlAmzEQxCQAyJWwLBKHBrJQzu8jN2IgkARFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712229232; c=relaxed/simple; bh=45vK49EfLJqORf4YubKvGjOflbMGxKU6di5MER/rwBg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gkBosojFpmFgAswnJoEkPZXzizgjFWlRJuF8eRm2M+jYOqT1s1IIyPY+RtZgVmaGMPp0YSUAcdb17JVJN3YQikmfhklSf2ku5ipFa4I0lVWpCSyIOrM+AdXw/MuHbJJ4o5YzHdimRQRtOTTkt6bzPllJxPct8NIoqvuJ3bxXPvQ= 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=MJPhAixk; arc=none smtp.client-ip=209.85.208.52 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="MJPhAixk" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56c197d042fso880938a12.0; Thu, 04 Apr 2024 04:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712229229; x=1712834029; 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=6TlPLK7jglvaB3j36qi7ymAffxtiGExNw/hBufrLkdw=; b=MJPhAixk5NJYqNK5XIyudgRoZEmzF5TbWBsgUQFicdpnav1P3448qJoku3FLmzIN63 nrFMTssObMctMCFii3DsP0xQtOUThGJb6SP5/SxMiske6VK7M69mVv6KzzrStHllbepR FCABzvbNQLaRSJc+Xr61yu3ETXMnHpIwJlssrBHezDh8iOmvE7uDxOd3JYpIxc7oKUOS gvMR6OAnAwHaWWgBSLyJegJXPDF11QptER8A3Ix1/uW8ZXcXzuoDl4m48xQacNMgNmRo IoMn2Hktee+FChQ3D14wge/BT65rY+6wYqTRBVtgNHDPLv3/x4DvQkfq0egQy1T3c48Q TQng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712229229; x=1712834029; 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=6TlPLK7jglvaB3j36qi7ymAffxtiGExNw/hBufrLkdw=; b=drSI3sIz+XfulG9Ac0Ch/Tgd/WgfYlcLO123g01xNvXzkgIibmM/XsudGrSK20zCi2 GDcQjH/W5J7y2qn5UhAFZk3fZdL09C+AIiqR26nL6waozF0x79N+SqOcIwkn+3iRzbJk INbtnYBK/+8RcdU8fzgQywc/14ZS3HAO8JykluZZioEnKWR26raSFZLKGXej9jrsyIcO rxRsUrAegiSFLUxp6nlK+p55VcAt6mw9Ka/Egy34LWjLPpsfm9JjnIj8umOV6hk/uEIa WI0rHfvaCVUF2G5tu+YCzU3+NrvtHsui5G66uSndnHqFntydMZMod+3Tg3RYrrGwI2B4 K3Pw== X-Forwarded-Encrypted: i=1; AJvYcCVpSFcuPow0WhDzp0QhVhAXFA/0kjRiVTbs3Od84waCCoK1Zvs628PY6LDaymGX4b4v3txv0lJqw4TxcruE7iOp2gCJtBZPDqY9W1cK X-Gm-Message-State: AOJu0YxoXCoH+UHmcsh44DpIUSUS5GFGguinEWbR8u0OjO1bSk3KNC8l I4vjgaX47Ys9+zezi6bEZ19IGp1ko+foyAi9uPl34IG2XXcIYgz3 X-Google-Smtp-Source: AGHT+IFtGTdz2xL9Qq4lX8iYug3K+v6pOIFUYq5Wdol+sO4ZpPj2n+IKwsdab9Bea2ogWg+W7qioMQ== X-Received: by 2002:a17:906:8c1:b0:a51:970b:6d55 with SMTP id o1-20020a17090608c100b00a51970b6d55mr41834eje.45.1712229228885; Thu, 04 Apr 2024 04:13:48 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-64.cable.dynamic.surfer.at. [84.115.213.64]) by smtp.gmail.com with ESMTPSA id qf4-20020a1709077f0400b00a5195edf8e8sm104659ejc.62.2024.04.04.04.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:13:48 -0700 (PDT) From: Javier Carrasco Date: Thu, 04 Apr 2024 13:13:28 +0200 Subject: [PATCH 2/2] hwmon: (gsc-hwmon) use device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240404-hwmon_device_for_each_child_node_scoped-v1-2-53997abde43c@gmail.com> References: <20240404-hwmon_device_for_each_child_node_scoped-v1-0-53997abde43c@gmail.com> In-Reply-To: <20240404-hwmon_device_for_each_child_node_scoped-v1-0-53997abde43c@gmail.com> To: Antoniu Miclaus , Jean Delvare , Guenter Roeck , Tim Harvey Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1712229225; l=1772; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=45vK49EfLJqORf4YubKvGjOflbMGxKU6di5MER/rwBg=; b=QfG0G1QzcjW5cfpfVaUj8toqOQuh+zJKvcu3CLHxbeaXwNT9D8jSNqdmgeEn3GDufpNPMIgoK CfT5014SEnNDtrX2uBgKp/g05ijU1ipzqbyRHilr8XhNoYHDvKB2+GY X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to the _scoped() version introduced in commit 365130fd47af ("device property: Introduce device_for_each_child_node_scoped()") to remove the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. Signed-off-by: Javier Carrasco --- drivers/hwmon/gsc-hwmon.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c index 1501ceb551e7..0f2147699c91 100644 --- a/drivers/hwmon/gsc-hwmon.c +++ b/drivers/hwmon/gsc-hwmon.c @@ -249,7 +249,6 @@ gsc_hwmon_get_devtree_pdata(struct device *dev) { struct gsc_hwmon_platform_data *pdata; struct gsc_hwmon_channel *ch; - struct fwnode_handle *child; struct device_node *fan; int nchannels; @@ -276,25 +275,21 @@ gsc_hwmon_get_devtree_pdata(struct device *dev) ch = pdata->channels; /* allocate structures for channels and count instances of each type */ - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { if (fwnode_property_read_string(child, "label", &ch->name)) { dev_err(dev, "channel without label\n"); - fwnode_handle_put(child); return ERR_PTR(-EINVAL); } if (fwnode_property_read_u32(child, "reg", &ch->reg)) { dev_err(dev, "channel without reg\n"); - fwnode_handle_put(child); return ERR_PTR(-EINVAL); } if (fwnode_property_read_u32(child, "gw,mode", &ch->mode)) { dev_err(dev, "channel without mode\n"); - fwnode_handle_put(child); return ERR_PTR(-EINVAL); } if (ch->mode > mode_max) { dev_err(dev, "invalid channel mode\n"); - fwnode_handle_put(child); return ERR_PTR(-EINVAL); }