Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp3102150lfb; Tue, 28 Jun 2022 06:33:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdM+4mmHwL5rPrYHxw+zrUpblWG+axb0yVg+KM521HDzIgvnSMyGg5pf+8WgCGbiPH5xz0 X-Received: by 2002:a17:906:db:b0:718:d986:d3d7 with SMTP id 27-20020a17090600db00b00718d986d3d7mr17886452eji.532.1656423238818; Tue, 28 Jun 2022 06:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423238; cv=none; d=google.com; s=arc-20160816; b=b0mG74127OIxTFnZh3+56btbva9t2wwjf3c3V9J+JhMaJPZ2YhasiomA+U7lF+0S45 idC0dolKbNif4ygMkjDnTGTA1m6EagWrl8apaaK6kksUvcYEYKnw2CQkpv/xcQrC3z0/ /T/4s0u27hYsQEXnn4f02SHNWm/c9t74WdMeK01jMMWLpY/yNwVVnqMoUrQ+MYPEGEGQ HPSRUe/ecylcXQGS/sDWCo9fexeDcRX5GtHXl0mhW2jeypU5yED8EJjeNrrI2Gu8WMo3 EUkvxFRirsIdmLOfJoUr0VM/+X9UePqGLstxYUSYHHn/FHcYk5q5ASCIy+tYL0JymqyG n0PQ== 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=wlYpkKGqhGxgtH3RgvwIlSJi7ei0NyqGbdtxd8Tr3hU=; b=oDn7JXu0HYc+6s9txqXiAmo95NwML/+/NhLBUjCz+h+4YpCtqHHoj+YQ1RnPyf9lJW jJR7GbbbBSOhb2Acu/4ySW2h4ZshwiaFK7wnMd9JvgKnUftY6K4j9szT1xGRBEZp2qqq Qaelirh7luT1CTxs9hotZPSW2fEOnErB85RuCQrfd3Q3bJRDnh8s+vIJXTP+hcqXy1EQ 1UNKIkqjH2E+olkz9Ie1I1CqliPBEVvPIS3xa6jnpPujGNTrlT6/oliEWiydtSF6mA4E VFL4bY1//2+WZT9X86thBfPORVP85QfiVjTiBcsvw/Qez3C7eEjLXPqmZ4tNnM5/S+za vkoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=jRiVC0Gj; 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 s26-20020a056402037a00b004379b762648si4068156edw.109.2022.06.28.06.33.31; Tue, 28 Jun 2022 06:33:58 -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=jRiVC0Gj; 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 S1346070AbiF1N1P (ORCPT + 99 others); Tue, 28 Jun 2022 09:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237534AbiF1N0l (ORCPT ); Tue, 28 Jun 2022 09:26:41 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C7472CE0D; Tue, 28 Jun 2022 06:23:53 -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 EF04022246; Tue, 28 Jun 2022 15:23:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656422631; 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=wlYpkKGqhGxgtH3RgvwIlSJi7ei0NyqGbdtxd8Tr3hU=; b=jRiVC0Gjfp8dtLh7H2btzlEmJsz7YuW1NcwOrNk64H3z4ZWbP7wupdoDiiaHBIxryuFNzx wXDLij9RwDQ2OzPqZtdsMFWP2ubHzcg8v86sXDgeKFKY43uUwLVdTDYre/enR0ZxnW63/o v+F4rmsf1J36hW1KDt8SMX0BsLXnues= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 28 Jun 2022 15:23:50 +0200 From: Michael Walle To: Andy Shevchenko Cc: Andy Shevchenko , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , ACPI Devel Maling List , devicetree , Linux Kernel Mailing List 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: <2f2d7685e0e43194270a310034004970@walle.cc> 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 >> I was trying to fix the lan966x driver [1] which doesn't work if there >> are disabled nodes in between. > > Can you elaborate what's wrong now in the behaviour of the driver? In > the code it uses twice the _available variant. Imagine the following device tree snippet: port0 { reg = <0>; status = "okay"; } port1 { reg = <1>; status = "disabled"; } port@2 { reg = <2>; status = "okay"; } The driver will set num_phys_ports to 2. When port@2 is probed, it will have the (correct!) physical port number 2. That will then trigger various EINVAL checks with "port_num >= num_phys_ports" or WARN()s. So the easiest fix would be to actual count all the child nodes (regardless if they are available or not), assuming there are as many nodes as physical ports. But num_phys_ports being a property of the hardware I don't think it's good to deduce it by counting the child nodes anyway, but it should rather be a (hardcoded) property of the driver. -michael [1] https://elixir.bootlin.com/linux/v5.19-rc4/source/drivers/net/ethernet/microchip/lan966x/lan966x_main.c