Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2103730lqb; Mon, 27 May 2024 08:01:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlzJM9mS/5oWGG0ulW/nPD7J7zZ65/O2TZ8o6RJjiw/4b/nOvcpOtSmaPLX8mOx29GEvWgPH6vyp8rgYCf1PH9gkwzwZtL5m0CsO6zPg== X-Google-Smtp-Source: AGHT+IGYXG7qsE+OqDv/VTGhxYKsNcRF7vxwwSDiOt6JFv8Usj+wt4HhTQsJgLDUJZw56LIiDjbA X-Received: by 2002:a50:8e17:0:b0:578:67db:7529 with SMTP id 4fb4d7f45d1cf-57867db789fmr4366977a12.4.1716822087009; Mon, 27 May 2024 08:01:27 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-579da93e574si739944a12.169.2024.05.27.08.01.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-190978-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 am.mirrors.kernel.org (Postfix) with ESMTPS id 82D6A1F21F18 for ; Mon, 27 May 2024 15:01:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C836D16ABFD; Mon, 27 May 2024 14:31:23 +0000 (UTC) Received: from fgw20-7.mail.saunalahti.fi (fgw20-7.mail.saunalahti.fi [62.142.5.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A401C15F33A for ; Mon, 27 May 2024 14:31:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716820283; cv=none; b=EhcBXYhrsJOCol1LIJ4U4ocxT8FAaq0J5te5S9hTJoGNdYVBR4dT6LzgSM1oE54gR7OAgUiaSEcd1z+TUGgZ377RVjDFqgjDtjZMzIYXDfUKDpnA537YxCkDOZq991xI0PkknFAp+UYm1ZGeam+mugmBhtJOoRIkhRd/6j/L1E0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716820283; c=relaxed/simple; bh=zQPbdgs7RCJg4Qq0wbiVF+3cbUHM+UsGXZAKlfdrC84=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SacKVmbVo2vzL0oxz7TBtYKwO7YlnXOGFYQDnd3DpLZL6L8Fsh25USDIxi1tV1I9XNTCxqc2sqEVLbO16qlzsD7DEeFH8QzNQhTPZJrT8OrLsei3hyb0YX2C+uBc+MdeY3fRnUfAIwOqWnXmYOIjhQpKIqslEkqbKZqb2rcjizE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-26-230.elisa-laajakaista.fi [88.113.26.230]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id 9f91693c-1c35-11ef-80bb-005056bdfda7; Mon, 27 May 2024 17:30:11 +0300 (EEST) From: Andy Shevchenko Date: Mon, 27 May 2024 17:30:10 +0300 To: Jonathan Cameron Cc: Javier Carrasco , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Jean Delvare , Guenter Roeck , Antoniu Miclaus , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Subject: Re: [PATCH v2 3/3] hwmon: (ltc2992) Use fwnode_for_each_available_child_node_scoped() Message-ID: References: <20240523-fwnode_for_each_available_child_node_scoped-v2-0-701f3a03f2fb@gmail.com> <20240523-fwnode_for_each_available_child_node_scoped-v2-3-701f3a03f2fb@gmail.com> <20240526144851.493dd3f2@jic23-huawei> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240526144851.493dd3f2@jic23-huawei> Sun, May 26, 2024 at 02:48:51PM +0100, Jonathan Cameron kirjoitti: > On Thu, 23 May 2024 17:47:16 +0200 > Javier Carrasco wrote: > > > 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 > > This looks like another instances of the lack of clarify about > what device_for_each_child_node[_scoped]() guarantees about node availability. > On DT it guarantees the node is available as ultimately calls > of_get_next_available_child() > > On ACPI it doesn't (I think). > For swnode, there isn't an obvious concept of available. > > It would be much better if we reached some agreement on this and > hence could avoid using the fwnode variants just to get the _available_ form > as done here. > Or just add the device_for_each_available_child_node[_scoped]() > and call that in almost all cases. device_for_each*() _implies_ availability. You need to talk to Rob about all this. The design of the device_for_each*() was exactly done in accordance with his suggestions... > In generic code, do we ever want to walk unavailable child nodes? ..which are most likely like your question here, i.e. why we ever need to traverse over unavailable nodes. -- With Best Regards, Andy Shevchenko