Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp3102885lfb; Tue, 28 Jun 2022 06:35:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLln+Rh2gDopWJEpsIu1y+PtrFs8H5wQh0lcGzzo8HKYYa6dQCplagFTD9vlnymfSwqiTs X-Received: by 2002:a05:6402:3481:b0:435:b12d:a66d with SMTP id v1-20020a056402348100b00435b12da66dmr23703401edc.135.1656423302586; Tue, 28 Jun 2022 06:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423302; cv=none; d=google.com; s=arc-20160816; b=EUErbSyJV2Q9zN81eC11gmtc0LLIog98fiVQmMfGwIiLhBVXP0UKorek7C34TOmCJf 4LRrTSXH6zlRb7PvWm/mZxxynu4vIaMGAKAqZlz4T/PfKM039l1fDZJ1GDVS7fqH+GGp kWdeRAPcb6gUUVXSugRx7cALJwdPiRfNI80HQExWkhqZ7/9LmZy0bgH9JB/ZCSlk33Ar XfjRFShVRiMFhliLhZgKRilbhlD6NF68Q1vFsyB3qCndKOUsMZpRuB/LGpF2kPv/TUMT evijAUnwaObZ20eba9wy4pcdbqUQy1D0ve4QGmmk1h2d1nfrJtckt0AkYcMtQh5jlM3E u5tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KUbAe9KIFqNmXcILHrcWkvl+JB7aEyvyKPLhAfKu+yI=; b=nmFjMoeoT09j2IUc1TQGJG+CL6rpqk+n/8qp4iDdLRaVycLblwBlXWMtPQgBYZYeif Hc4xNLhW04MNTREj590n8oElLgZqK+kgNb+IIev2cAVpBjwyZ+u9rk7j/nARM8Ch0CPA L/vzUztzmWyNY6i1Ah8tKzllEbOgrphQ/cORrlT58ayFDPQ9QvA3G7W+n7cDYpVD6Vt+ qbou/8bZsYLiia4w7x4oSqbZMJ8IwgOgIt5X+dc1ZT5WaI7kTZfNchDwJJXI2kw/a84C Al/9FPbq7fVru4o6gg+e1oOca/XV4FuuvajrAXXfIQ/wSf5bx6pYK5mX23BWoQMf4jBz s13w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EYWtZF+i; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a50f107000000b004357523b6a3si17637944edl.550.2022.06.28.06.34.32; Tue, 28 Jun 2022 06:35:02 -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=@gmail.com header.s=20210112 header.b=EYWtZF+i; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346476AbiF1Nbf (ORCPT + 99 others); Tue, 28 Jun 2022 09:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346416AbiF1Nag (ORCPT ); Tue, 28 Jun 2022 09:30:36 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF5E2F6; Tue, 28 Jun 2022 06:29:51 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-31780ad7535so116914207b3.8; Tue, 28 Jun 2022 06:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KUbAe9KIFqNmXcILHrcWkvl+JB7aEyvyKPLhAfKu+yI=; b=EYWtZF+i6Zcnj76xFRShaz2PGKOXa9fUc+eipltW/9qVATRErYqeGw2VmCvJDEFjnq yq2V0RYbZyYBnqirCknkhGQi7jpTnbaHOGi2PFUSy8dmBACe8eYQMMybnh3gL3GcuhbJ 4RrdxH/K1NsX9+StXC3j3754ifoOLqeAdSTLeD+o2gC8cQI5vGXzpJkBL7IhboosxOer 9zduLdvcUlN5AqXc959KFIL0FsKZ1B5NpnZozMYfqEIui1GtxE9zmmX9Bc9oGiZ/0sDn W8NLffDBXll6gkzUI8sE+3QH9C1+H4u45pocqGttmv1KzOTLZLiKvW0SOdE8pHNeOiK6 cYTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KUbAe9KIFqNmXcILHrcWkvl+JB7aEyvyKPLhAfKu+yI=; b=4VYDLy3LeICXcuGMOxdFkQS0Byxmw7aZbUEpu+0ULm9sb6VLL1pyy6PPhMAA1gBvdQ KjAgHyUldBdQ4XLXjIiRtR86fmJZ1kvNzvFUkQRLnnylb4kwN2xNNgQr47FO5FQgwSTv SoSff7OwYW0WM1/uaXzCZFwWeTk1xujOOcxLQr2RnXsHmuBhJs3u51jvA0WQJpznphk9 duT7QKM0ShB/+HGB25v93BkR1oSGMyDtY8Wt+FcFfWJrE20R4mmE/Eh+WhE2OIRlmvx8 QiIJTAVgihdEHrOWPVUT15dpymQ8WTAx5rpEaXBU+NVM+Q5282BJNdPFJ8rwE9PyRfZy APrA== X-Gm-Message-State: AJIora92PUhQHOMQ5Q8tCG4IWb5oSmLPXsSGRrTfTrp7mYKN2gY1Bmv1 Uxxw+uOT5Uztjmn941Ix7wBTc9CPZu36Kxc8/a0= X-Received: by 2002:a81:2386:0:b0:317:6586:8901 with SMTP id j128-20020a812386000000b0031765868901mr21397834ywj.195.1656422991058; Tue, 28 Jun 2022 06:29:51 -0700 (PDT) MIME-Version: 1.0 References: <4e1d5db9dea68d82c94336a1d6aac404@walle.cc> <2f2d7685e0e43194270a310034004970@walle.cc> In-Reply-To: <2f2d7685e0e43194270a310034004970@walle.cc> From: Andy Shevchenko Date: Tue, 28 Jun 2022 15:29:13 +0200 Message-ID: Subject: Re: fwnode_for_each_child_node() and OF backend discrepancy To: Michael Walle Cc: Andy Shevchenko , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , ACPI Devel Maling List , devicetree , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Tue, Jun 28, 2022 at 3:23 PM Michael Walle wrote: > > >> 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. It means the above mentioned condition is wrong: it should be "port_idx >= num_phys_ports" (if the port_idx doesn't exists, that's the bug in the first place) > 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 So, name is wrong, that's how I read it, it should be num_of_acrive_phys_ports (or alike). > I don't > think it's good to deduce it by counting the child nodes anyway, Right. > but it should rather be a (hardcoded) property of the driver. Also good to update. > [1] > https://elixir.bootlin.com/linux/v5.19-rc4/source/drivers/net/ethernet/microchip/lan966x/lan966x_main.c -- With Best Regards, Andy Shevchenko