Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1093743lqp; Thu, 23 May 2024 08:48:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhD83qu2TZuLuUuQHZLYgu70zZCdIJvibngnfhDU+BMbrLAWoF9lUPjXovl1Ekj/jRic3cWBYYhVaQS9xZHr5BHbR5+3CilD7OwlchWQ== X-Google-Smtp-Source: AGHT+IEgJFOFwZHnPXRq7/3tny71e9GPZv2pzDh8jHFw8IQ3KzenU4sLH2Lm6t3xIp4GHelqvjeO X-Received: by 2002:a17:902:ea03:b0:1f3:4c13:671e with SMTP id d9443c01a7336-1f34c1367eemr15602865ad.21.1716479302391; Thu, 23 May 2024 08:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716479302; cv=pass; d=google.com; s=arc-20160816; b=Py+aewey+I+5nsvGTRgfZ0FMaRUi+R335fl0kfi31T7SdYcrk3ky05tzQOuiyC213g Aay6K/hbL2ixWLQTrCUqH4tdlrc28wwDPP7WB1ZVQdqYmdPwVuJM39VvyKoBCWYerljF cv1RvpR4WsdzU7ICf/UsFW+zuBvUeY+CtXvS9WpLWW6ycP4uC6g4TQIoDirfBg/40820 5FRWHvhVxi5VUc0DSQL0ACCvvO6AaLRbdRM+9zyujg+5kzTS3A3P9YgW7wLqyoqcpmpV cYO0264aJDFr08oPWyimNGqKMgbNMsOG9m6y9Z9kVRTOBVNdzOzoZkfCOZhB/JjFoPuk lXpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=mgjORZ1nG8GVZ5mqOBWiHYanFt0bhnov5yW5k3xGY4s=; fh=mHctGUfYGzCQftnWTnjhDQrtI2vUF0vj+2E/N8oFzoU=; b=qEn1+MNjwctoUu3517VqvnZuAzvqXwNdw33CWyX8O5wpCl7sSV1gjeX1IpPsEDxPG1 jherCw8xr1n5GLh/XOTX1K3ma0fx5J2l7iOAQVhGgaVaSLbBdX/FVvIOgerdBt9Rb5YE BLPvqRJNDOI4tfvbNWqNoCWnkCyw386aprnalU1NHNmOZaJ44zXDqYnXZcHQZXO1ew3l c0Z4KLUypFn1O3R4auOCtTAtTAFb1CztlZseisFZYpVBLbhN4GITZamSpvBJLPTorIjf Q90t2LEndAKbMhbMj5yd9U3IWJ+YGZLfzwslVxVrEzy2nKOSvggBs3rW3JbafkYE7z90 2UZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="CiTw7/Sa"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f2fed58861si79573015ad.255.2024.05.23.08.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:48:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="CiTw7/Sa"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 068FE281DE3 for ; Thu, 23 May 2024 15:48:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEDD221342; Thu, 23 May 2024 15:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CiTw7/Sa" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 6AA3C18029; Thu, 23 May 2024 15:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716479259; cv=none; b=L/5CBwuKoT8BgPTYWvempwECM1PLGrpYowWZnrFK6LTk8/bPP3YpWfpeebN5OQMHZFuuMchMw6U2Xm3CJIU5GIq1+b9ZqqDvMGJbIZdzZrd9Gd7NFuqCGD/2mUzoyvKaFEgkjOfQoNSVAsF8S67tHjENt9oabcKOAP/ADbZGaHA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716479259; c=relaxed/simple; bh=W29c7LQHWSwTs1cLDmC6925ws2Ed59HyAJ65h7ys/4I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r7twJvCZr3MeqbrZb3dD5/kfezukbmNROxlpXz93TTCbVFcWZditwtJBVzf4G90grpxFItuT/BAF9rI+c9bUQtqnplIHeeTubrdLNjD/113qszwXhNu8TtKAVqMYyzil2GjBoz9GBAzsiEfve5cBaj3e+FvbFgo5ND4tmjVo84Q= 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=CiTw7/Sa; arc=none smtp.client-ip=209.85.128.41 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 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-420180b58c3so57754355e9.2; Thu, 23 May 2024 08:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716479255; x=1717084055; 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=mgjORZ1nG8GVZ5mqOBWiHYanFt0bhnov5yW5k3xGY4s=; b=CiTw7/SaNLJoa6mqdAKBKZQj0ZdZxcNEmG3MTZup4o8b1PVzbtALUM9sbk7b7MkzpI 4T9dXfswjG4BKM5XeMs/TDFZN5BI7XKsRhBb8dna/zrOyTedurRp4vFDXPgCBcOwm4m7 sVs2/J52xTVqgLDTH3yB6uEOsNjrmvot6Vf7MqH8m1Sraqp8GbCcIzWCHFa9hfXsV6Yj cMeZ4wkDacIlJ/zLGFMOALKDTYgPxPy8lx3QnRzAS/55kQNXXe2Q/LRQxYbzoQ0Q9GQD GEVSTcIX8QNaxDvqPATBo1SFYw+yiiMldoVpYhIwgV6AqWVJcn+qs0TL0uUTE1xQjl9n UXcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716479255; x=1717084055; 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=mgjORZ1nG8GVZ5mqOBWiHYanFt0bhnov5yW5k3xGY4s=; b=wsu7sEvbwxxHRe2/YAMaSkdAXB38bfT0FDr4JFl1XbUfwk3LW9L/eGj0QNjlwjuHly 6PABaQijh99/h9dJWZby2wecLaAWxF+Io6UMhS0wtbiFLpgVERLumch7zI5yY2RXtlqf M2lRtDgqnY/ipGnNODRotRS5RJ+cT4JnjbSEyNaqqnn+zdKXv4vZeBh5aXzRqv7zi8/C zcZbLP770aAENbBOLovTTrXSj22jb5EqodPI2zqhRzewAJWVHTTq1fa521v7NeKn/2dd 3E47EoyEvOhvl8ZrbdRPGUn1MtR4/eblpUToOLqla+DvDAEidt8g9am1mGdGIiBK6BDD +WoQ== X-Forwarded-Encrypted: i=1; AJvYcCXfLA00+rfLoYshPdmMPQgqO1VAXOF94q1mc6Sts67QNPqJ1nR3z+TMudwXnnu+KvuytKsn500cj9qSjCc8snk58qR0o2/34qxiDr9rRf2BZNEqXBXs5zQ9WH3JPYbohUeU6nej5WrP/Js= X-Gm-Message-State: AOJu0Yx0htenNUOVA11RxvevYURV/raK9XSyFE/1k6Mi3x5iLBJBFZIT JQYJjg+ES2xg3GMwj702ipV6SHa9v4bbO9Y1ptAgRmu/8UQPup7ruo+HRkO9Py0= X-Received: by 2002:a05:600c:5802:b0:418:3eb7:e8c6 with SMTP id 5b1f17b1804b1-420fd2de525mr42805915e9.5.1716479255556; Thu, 23 May 2024 08:47:35 -0700 (PDT) Received: from [127.0.1.1] (84-115-212-250.cable.dynamic.surfer.at. [84.115.212.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f5a576sm28569725e9.22.2024.05.23.08.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:47:35 -0700 (PDT) From: Javier Carrasco Date: Thu, 23 May 2024 17:47:16 +0200 Subject: [PATCH v2 3/3] hwmon: (ltc2992) Use fwnode_for_each_available_child_node_scoped() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240523-fwnode_for_each_available_child_node_scoped-v2-3-701f3a03f2fb@gmail.com> References: <20240523-fwnode_for_each_available_child_node_scoped-v2-0-701f3a03f2fb@gmail.com> In-Reply-To: <20240523-fwnode_for_each_available_child_node_scoped-v2-0-701f3a03f2fb@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Jean Delvare , Guenter Roeck , Antoniu Miclaus , Jonathan Cameron Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1716479248; l=1914; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=W29c7LQHWSwTs1cLDmC6925ws2Ed59HyAJ65h7ys/4I=; b=hJsNk1qK9bFp/YtyRLaBHH0CpBC3eyYwxgTIyc4EGzGTSOLsTh0zFRQvHVKbK6UTawaCYX+Og fw7w7hR9WohDlf33RLnmPUHoRnfzSKZOMX23rnLStdiTmIuAXpCWpyp X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The scoped version of the fwnode_for_each_available_child_node() macro automates object recfount decrement, avoiding possible memory leaks in new error paths inside the loop like it happened when commit '10b029020487 ("hwmon: (ltc2992) Avoid division by zero")' was added. The new macro removes the need to manually call fwnode_handle_put() in the existing error paths and in any future addition. It also removes the need for the current child node declaration as well, as it is internally declared. Reviewed-by: Andy Shevchenko Signed-off-by: Javier Carrasco --- drivers/hwmon/ltc2992.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c index d4a93223cd3b..3feee400ecf8 100644 --- a/drivers/hwmon/ltc2992.c +++ b/drivers/hwmon/ltc2992.c @@ -855,32 +855,25 @@ static const struct regmap_config ltc2992_regmap_config = { static int ltc2992_parse_dt(struct ltc2992_state *st) { struct fwnode_handle *fwnode; - struct fwnode_handle *child; u32 addr; u32 val; int ret; fwnode = dev_fwnode(&st->client->dev); - fwnode_for_each_available_child_node(fwnode, child) { + fwnode_for_each_available_child_node_scoped(fwnode, child) { ret = fwnode_property_read_u32(child, "reg", &addr); - if (ret < 0) { - fwnode_handle_put(child); + if (ret < 0) return ret; - } - if (addr > 1) { - fwnode_handle_put(child); + if (addr > 1) return -EINVAL; - } ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); if (!ret) { - if (!val) { - fwnode_handle_put(child); + if (!val) return dev_err_probe(&st->client->dev, -EINVAL, "shunt resistor value cannot be zero\n"); - } st->r_sense_uohm[addr] = val; } } -- 2.40.1