Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3908689iog; Tue, 28 Jun 2022 05:24:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tmER/3/M0TbuRku//bNyHsvqgGPJgl0uxCr6kQjfomHcBIOAWucuFCqM3PRqgJ3wm5syWX X-Received: by 2002:a17:907:9620:b0:726:9316:54b7 with SMTP id gb32-20020a170907962000b00726931654b7mr14812280ejc.73.1656419055341; Tue, 28 Jun 2022 05:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656419055; cv=none; d=google.com; s=arc-20160816; b=o6SfKAkokj2LleJiChGRid9xXg1U/BN14teL3vK7QknymbsvIkZCMoXQ4srFbZsel+ reA3hf0zExfChIZtVoZhHxEmshgVUJwiNj3A+WLVQ+rFwiuofnoRSb69NXIyKZrv0/30 pZIbdg1KU7BwPKE4lN+66y4NPh6efCruRanD+E7NEp3wqb6Dw4sT+TWsBg3tgrOdC8bN MlJh7+MQPviZoKWzGDgbN5vWx0OgFqqQmxfZo4DPz61fukvYFVzwZBdyDe/PSRBZZ0ky qm20oijjxsRpJG9qaHif8LeToOhs1bz/WF0zeq3Sid5pl+gFxnkfYyUrSR82hSUbXTnh f86A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=za8uTTYx8zFPk1Ng0Xyp1mSh2osnL3ssrrojyyayo04=; b=DHTk0T7xlgd+doOv8FXbJ/AkncNvvXhaMmcQpmQHknOayaWbR+LUCGEflaTBN1N7Gp nQxuuXH9+xpUZEck6jYbCzflsQ+cvNLYsbj3owgDt8MRr/wUjESKXZBGvP7y/93zy3y4 b8RJO4M6CRIjPqm+vYOR8JNWeds31wIlE64JyWcYmC2CpeUOB+StXymEWd1ocy6la/JF 0BwtK6bK6W92juPfmtbNmu1waxiVMI1AeHiVmojZyzrW8fFunaf6wv3R/Xr8ILA/0cju OpJQJc9GV5vwOm9YxsxDWGZCVhzu8ZCTPjWHGD74viL9qqb6Hmmt8/nceixFqf3As9FB eeJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=lHtroMuc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l22-20020a170906795600b00712236ab6aasi15913245ejo.95.2022.06.28.05.23.47; Tue, 28 Jun 2022 05:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=lHtroMuc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345220AbiF1Lgs (ORCPT + 99 others); Tue, 28 Jun 2022 07:36:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbiF1Lgr (ORCPT ); Tue, 28 Jun 2022 07:36:47 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFAF4326F2; Tue, 28 Jun 2022 04:36:46 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A8CAE22246; Tue, 28 Jun 2022 13:36:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656416204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=za8uTTYx8zFPk1Ng0Xyp1mSh2osnL3ssrrojyyayo04=; b=lHtroMucaHy91RglKDxtz8KfYfdTkDypNHaOuDniKsEcg1oSpJakww1A9ZsQRDDzQMxmqn kGlVoX7XYWdcwQgQxg4NQH141viaDiZgkPsezNCgHTyKV9YVcClKgoWgrgvf3vQSDHi/UF ZdHhPcanYwYElIjr9YOrj78V+G+Wmj0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 28 Jun 2022 13:36:44 +0200 From: Michael Walle To: Andy Shevchenko Cc: "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: fwnode_for_each_child_node() and OF backend discrepancy In-Reply-To: References: <4e1d5db9dea68d82c94336a1d6aac404@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-06-28 13:10, schrieb Andy Shevchenko: > On Mon, Jun 27, 2022 at 02:49:51PM +0200, Michael Walle wrote: >> Hi, >> >> I tired to iterate over all child nodes, regardless if they are >> available >> or not. Now there is that handy fwnode_for_each_child_node() (and the >> fwnode_for_each_available_child_node()). The only thing is the OF >> backend >> already skips disabled nodes [1], making fwnode_for_each_child_node() >> and >> fwnode_for_each_available_child_node() behave the same with the OF >> backend. >> >> Doesn't seem to be noticed by anyone for now. I'm not sure how to fix >> that >> one. fwnode_for_each_child_node() and also >> fwnode_get_next_child_node() are >> used by a handful of drivers. I've looked at some, but couldn't decide >> whether they really want to iterate over all child nodes or just the >> enabled >> ones. >> >> Any thoughts? > > It was discussed at least twice this year (in regard to some new IIO > drivers) > and Rob told that iterating over disabled (not available) nodes in OF > kinda > legacy/design mistake. That's why device_for_each_child_node() goes > only > over available nodes only. Mh, but then the fwnode_for_each_child_node() is very misleading, esp. with the presence of fwnode_for_each_available_child_node(). > So, why do you need to iterate over disabled ones? I was trying to fix the lan966x driver [1] which doesn't work if there are disabled nodes in between. My steps would have been: (1) change fwnode_for_each_available_child_node() to fwnode_for_each_child_node(), maybe with a fixes tag, as it's easy to backport (2) introduce new compatibles and deduce the number of ports according to the compatible string and not by counting the child nodes. (3) keep the old behavior for the legacy compatible and mark it as deprecated in the binding (4) move the device tree over to the new compatible string -michael [1] https://elixir.bootlin.com/linux/v5.19-rc4/source/drivers/net/ethernet/microchip/lan966x/lan966x_main.c#L1029